Skip to content

Commit

Permalink
Force TCP KeepAlive on both sides of proxied connection
Browse files Browse the repository at this point in the history
  • Loading branch information
Chupaka committed Jan 17, 2023
1 parent fc9c75f commit cf3da59
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ func proxy(local io.ReadWriteCloser, remoteAddr *net.TCPAddr) {
return
}

local.(*net.TCPConn).SetKeepAlive(true)
local.(*net.TCPConn).SetKeepAlivePeriod(5 * time.Second)

remote.(*net.TCPConn).SetKeepAlive(true)
remote.(*net.TCPConn).SetKeepAlivePeriod(5 * time.Second)

go pipe(local, remote)
go pipe(remote, local)
}
Expand Down

0 comments on commit cf3da59

Please sign in to comment.