Skip to content

Commit

Permalink
Update SetLinger comment
Browse files Browse the repository at this point in the history
  • Loading branch information
v-byte-cpu committed Apr 5, 2021
1 parent bf10090 commit 8428e7c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/scan/socks5/socks5.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,13 @@ func (s *Scanner) Scan(ctx context.Context, r *scan.Request) (result scan.Result
return
}
defer conn.Close()
// tell the operating system to discard any unsent or unacknowledged data on Close(),
// after a maximum of 1 second it will release all socket resources and send RST packet,
// fine for the scan
// wait a maximum of 1 second for normal confirmation of connection termination ( FIN,ACK )
// on Close() instead of default net.ipv4.tcp_fin_timeout = 60 seconds;
// if this time has elapsed, the operating system will discard any unsent or unacknowledged
// data, send RST packet and release all socket resources, fine for the scan;
// note that in normal case ( FIN,ACK received ) the socket goes to the TIME-WAIT state anyway,
// it limits the maximum number of open outbound network connections
// so setting net.ipv4.tcp_tw_reuse to 1 is useful
if err = conn.(*net.TCPConn).SetLinger(1); err != nil {
return
}
Expand Down

0 comments on commit 8428e7c

Please sign in to comment.