增加了CIDR判断和返回数据的debug信息

This commit is contained in:
bjd
2021-01-12 17:30:31 +08:00
parent a72fc63c06
commit 3ebb669558
5 changed files with 39 additions and 39 deletions

View File

@@ -49,12 +49,12 @@ func LinkCstp(conn net.Conn, cSess *sessdata.ConnSession) {
switch hdata[6] {
case 0x07: // KEEPALIVE
// do nothing
base.Debug("recv keepalive", cSess.IpAddr)
// base.Debug("recv keepalive", cSess.IpAddr)
case 0x05: // DISCONNECT
base.Debug("DISCONNECT", cSess.IpAddr)
return
case 0x03: // DPD-REQ
base.Debug("recv DPD-REQ", cSess.IpAddr)
// base.Debug("recv DPD-REQ", cSess.IpAddr)
if payloadOut(cSess, sessdata.LTypeIPData, 0x04, nil) {
return
}

View File

@@ -1,6 +1,7 @@
package handler
import (
"bytes"
"fmt"
"log"
"net"
@@ -86,11 +87,11 @@ func LinkTunnel(w http.ResponseWriter, r *http.Request) {
}
// 允许的路由
for _, v := range cSess.Group.RouteInclude {
w.Header().Add("X-CSTP-Split-Include", v.Val)
w.Header().Add("X-CSTP-Split-Include", v.IpMask)
}
// 不允许的路由
for _, v := range cSess.Group.RouteExclude {
w.Header().Add("X-CSTP-Split-Exclude", v.Val)
w.Header().Add("X-CSTP-Split-Exclude", v.IpMask)
}
w.Header().Set("X-CSTP-Lease-Duration", fmt.Sprintf("%d", base.Cfg.IpLease)) // ip地址租期
@@ -130,8 +131,11 @@ func LinkTunnel(w http.ResponseWriter, r *http.Request) {
// w.Header().Set("X-CSTP-Post-Auth-XML", ``)
w.WriteHeader(http.StatusOK)
// h := w.Header().Clone()
// h.Write(os.Stdout)
h := w.Header().Clone()
headers := make([]byte, 0)
buf := bytes.NewBuffer(headers)
h.Write(buf)
base.Debug(string(buf.Bytes()))
hj := w.(http.Hijacker)
conn, _, err := hj.Hijack()