mirror of
https://github.com/ehang-io/nps.git
synced 2025-08-31 17:56:56 +00:00
remove tcp keep-alive and update socks5 udp
This commit is contained in:
@@ -3,7 +3,6 @@ package proxy
|
||||
import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"strconv"
|
||||
@@ -174,12 +173,7 @@ func (s *Sock5ModeServer) sendUdpReply(writeConn net.Conn, c net.Conn, rep uint8
|
||||
|
||||
}
|
||||
|
||||
var serveExternalIp string
|
||||
|
||||
func (s *Sock5ModeServer) handleUDP(c net.Conn) {
|
||||
if serveExternalIp == "" {
|
||||
serveExternalIp = common.GetExternalIp()
|
||||
}
|
||||
defer c.Close()
|
||||
addrType := make([]byte, 1)
|
||||
c.Read(addrType)
|
||||
@@ -206,7 +200,7 @@ func (s *Sock5ModeServer) handleUDP(c net.Conn) {
|
||||
//读取端口
|
||||
var port uint16
|
||||
binary.Read(c, binary.BigEndian, &port)
|
||||
fmt.Println(host, string(port))
|
||||
logs.Warn(host, string(port))
|
||||
replyAddr, err := net.ResolveUDPAddr("udp", s.task.ServerIp+":0")
|
||||
if err != nil {
|
||||
logs.Error("build local reply addr error", err)
|
||||
@@ -219,9 +213,8 @@ func (s *Sock5ModeServer) handleUDP(c net.Conn) {
|
||||
return
|
||||
}
|
||||
// reply the local addr
|
||||
s.sendUdpReply(c, reply, succeeded, serveExternalIp)
|
||||
s.sendUdpReply(c, reply, succeeded, common.GetServerIpByClientIp(c.RemoteAddr().(*net.TCPAddr).IP))
|
||||
defer reply.Close()
|
||||
|
||||
// new a tunnel to client
|
||||
link := conn.NewLink("udp", "", s.task.Client.Cnf.Crypt, s.task.Client.Cnf.Compress, c.RemoteAddr().String(), false)
|
||||
target, err := s.bridge.SendLinkInfo(s.task.Client.Id, link, s.task)
|
||||
|
Reference in New Issue
Block a user