return unreachable for ipv6 addresses to force ipv4 (#159)
This commit is contained in:
1 parent
a0229885ca
commit
f4714f93d6
7 files changed
+232
-29
No files matched your search
@@ -26,7 +26,6 @@ const (
|
||||
|
||||
const readBufSize = 65536
|
||||
|
||||
|
||||
var framePool = sync.Pool{
|
||||
New: func() any {
|
||||
buf := make([]byte, 5+readBufSize)
|
||||
@@ -72,7 +71,6 @@ func logMsg(format string, args ...any) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
type wsWriter struct {
|
||||
ws *websocket.Conn
|
||||
ch chan []byte
|
||||
@@ -113,7 +111,6 @@ func (w *wsWriter) close() {
|
||||
<-w.done
|
||||
}
|
||||
|
||||
|
||||
var activeJoiner struct {
|
||||
sync.Mutex
|
||||
j *joinerRelay
|
||||
@@ -289,13 +286,7 @@ func (j *joinerRelay) handleUDPAssociate(tcpConn net.Conn) {
|
||||
binary.BigEndian.Uint16(buf[5+dlen:7+dlen]))
|
||||
headerLen = 5 + dlen + 2
|
||||
case common.AtypIPv6:
|
||||
if n < 22 {
|
||||
continue
|
||||
}
|
||||
ip := net.IP(buf[4:20])
|
||||
dstAddr = fmt.Sprintf("[%s]:%d", ip.String(),
|
||||
binary.BigEndian.Uint16(buf[20:22]))
|
||||
headerLen = 22
|
||||
continue
|
||||
default:
|
||||
continue
|
||||
}
|
||||
@@ -430,13 +421,9 @@ func (j *joinerRelay) handleSOCKS(conn net.Conn) {
|
||||
host = fmt.Sprintf("%s:%d", string(buf[5:5+dlen]),
|
||||
binary.BigEndian.Uint16(buf[5+dlen:7+dlen]))
|
||||
case common.AtypIPv6:
|
||||
if n < 22 {
|
||||
conn.Close()
|
||||
return
|
||||
}
|
||||
ip := net.IP(buf[4:20])
|
||||
host = fmt.Sprintf("[%s]:%d", ip.String(),
|
||||
binary.BigEndian.Uint16(buf[20:22]))
|
||||
conn.Write(common.NetUnreach)
|
||||
conn.Close()
|
||||
return
|
||||
default:
|
||||
conn.Write(common.AddrErr)
|
||||
conn.Close()
|
||||
@@ -471,4 +458,3 @@ func (j *joinerRelay) handleSOCKS(conn net.Conn) {
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user