proxy: record failures of remote connection only

This commit is contained in:
nadoo committed 2020-09-14 20:56:37 +08:00
1 parent b3b11b4188
commit 89114e678b
7 files changed
+33 -15

No files matched your search

+6 -2
View File
@@ -15,6 +15,7 @@ import (
"net"
"net/url"
"strconv"
"strings"
"sync"
"time"
@@ -142,8 +143,11 @@ func (s *Socks5) Serve(c net.Conn) {
log.F("[socks5] %s <-> %s via %s", c.RemoteAddr(), tgt, dialer.Addr())
if err = conn.Relay(c, rc); err != nil {
log.F("[socks5] relay error: %v", err)
s.proxy.Record(dialer, false)
log.F("[socks5] %s <-> %s via %s, relay error: %v", c.RemoteAddr(), tgt, dialer.Addr(), err)
// record remote conn failure only
if !strings.Contains(err.Error(), s.addr) {
s.proxy.Record(dialer, false)
}
}
}