Feature: add Mixed(http+socks5) proxy listening (#685)

This commit is contained in:
bytew021
2020-05-12 11:29:53 +08:00
committed by GitHub
parent 3638b077cd
commit 3a27cfc4a1
9 changed files with 186 additions and 5 deletions

View File

@ -36,7 +36,7 @@ func NewSocksProxy(addr string) (*SockListener, error) {
}
continue
}
go handleSocks(c)
go HandleSocks(c)
}
}()
@ -52,13 +52,15 @@ func (l *SockListener) Address() string {
return l.address
}
func handleSocks(conn net.Conn) {
func HandleSocks(conn net.Conn) {
target, command, err := socks5.ServerHandshake(conn, authStore.Authenticator())
if err != nil {
conn.Close()
return
}
conn.(*net.TCPConn).SetKeepAlive(true)
if c, ok := conn.(*net.TCPConn); ok {
c.SetKeepAlive(true)
}
if command == socks5.CmdUDPAssociate {
defer conn.Close()
io.Copy(ioutil.Discard, conn)