From 539f7ff19d3a1317c2d594b16f0b28c3995929c4 Mon Sep 17 00:00:00 2001 From: nervuri Date: Thu, 26 May 2022 00:00:00 +0000 Subject: [PATCH] go fmt --- client_hello_parser.go | 52 +++++++++++++++++++++--------------------- server.go | 10 ++++---- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/client_hello_parser.go b/client_hello_parser.go index 1b9dd8a..2ed13d2 100644 --- a/client_hello_parser.go +++ b/client_hello_parser.go @@ -172,21 +172,21 @@ func (numbers uint8Slice) MarshalJSON() ([]byte, error) { } type extensionData struct { - Raw byteSlice `json:"raw"` - ServerName string `json:"server_name,omitempty"` - StatusType uint8 `json:"status_type,omitempty"` - SupportedGroups []curveID `json:"supported_groups,omitempty"` - SupportedPointFormats uint8Slice `json:"supported_point_formats,omitempty"` - SupportedSignatureAlgorithms []signatureScheme `json:"supported_signature_algorithms,omitempty"` - RenegotiationInfo []byte `json:"renegotiation_info,omitempty"` - AlpnProtocols []string `json:"alpn_protocols,omitempty"` - SupportedVersions []uint16 `json:"supported_tls_versions,omitempty"` - Cookie byteSlice `json:"cookie,omitempty"` - KeyShares []keyShare `json:"key_shares,omitempty"` - PskModes uint8Slice `json:"psk_modes,omitempty"` - PskIdentities []pskIdentity `json:"psk_identities,omitempty"` - PskBinders []byteSlice `json:"psk_binders,omitempty"` - Length uint16 `json:"length,omitempty"` // padding + Raw byteSlice `json:"raw"` + ServerName string `json:"server_name,omitempty"` + StatusType uint8 `json:"status_type,omitempty"` + SupportedGroups []curveID `json:"supported_groups,omitempty"` + SupportedPointFormats uint8Slice `json:"supported_point_formats,omitempty"` + SupportedSignatureAlgorithms []signatureScheme `json:"supported_signature_algorithms,omitempty"` + RenegotiationInfo []byte `json:"renegotiation_info,omitempty"` + AlpnProtocols []string `json:"alpn_protocols,omitempty"` + SupportedVersions []uint16 `json:"supported_tls_versions,omitempty"` + Cookie byteSlice `json:"cookie,omitempty"` + KeyShares []keyShare `json:"key_shares,omitempty"` + PskModes uint8Slice `json:"psk_modes,omitempty"` + PskIdentities []pskIdentity `json:"psk_identities,omitempty"` + PskBinders []byteSlice `json:"psk_binders,omitempty"` + Length uint16 `json:"length,omitempty"` // padding } type extension struct { @@ -197,13 +197,13 @@ type extension struct { type highlights struct { //SupportedTLSVersions []uint16 - SecureRenegotiationSupport bool `json:"secure_renegotiation_support"` - OcspStaplingSupport bool `json:"ocsp_stapling_support"` - SctSupport bool `json:"sct_support"` + SecureRenegotiationSupport bool `json:"secure_renegotiation_support"` + OcspStaplingSupport bool `json:"ocsp_stapling_support"` + SctSupport bool `json:"sct_support"` // Go's crypto/tls server does not support early data. - EarlyData bool `json:"-"` // don't include in JSON - JA3 string `json:"ja3"` - JA3MD5 byteSlice `json:"ja3_md5"` + EarlyData bool `json:"-"` // don't include in JSON + JA3 string `json:"ja3"` + JA3MD5 byteSlice `json:"ja3_md5"` } type clientHelloMsg struct { @@ -518,7 +518,7 @@ func (m *clientHelloMsg) unmarshal(data []byte) bool { default: // Check if this is a GREASE extension (RFC 8701) if isGREASE(extension.Code) { - extension.Name = "GREASE" + extension.Name = "GREASE" } else { log.Println("Unknown extension:", extension.Code) } @@ -541,7 +541,7 @@ func (m *clientHelloMsg) unmarshal(data []byte) bool { for i, cs := range m.CipherSuites { if !isGREASE(cs) { // ignore GREASE values ja3.WriteString(strconv.FormatUint(uint64(cs), 10)) - if i + 1 != len(m.CipherSuites) { + if i+1 != len(m.CipherSuites) { ja3.WriteString("-") } } @@ -550,7 +550,7 @@ func (m *clientHelloMsg) unmarshal(data []byte) bool { for i, e := range m.Extensions { if !isGREASE(e.Code) { // ignore GREASE values ja3.WriteString(strconv.FormatUint(uint64(e.Code), 10)) - if i + 1 != len(m.Extensions) { + if i+1 != len(m.Extensions) { ja3.WriteString("-") } if e.Code == extensionSupportedGroups { @@ -564,7 +564,7 @@ func (m *clientHelloMsg) unmarshal(data []byte) bool { for i, g := range supportedGroups { if !isGREASE(uint16(g)) { // ignore GREASE values ja3.WriteString(strconv.FormatUint(uint64(g), 10)) - if i + 1 != len(supportedGroups) { + if i+1 != len(supportedGroups) { ja3.WriteString("-") } } @@ -573,7 +573,7 @@ func (m *clientHelloMsg) unmarshal(data []byte) bool { for i, pf := range supportedPointFormats { if !isGREASE(uint16(pf)) { // ignore GREASE values ja3.WriteString(strconv.FormatUint(uint64(pf), 10)) - if i + 1 != len(supportedPointFormats) { + if i+1 != len(supportedPointFormats) { ja3.WriteString("-") } } diff --git a/server.go b/server.go index fd69547..8ace7bc 100644 --- a/server.go +++ b/server.go @@ -11,9 +11,9 @@ import ( "flag" "fmt" "io" + "log" "net" "net/url" - "log" "os/user" "strconv" "strings" @@ -21,7 +21,7 @@ import ( "time" ) -import( +import ( //#include //#include "C" @@ -192,8 +192,8 @@ func tlsHandler(conn *tls.Conn, rawClientHello []byte) { _, err = conn.Write([]byte("20 application/json\r\n")) } } else if strings.HasPrefix(line, "GET ") || - strings.HasPrefix(line, "POST ") || - strings.HasPrefix(line, "HEAD ") { + strings.HasPrefix(line, "POST ") || + strings.HasPrefix(line, "HEAD ") { protocol = "HTTP" path = strings.Split(line, " ")[1] if path == "/" { @@ -243,7 +243,7 @@ func tlsHandler(conn *tls.Conn, rawClientHello []byte) { } } else if path == "/json/v1" { output := struct { - ClientHello clientHelloMsg `json:"client_hello"` + ClientHello clientHelloMsg `json:"client_hello"` TlsConnectionInfo tlsConnectionInfo `json:"connection_info"` }{ clientHello,