Skip to content

Commit

Permalink
Add dial queue full timeout
Browse files Browse the repository at this point in the history
Signed-off-by: Sherlock Holo <sherlockya@gmail.com>
  • Loading branch information
Sherlock-Holo committed Mar 3, 2019
1 parent 4fc95f2 commit b6ff140
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion client/client.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package client

import (
"context"
"crypto/tls"
"crypto/x509"
"io"
Expand Down Expand Up @@ -177,7 +178,20 @@ func (c *Client) handle(conn net.Conn) {
Err: make(chan error, 1),
}

c.connReqChan <- connReq
timeoutCtx := context.Background()
if c.config.Timeout.Duration > 0 {
timeoutCtx, _ = context.WithTimeout(context.Background(), c.config.Timeout.Duration)
}

select {
case <-timeoutCtx.Done():
log.Printf("dial queue is full")
socks.Handshake(libsocks.TTLExpired)
socks.Close()
return

case c.connReqChan <- connReq:
}

var l link.Link

Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package cmd

const version = "0.10.4"
const version = "0.10.5"

0 comments on commit b6ff140

Please # to comment.