Fix(socks5): fully udp associate support (#233)

This commit is contained in:
X. Jason Lyu
2019-07-25 17:47:39 +08:00
committed by Dreamacro
parent 183e776970
commit 1fd8f690fe
13 changed files with 483 additions and 89 deletions

View File

@ -1,6 +1,8 @@
package socks
import (
"io"
"io/ioutil"
"net"
adapters "github.com/Dreamacro/clash/adapters/inbound"
@ -62,7 +64,8 @@ func handleSocks(conn net.Conn) {
}
conn.(*net.TCPConn).SetKeepAlive(true)
if command == socks5.CmdUDPAssociate {
tun.Add(adapters.NewSocket(target, conn, C.SOCKS, C.UDP))
defer conn.Close()
io.Copy(ioutil.Discard, conn)
return
}
tun.Add(adapters.NewSocket(target, conn, C.SOCKS, C.TCP))