tls on a socks5 does NOT work out of the box

master
bel 2023-04-15 15:01:43 -06:00
parent fd9bb5b0b1
commit fd7ec1a90b
1 changed files with 15 additions and 4 deletions

View File

@ -111,11 +111,22 @@ func (p Proxy) ServeTLS(ln net.Listener, certFile, keyFile string) {
ln = tls.NewListener(ln, cfg)
defer ln.Close()
for {
if err := acceptAndHandle(ln, httpproxy.Handler(d), d); err != nil {
panic(err)
socksListener, httpListener := proxymux.SplitSOCKSAndHTTP(ln)
errc := make(chan error, 2)
go func() {
for {
if err := acceptAndHandle(httpListener, httpproxy.Handler(d), d); err != nil {
errc <- err
}
}
}
}()
go func() {
socksProxy := &socks5.Server{Dialer: d}
if err := socksProxy.Serve(socksListener); err != nil {
errc <- err
}
}()
<-errc
}
type singleListener struct {