From 282616a9071c45647de1b67af73856ec577fc867 Mon Sep 17 00:00:00 2001 From: xvzc Date: Sun, 21 Jul 2024 14:34:38 +0900 Subject: [PATCH] set default timeout to 2000ms --- net/conn.go | 8 +++----- proxy/proxy.go | 6 ++---- util/config.go | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/net/conn.go b/net/conn.go index 0937661..21f0267 100644 --- a/net/conn.go +++ b/net/conn.go @@ -176,11 +176,9 @@ func (from *Conn) Serve(to *Conn, proto string, fd string, td string, timeout in proto += " " for { - if timeout > 0 { - from.SetReadDeadline( - time.Now().Add(time.Millisecond * time.Duration(timeout)), - ) - } + from.SetReadDeadline( + time.Now().Add(time.Millisecond * time.Duration(timeout)), + ) buf, err := from.ReadBytes() if err != nil { diff --git a/proxy/proxy.go b/proxy/proxy.go index 45fbd7c..88c8b97 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -39,11 +39,9 @@ func (p *Proxy) Start() { os.Exit(1) } - if p.timeout > 0 { - log.Println(fmt.Sprintf("Connection timeout is set to %dms", p.timeout)) - } + log.Println(fmt.Sprintf("Connection timeout is set to %dms", p.timeout)) - log.Println("Created a listener on port", p.Port()) + log.Println("Created a listener on port", p.Port()) for { conn, err := l.Accept() diff --git a/util/config.go b/util/config.go index d73c09b..be42f35 100644 --- a/util/config.go +++ b/util/config.go @@ -56,7 +56,7 @@ func ParseArgs() { config.Dns = flag.String("dns", "8.8.8.8", "DNS server") config.Debug = flag.Bool("debug", false, "true | false") config.NoBanner = flag.Bool("no-banner", false, "true | false") - config.Timeout = flag.Int("timeout", 0, "timeout in milliseconds") + config.Timeout = flag.Int("timeout", 2000, "timeout in milliseconds") flag.Var(&allowedHosts, "url", "Bypass DPI only on this url, can be passed multiple times") allowedPattern = flag.String(