Skip to content

Commit

Permalink
Merge pull request #59 from xvzc/timeout
Browse files Browse the repository at this point in the history
set default timeout to 2000ms
  • Loading branch information
xvzc authored Jul 21, 2024
2 parents 31a96b1 + 282616a commit d84dff0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
8 changes: 3 additions & 5 deletions net/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 2 additions & 4 deletions proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion util/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit d84dff0

Please sign in to comment.