diff options
| -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 | ||||
| -rw-r--r-- | networkQuality.go | 10 | ||||
| -rw-r--r-- | rpm/rpm.go | 29 |
6 files changed, 68 insertions, 19 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 } diff --git a/networkQuality.go b/networkQuality.go index eb8bdc4..93c42e0 100644 --- a/networkQuality.go +++ b/networkQuality.go @@ -110,7 +110,9 @@ func main() { if *calculateExtendedStats && !extendedstats.ExtendedStatsAvailable() { *calculateExtendedStats = false - fmt.Printf("Warning: Calculation of extended statistics was requested but they are not supported on this platform.\n") + fmt.Printf( + "Warning: Calculation of extended statistics was requested but they are not supported on this platform.\n", + ) } if err := config.Get(configHostPort, *configPath); err != nil { @@ -319,7 +321,11 @@ func main() { panic("Extended stats are not available but the user requested their calculation.") } if err := extendedStats.IncorporateConnectionStats(downloadSaturation.LGCs[i].Stats().ConnInfo.Conn); err != nil { - fmt.Fprintf(os.Stderr, "Warning: Could not add extended stats for the connection: %v", err) + fmt.Fprintf( + os.Stderr, + "Warning: Could not add extended stats for the connection: %v", + err, + ) } } } @@ -128,7 +128,11 @@ func Saturate( allInvalid = false currentTransferred, currentInterval := lgcs[i].TransferredInInterval() // normalize to a second-long interval! - instantaneousTransferred := float64(currentTransferred) / float64(currentInterval.Seconds()) + instantaneousTransferred := float64( + currentTransferred, + ) / float64( + currentInterval.Seconds(), + ) totalTransfer += instantaneousTransferred } @@ -315,7 +319,9 @@ func (p *Probe) GetTLSAndHttpHeaderDelta() time.Duration { } func (p *Probe) GetHttpHeaderDelta() time.Duration { - panic("Unusable until TLS tracing support is enabled! Use GetTLSAndHttpHeaderDelta() instead.\n") + panic( + "Unusable until TLS tracing support is enabled! Use GetTLSAndHttpHeaderDelta() instead.\n", + ) delta := p.stats.HttpResponseReadyTime.Sub(utilities.GetSome(p.stats.TLSDoneTime)) if debug.IsDebug(p.debug) { fmt.Printf("(Probe %v): Http Header Time: %v\n", p.probeid, delta) @@ -495,7 +501,12 @@ func (probe *Probe) SetHttpResponseReadyTime( } } -func getLatency(ctx context.Context, probe *Probe, url string, debugLevel debug.DebugLevel) utilities.MeasurementResult { +func getLatency( + ctx context.Context, + probe *Probe, + url string, + debugLevel debug.DebugLevel, +) utilities.MeasurementResult { time_before_probe := time.Now() probe_req, err := http.NewRequestWithContext( httptrace.WithClientTrace(ctx, probe.GetTrace()), @@ -526,8 +537,10 @@ func getLatency(ctx context.Context, probe *Probe, url string, debugLevel debug. sanity := time_after_probe.Sub(time_before_probe) tlsAndHttpHeaderDelta := probe.GetTLSAndHttpHeaderDelta() - httpDownloadDelta := probe.GetHttpDownloadDelta(time_after_probe) // Combined with above, constitutes 2 time measurements, per the Spec. - tcpDelta := probe.GetTCPDelta() // Constitutes 1 time measurement, per the Spec. + httpDownloadDelta := probe.GetHttpDownloadDelta( + time_after_probe, + ) // Combined with above, constitutes 2 time measurements, per the Spec. + tcpDelta := probe.GetTCPDelta() // Constitutes 1 time measurement, per the Spec. totalDelay := tlsAndHttpHeaderDelta + httpDownloadDelta + tcpDelta // By default, assume that there was a reused connection which @@ -547,7 +560,11 @@ func getLatency(ctx context.Context, probe *Probe, url string, debugLevel debug. totalDelay, ) } - return utilities.MeasurementResult{Delay: totalDelay, MeasurementCount: measurementCount, Err: nil} + return utilities.MeasurementResult{ + Delay: totalDelay, + MeasurementCount: measurementCount, + Err: nil, + } } func CalculateProbeMeasurements( |
