Skip to content

Commit 3bc8465

Browse files
code cleanup
1 parent 1410732 commit 3bc8465

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

tool/tcping.go

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,11 @@ func TCPing(q *TCPingQ) (*TCPingP, error) {
7272
for i := uint64(0); i < q.Times; i++ {
7373
ctx, cancel = context.WithCancel(context.Background())
7474
conn, err := d.DialContext(ctx, network, addr.String())
75-
if err != nil {
76-
r.Data = append(r.Data, TCPingPEntry{
77-
Success: false,
78-
Latency: float64(time.Since(now)) / float64(time.Millisecond),
79-
})
80-
} else {
81-
r.Data = append(r.Data, TCPingPEntry{
82-
Success: true,
83-
Latency: float64(time.Since(now)) / float64(time.Millisecond),
84-
})
85-
_ = conn.Close()
86-
}
75+
r.Data = append(r.Data, TCPingPEntry{
76+
Success: err == nil,
77+
Latency: float64(time.Since(now)) / float64(time.Millisecond),
78+
})
79+
_ = conn.Close()
8780
timer.Stop()
8881
cancel()
8982
time.Sleep(time.Duration(q.Interval) * time.Millisecond)

tool/tls.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ func TLS(q *TlsQ) (*TlsP, error) {
225225
cert := state.PeerCertificates[i-1]
226226
hash := sha256.Sum256(cert.Raw)
227227
data := Certificate{
228+
Size: len(cert.Raw),
228229
Subject: cert.Subject.String(),
229230
Issuer: cert.Issuer.String(),
230231
NotBefore: cert.NotBefore,

tool/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ const (
153153
)
154154

155155
type Certificate struct {
156+
Size int `json:"size,omitempty"`
156157
Valid bool `json:"valid"`
157158

158159
Subject string `json:"subject"`

0 commit comments

Comments
 (0)