func runSOCKS5Server(conf Config, router socks.Router) { if conf.SOCKS5Addr != "" { listener, err := net.Listen("tcp", conf.SOCKS5Addr) if err == nil { listener = NewDecorateListener(listener, CipherConnDecorator(conf.LocalCryptoMethod, conf.LocalCryptoPassword)) socks5Svr := socks.NewSocks5Server(router) go socks5Svr.Run(listener) } } }
func runSOCKS5Server(conf Proxy, forward socks.Dialer) { if conf.SOCKS5 != "" { listener, err := net.Listen("tcp", conf.SOCKS5) if err != nil { ErrLog.Println("net.Listen failed, err:", err, conf.SOCKS5) return } cipherDecorator := NewCipherConnDecorator(conf.Crypto, conf.Password) listener = NewDecorateListener(listener, cipherDecorator) socks5Svr, err := socks.NewSocks5Server(forward) if err != nil { listener.Close() ErrLog.Println("socks.NewSocks5Server failed, err:", err) return } go func() { defer listener.Close() socks5Svr.Serve(listener) }() } }