diff options
Diffstat (limited to 'extendedstats')
| -rw-r--r-- | extendedstats/darwin.go | 16 | ||||
| -rw-r--r-- | extendedstats/other.go | 2 | ||||
| -rw-r--r-- | extendedstats/unix.go | 10 | ||||
| -rw-r--r-- | extendedstats/windows.go | 20 |
4 files changed, 37 insertions, 11 deletions
diff --git a/extendedstats/darwin.go b/extendedstats/darwin.go index 788e36c..92e48fc 100644 --- a/extendedstats/darwin.go +++ b/extendedstats/darwin.go @@ -32,14 +32,18 @@ func ExtendedStatsAvailable() bool { func (es *ExtendedStats) IncorporateConnectionStats(rawConn net.Conn) error { tlsConn, ok := rawConn.(*tls.Conn) if !ok { - return fmt.Errorf("OOPS: Could not get the TCP info for the connection (not a TLS connection)!\n") + return fmt.Errorf( + "OOPS: Could not get the TCP info for the connection (not a TLS connection)", + ) } tcpConn, ok := tlsConn.NetConn().(*net.TCPConn) if !ok { - return fmt.Errorf("OOPS: Could not get the TCP info for the connection (not a TCP connection)!\n") + return fmt.Errorf( + "OOPS: Could not get the TCP info for the connection (not a TCP connection)", + ) } if info, err := getTCPConnectionInfo(tcpConn); err != nil { - return fmt.Errorf("OOPS: Could not get the TCP info for the connection: %v!\n", err) + return fmt.Errorf("OOPS: Could not get the TCP info for the connection: %v", err) } else { es.Maxseg = utilities.Max(es.Maxseg, uint64(info.Maxseg)) es.TotalReorderings += info.Rxoutoforderbytes @@ -75,7 +79,11 @@ func getTCPConnectionInfo(connection net.Conn) (*unix.TCPConnectionInfo, error) var info *unix.TCPConnectionInfo = nil rawConn.Control(func(fd uintptr) { - info, err = unix.GetsockoptTCPConnectionInfo(int(fd), unix.IPPROTO_TCP, unix.TCP_CONNECTION_INFO) + info, err = unix.GetsockoptTCPConnectionInfo( + int(fd), + unix.IPPROTO_TCP, + unix.TCP_CONNECTION_INFO, + ) }) return info, err } diff --git a/extendedstats/other.go b/extendedstats/other.go index 960ee85..b4eae18 100644 --- a/extendedstats/other.go +++ b/extendedstats/other.go @@ -11,7 +11,7 @@ import ( type ExtendedStats struct{} func (es *ExtendedStats) IncorporateConnectionStats(conn net.Conn) error { - return fmt.Errorf("OOPS: IncorporateConnectionStats is not supported on this platform.") + return fmt.Errorf("OOPS: IncorporateConnectionStats is not supported on this platform") } func (es *ExtendedStats) Repr() string { diff --git a/extendedstats/unix.go b/extendedstats/unix.go index 1448368..a2d4d30 100644 --- a/extendedstats/unix.go +++ b/extendedstats/unix.go @@ -30,14 +30,18 @@ func ExtendedStatsAvailable() bool { func (es *ExtendedStats) IncorporateConnectionStats(rawConn net.Conn) error { tlsConn, ok := rawConn.(*tls.Conn) if !ok { - return fmt.Errorf("OOPS: Could not get the TCP info for the connection (not a TLS connection)!\n") + return fmt.Errorf( + "OOPS: Could not get the TCP info for the connection (not a TLS connection)", + ) } tcpConn, ok := tlsConn.NetConn().(*net.TCPConn) if !ok { - return fmt.Errorf("OOPS: Could not get the TCP info for the connection (not a TCP connection)!\n") + return fmt.Errorf( + "OOPS: Could not get the TCP info for the connection (not a TCP connection)", + ) } if info, err := getTCPInfo(tcpConn); err != nil { - return fmt.Errorf("OOPS: Could not get the TCP info for the connection: %v!\n", err) + return fmt.Errorf("OOPS: Could not get the TCP info for the connection: %v", err) } else { es.MaxPathMtu = utilities.Max(es.MaxPathMtu, uint64(info.Pmtu)) es.MaxRecvMss = utilities.Max(es.MaxRecvMss, uint64(info.Rcv_mss)) diff --git a/extendedstats/windows.go b/extendedstats/windows.go index cc2fca7..c1c80f8 100644 --- a/extendedstats/windows.go +++ b/extendedstats/windows.go @@ -70,11 +70,15 @@ type TCPINFO_V1 struct { func (es *ExtendedStats) IncorporateConnectionStats(rawConn net.Conn) error { tlsConn, ok := rawConn.(*tls.Conn) if !ok { - return fmt.Errorf("OOPS: Could not get the TCP info for the connection (not a TLS connection)") + return fmt.Errorf( + "OOPS: Could not get the TCP info for the connection (not a TLS connection)", + ) } tcpConn, ok := tlsConn.NetConn().(*net.TCPConn) if !ok { - return fmt.Errorf("OOPS: Could not get the TCP info for the connection (not a TCP connection)") + return fmt.Errorf( + "OOPS: Could not get the TCP info for the connection (not a TCP connection)", + ) } if info, err := getTCPInfo(tcpConn); err != nil { return fmt.Errorf("OOPS: Could not get the TCP info for the connection: %v", err) @@ -142,7 +146,17 @@ func getTCPInfo(connection net.Conn) (*TCPINFO_V1, error) { completionRoutine := uintptr(0) rawConn.Control(func(fd uintptr) { - err = windows.WSAIoctl(windows.Handle(fd), iocc, (*byte)(unsafe.Pointer(&inbuf)), cbif, (*byte)(unsafe.Pointer(&outbuf)), cbob, &cbbr, &overlapped, completionRoutine) + err = windows.WSAIoctl( + windows.Handle(fd), + iocc, + (*byte)(unsafe.Pointer(&inbuf)), + cbif, + (*byte)(unsafe.Pointer(&outbuf)), + cbob, + &cbbr, + &overlapped, + completionRoutine, + ) }) return &outbuf, err } |
