diff options
| author | Randall Meyer <[email protected]> | 2022-10-16 15:20:32 -0700 |
|---|---|---|
| committer | Randall Meyer <[email protected]> | 2023-02-20 10:28:21 -0800 |
| commit | 8a66c0ad439a6a5d2ae886b28ec841b3663df226 (patch) | |
| tree | 35c1961dde53d4c3c4a078be426ce833c9332b91 | |
| parent | ea1c43eb259aeefa340bdf99339f4e76bc744e4f (diff) | |
extendedstats: fix build error on other platform
Also, simplify code for darwin's TCPInfo
| -rw-r--r-- | extendedstats/darwin.go | 22 | ||||
| -rw-r--r-- | extendedstats/other.go | 2 |
2 files changed, 8 insertions, 16 deletions
diff --git a/extendedstats/darwin.go b/extendedstats/darwin.go index 59d6e38..19c5bc0 100644 --- a/extendedstats/darwin.go +++ b/extendedstats/darwin.go @@ -28,8 +28,6 @@ import ( type AggregateExtendedStats struct { Maxseg uint64 - MaxSendMss uint64 - MaxRecvMss uint64 TotalRetransmissions uint64 totalSent uint64 TotalReorderings uint64 @@ -44,12 +42,8 @@ func ExtendedStatsAvailable() bool { } type TCPInfo struct { - Rxoutoforderbytes uint64 - Txretransmitbytes uint64 - Txbytes uint64 - Rtt uint32 - Maxseg uint32 - Snd_cwnd uint32 + unix.TCPConnectionInfo + Rtt uint32 // Srtt under Darwin } func (es *AggregateExtendedStats) IncorporateConnectionStats(basicConn net.Conn) error { @@ -98,20 +92,18 @@ func GetTCPInfo(basicConn net.Conn) (*TCPInfo, error) { var rawInfo *unix.TCPConnectionInfo = nil var tcpInfo *TCPInfo = nil - rawConn.Control(func(fd uintptr) { + rerr := rawConn.Control(func(fd uintptr) { rawInfo, err = unix.GetsockoptTCPConnectionInfo( int(fd), unix.IPPROTO_TCP, unix.TCP_CONNECTION_INFO, ) }) + if rerr != nil { + return nil, rerr + } if rawInfo != nil && err == nil { - tcpInfo = &TCPInfo{} - tcpInfo.Rxoutoforderbytes = rawInfo.Rxoutoforderbytes - tcpInfo.Txretransmitbytes = rawInfo.Txretransmitbytes - tcpInfo.Rtt = rawInfo.Srtt - tcpInfo.Snd_cwnd = rawInfo.Snd_cwnd - tcpInfo.Maxseg = rawInfo.Maxseg + tcpInfo = &TCPInfo{TCPConnectionInfo: *rawInfo, Rtt: rawInfo.Srtt} } return tcpInfo, err } diff --git a/extendedstats/other.go b/extendedstats/other.go index 2d76eaf..ed6d925 100644 --- a/extendedstats/other.go +++ b/extendedstats/other.go @@ -36,6 +36,6 @@ func ExtendedStatsAvailable() bool { return false } -func GetTCPInfo(basicConn net.Conn) (interface, error) { +func GetTCPInfo(basicConn net.Conn) (interface{}, error) { return nil, fmt.Errorf("GetTCPInfo is not supported on this platform") } |
