Skip to content

Commit 0dbaecb

Browse files
Smalll fixt to formatting of tls handshake
1 parent e099cfd commit 0dbaecb

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

cmd/gohpts/cli.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ const (
1717
addrHTTP string = "127.0.0.1:8080"
1818
tproxyOS string = "linux"
1919
)
20-
const usagePrefix string = `
21-
_____ _ _ _____ _______ _____
20+
const usagePrefix string = ` _____ _ _ _____ _______ _____
2221
/ ____| | | | | __ \__ __/ ____|
2322
| | __ ___ | |__| | |__) | | | | (___
2423
| | |_ |/ _ \| __ | ___/ | | \___ \

gohpts.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -269,17 +269,20 @@ func (p *proxyapp) colorizeTLS(req *layers.TLSClientHello, resp *layers.TLSServe
269269
if req.Version != nil && req.Version.Desc != "" {
270270
sb.WriteString(fmt.Sprintf(" Ver: %s", req.Version.Desc))
271271
}
272-
if req.SessionID != "" {
273-
sb.WriteString(fmt.Sprintf(" SID: %s", req.SessionID))
274-
}
275272
if req.ALPN != nil {
276273
sb.WriteString(fmt.Sprintf(" ALPN: %v", req.ALPN))
277274
}
278275
sb.WriteString(" -> ")
279-
sb.WriteString(fmt.Sprintf("%s ", resp.TypeDesc))
276+
sb.WriteString("\n")
277+
sb.WriteString(fmt.Sprintf("%s ", p.colorizeTimestamp()))
278+
sb.WriteString(id)
279+
sb.WriteString(fmt.Sprintf(" %s ", resp.TypeDesc))
280280
if resp.Length > 0 {
281281
sb.WriteString(fmt.Sprintf(" Len: %d", resp.Length))
282282
}
283+
if resp.SessionID != "" {
284+
sb.WriteString(fmt.Sprintf(" SID: %s", resp.SessionID))
285+
}
283286
if resp.CipherSuite != nil && resp.CipherSuite.Desc != "" {
284287
sb.WriteString(fmt.Sprintf(" CS: %s", resp.CipherSuite.Desc))
285288
}
@@ -302,17 +305,20 @@ func (p *proxyapp) colorizeTLS(req *layers.TLSClientHello, resp *layers.TLSServe
302305
if req.Version != nil && req.Version.Desc != "" {
303306
sb.WriteString(colors.GreenBg(fmt.Sprintf(" Ver: %s", req.Version.Desc)).String())
304307
}
305-
if req.SessionID != "" {
306-
sb.WriteString(colors.Gray(fmt.Sprintf(" SID: %s", req.SessionID)).String())
307-
}
308308
if req.ALPN != nil {
309309
sb.WriteString(colors.BlueBg(fmt.Sprintf(" ALPN: %v", req.ALPN)).String())
310310
}
311311
sb.WriteString(colors.MagentaBg(" -> ").String())
312-
sb.WriteString(colors.LightBlue(fmt.Sprintf("%s ", resp.TypeDesc)).Bold())
312+
sb.WriteString("\n")
313+
sb.WriteString(fmt.Sprintf("%s ", p.colorizeTimestamp()))
314+
sb.WriteString(id)
315+
sb.WriteString(colors.LightBlue(fmt.Sprintf(" %s ", resp.TypeDesc)).Bold())
313316
if resp.Length > 0 {
314317
sb.WriteString(colors.BeigeBg(fmt.Sprintf(" Len: %d", resp.Length)).String())
315318
}
319+
if resp.SessionID != "" {
320+
sb.WriteString(colors.Gray(fmt.Sprintf(" SID: %s", resp.SessionID)).String())
321+
}
316322
if resp.CipherSuite != nil && resp.CipherSuite.Desc != "" {
317323
sb.WriteString(colors.Yellow(fmt.Sprintf(" CS: %s", resp.CipherSuite.Desc)).Bold())
318324
}

0 commit comments

Comments
 (0)