增加改写from的处理逻辑

This commit is contained in:
lwch
2021-08-23 18:37:38 +08:00
parent b2f343e673
commit 8500462671
2 changed files with 9 additions and 1 deletions
+1 -1
View File
@@ -26,7 +26,7 @@ func (p *Pool) handleConnectReq(conn *network.Conn, from, to string, req *networ
port, _ := strconv.ParseUint(pt, 10, 16)
tn := tunnel.New(global.Tunnel{
Name: req.GetName(),
Target: to,
Target: from,
Type: dial,
LocalAddr: host,
LocalPort: uint16(port),
+8
View File
@@ -108,6 +108,14 @@ func (p *Pool) connect(cfg *global.Configure, idx int) {
logging.Error("read message: %v", err)
return
}
from := msg.GetFrom()
if len(from) > 0 {
n := strings.LastIndex(from, "-")
if n != -1 {
from = from[:n]
}
msg.From = from
}
switch msg.GetXType() {
case network.Msg_connect_req:
p.handleConnectReq(c, msg.GetFrom(), msg.GetTo(), msg.GetCreq())