Skip to content

Commit

Permalink
Merge pull request antoniomika#57 from jonahbull/make-idle-timeout-co…
Browse files Browse the repository at this point in the history
…nfigurable

Make idle timeout configurable
  • Loading branch information
antoniomika authored Dec 16, 2019
2 parents 2882e4d + 29d4802 commit 3e48013
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ Usage of ./sish:
The location of pem files for HTTPS (fullchain.pem and privkey.pem) (default "ssl/")
-sish.httpsport int
The port to use for https command output
-sish.idletimeout int
Number of seconds to wait for activity before closing a connection (default 5)
-sish.keysdir string
Directory for public keys for pubkey auth (default "pubkeys/")
-sish.logtoclient
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ var (
versionCheck = flag.Bool("sish.version", false, "Print version and exit")
tcpAlias = flag.Bool("sish.tcpalias", false, "Whether or not to allow the use of TCP aliasing")
logToClient = flag.Bool("sish.logtoclient", false, "Whether or not to log http requests to the client")
idleTimeout = flag.Int("sish.idletimeout", 5, "Number of seconds to wait for activity before closing a connection")
bannedSubdomainList = []string{""}
filter *ipfilter.IPFilter
)
Expand Down
4 changes: 2 additions & 2 deletions requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ type IdleTimeoutConn struct {

// Read is needed to implement the reader part
func (i IdleTimeoutConn) Read(buf []byte) (int, error) {
err := i.Conn.SetDeadline(time.Now().Add(5 * time.Second))
err := i.Conn.SetDeadline(time.Now().Add(time.Duration(*idleTimeout) * time.Second))
if err != nil {
return 0, err
}
Expand All @@ -249,7 +249,7 @@ func (i IdleTimeoutConn) Read(buf []byte) (int, error) {

// Write is needed to implement the writer part
func (i IdleTimeoutConn) Write(buf []byte) (int, error) {
err := i.Conn.SetDeadline(time.Now().Add(5 * time.Second))
err := i.Conn.SetDeadline(time.Now().Add(time.Duration(*idleTimeout) * time.Second))
if err != nil {
return 0, err
}
Expand Down

0 comments on commit 3e48013

Please sign in to comment.