Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ require (
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/onsi/ginkgo/v2 v2.17.2 // indirect
go.uber.org/mock v0.4.0 // indirect
golang.org/x/crypto v0.36.0 // indirect
golang.org/x/crypto v0.40.0 // indirect
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.38.0 // indirect
golang.org/x/sys v0.31.0 // indirect
golang.org/x/tools v0.20.0 // indirect
golang.org/x/mod v0.25.0 // indirect
golang.org/x/net v0.42.0 // indirect
golang.org/x/sys v0.34.0 // indirect
golang.org/x/text v0.27.0 // indirect
golang.org/x/tools v0.34.0 // indirect
)
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM=
golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY=
golang.org/x/crypto/x509roots/fallback v0.0.0-20240522200748-44c9b0ff9e71 h1:cJ7opb2P6yQGtej4ijbXq7n5agXTJ0vyquZa61aF6xs=
golang.org/x/crypto/x509roots/fallback v0.0.0-20240522200748-44c9b0ff9e71/go.mod h1:kNa9WdvYnzFwC79zRpLRMJbdEFlhyM5RPFBBZp/wWH8=
golang.org/x/crypto/x509roots/fallback v0.0.0-20250529171604-18228cd6f13e h1:/BYQaQnB7gQPmkKz+BOMpN5b0G1IaSu6EGjSgDQYGZE=
Expand All @@ -89,12 +91,15 @@ golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPI
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.25.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs=
golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
Expand All @@ -108,15 +113,20 @@ golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA=
golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4=
golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU=
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY=
golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg=
golang.org/x/tools v0.34.0/go.mod h1:pAP9OwEaY1CAW3HOmg3hLZC5Z0CCmzjAF2UQMSqNARg=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
Expand Down
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func main() {
v4 = fs.BoolShort('4', "only resolve IPv4 (only works when IP is not set)")
v6 = fs.BoolShort('6', "only resolve IPv6 (only works when IP is not set)")
sni = fs.StringLong("sni", "", "tls sni (if IP flag not provided, this SNI will be resolved by system DNS)")
host = fs.StringLong("host", "", "http host (defaults to sni)")
port = fs.UintLong("port", 443, "tls port")
ip = fs.StringLong("ip", "", "manually provide IP (no DNS lookup)")
repeat = fs.UintLong("repeat", 1, "number of times to repeat each test")
Expand Down Expand Up @@ -88,6 +89,9 @@ func main() {
if *sni == "" {
fatal(l, errors.New("must specify SNI"))
}
if *host == "" {
*host = *sni
}

addr := netip.IPv4Unspecified()
if *ip != "" {
Expand All @@ -114,6 +118,7 @@ func main() {
ManualIP: addr.Unmap(),
Port: uint16(*port),
SNI: *sni,
Host: *host,
Repeat: *repeat,
}

Expand Down
6 changes: 4 additions & 2 deletions test_QUIC_TLS13_UQUIC_Chrome_115_Default.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
)

// test_QUIC_TLS13_UQUIC_Chrome_115_Default
func test_QUIC_TLS13_UQUIC_Chrome_115_Default(ctx context.Context, l *slog.Logger, addrPort netip.AddrPort, sni string) TestAttemptResult {
func test_QUIC_TLS13_UQUIC_Chrome_115_Default(ctx context.Context, l *slog.Logger, addrPort netip.AddrPort, sni string, host string) TestAttemptResult {
counter, _, _, _ := runtime.Caller(0)
l = l.With("test", strings.Split(runtime.FuncForPC(counter).Name(), ".")[1], "ip", addrPort.Addr().String())

Expand Down Expand Up @@ -64,6 +64,8 @@ func test_QUIC_TLS13_UQUIC_Chrome_115_Default(ctx context.Context, l *slog.Logge
defer quicConn.CloseWithError(quic.ApplicationErrorCode(quic.NoError), "")
res.TransportEstablishDuration = time.Since(t0)

l.Info("success", "handshake", quicConn.ConnectionState().TLS.HandshakeComplete)
l.Info("handshake success", "handshake", quicConn.ConnectionState().TLS.HandshakeComplete)
l.Warn("TTFB test not yet implemented for QUIC")

return res
}
12 changes: 10 additions & 2 deletions test_TCP_TLS12_Default.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
// default cipher suites
// forced TLS1.2
// default elliptic curve preferences
func test_TCP_TLS12_Default(ctx context.Context, l *slog.Logger, addrPort netip.AddrPort, sni string) TestAttemptResult {
func test_TCP_TLS12_Default(ctx context.Context, l *slog.Logger, addrPort netip.AddrPort, sni string, host string) TestAttemptResult {
counter, _, _, _ := runtime.Caller(0)
l = l.With("test", strings.Split(runtime.FuncForPC(counter).Name(), ".")[1], "ip", addrPort.Addr().String())

Expand Down Expand Up @@ -67,6 +67,14 @@ func test_TCP_TLS12_Default(ctx context.Context, l *slog.Logger, addrPort netip.
res.TLSHandshakeDuration = time.Since(t0)

tlsState := tlsConn.ConnectionState()
l.Info("success", "handshake", tlsState.HandshakeComplete)
l.Info("handshake success", "handshake", tlsState.HandshakeComplete)

ttfb, err := measureTTFB(ctx, tlsConn, host)
if err != nil {
res.err = err
l.Error(err.Error())
}
res.TTFBDuration = ttfb

return res
}
12 changes: 10 additions & 2 deletions test_TCP_TLS13_Default.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
// default cipher suites
// forced TLS1.3
// default elliptic curve preferences
func test_TCP_TLS13_Default(ctx context.Context, l *slog.Logger, addrPort netip.AddrPort, sni string) TestAttemptResult {
func test_TCP_TLS13_Default(ctx context.Context, l *slog.Logger, addrPort netip.AddrPort, sni string, host string) TestAttemptResult {
counter, _, _, _ := runtime.Caller(0)
l = l.With("test", strings.Split(runtime.FuncForPC(counter).Name(), ".")[1], "ip", addrPort.Addr().String())

Expand Down Expand Up @@ -67,6 +67,14 @@ func test_TCP_TLS13_Default(ctx context.Context, l *slog.Logger, addrPort netip.
res.TLSHandshakeDuration = time.Since(t0)

tlsState := tlsConn.ConnectionState()
l.Info("success", "handshake", tlsState.HandshakeComplete)
l.Info("handshake success", "handshake", tlsState.HandshakeComplete)

ttfb, err := measureTTFB(ctx, tlsConn, host)
if err != nil {
res.err = err
l.Error(err.Error())
}
res.TTFBDuration = ttfb

return res
}
12 changes: 10 additions & 2 deletions test_TCP_TLS13_UTLS_ChromeAuto_Default.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
// forced TLS1.3
// default elliptic curve preferences
// utls.HelloChrome_Auto
func test_TCP_TLS13_UTLS_ChromeAuto_Default(ctx context.Context, l *slog.Logger, addrPort netip.AddrPort, sni string) TestAttemptResult {
func test_TCP_TLS13_UTLS_ChromeAuto_Default(ctx context.Context, l *slog.Logger, addrPort netip.AddrPort, sni string, host string) TestAttemptResult {
counter, _, _, _ := runtime.Caller(0)
l = l.With("test", strings.Split(runtime.FuncForPC(counter).Name(), ".")[1], "ip", addrPort.Addr().String())

Expand Down Expand Up @@ -69,6 +69,14 @@ func test_TCP_TLS13_UTLS_ChromeAuto_Default(ctx context.Context, l *slog.Logger,
res.TLSHandshakeDuration = time.Since(t0)

tlsState := tlsConn.ConnectionState()
l.Info("success", "handshake", tlsState.HandshakeComplete)
l.Info("handshake success", "handshake", tlsState.HandshakeComplete)

ttfb, err := measureTTFB(ctx, tlsConn, host)
if err != nil {
res.err = err
l.Error(err.Error())
}
res.TTFBDuration = ttfb

return res
}
11 changes: 9 additions & 2 deletions test_TCP_TLS13_UTLS_ChromeAuto_bepass_fragment.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
// default elliptic curve preferences
// utls.HelloChrome_Auto
// And the bepass fragmenting TCP connection!
func test_TCP_TLS13_UTLS_ChromeAuto_bepass_fragment(ctx context.Context, l *slog.Logger, addrPort netip.AddrPort, sni string) TestAttemptResult {
func test_TCP_TLS13_UTLS_ChromeAuto_bepass_fragment(ctx context.Context, l *slog.Logger, addrPort netip.AddrPort, sni string, host string) TestAttemptResult {
counter, _, _, _ := runtime.Caller(0)
l = l.With("test", strings.Split(runtime.FuncForPC(counter).Name(), ".")[1], "ip", addrPort.Addr().String())

Expand Down Expand Up @@ -79,6 +79,13 @@ func test_TCP_TLS13_UTLS_ChromeAuto_bepass_fragment(ctx context.Context, l *slog
res.TLSHandshakeDuration = time.Since(t0)

tlsState := tlsConn.ConnectionState()
l.Info("success", "handshake", tlsState.HandshakeComplete)
l.Info("handshake success", "handshake", tlsState.HandshakeComplete)
ttfb, err := measureTTFB(ctx, tlsConn, host)
if err != nil {
res.err = err
l.Error(err.Error())
}
res.TTFBDuration = ttfb

return res
}
12 changes: 10 additions & 2 deletions test_TCP_TLS_warp_plus_custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
// test_TCP_TLS_warp_plus_custom is a uTLS connection using:
// warp-plus settings from from warp-plus v1.2.1
// NOTE: the version of uTLS used in warp-plus is much older than here.
func test_TCP_TLS_warp_plus_custom(ctx context.Context, l *slog.Logger, addrPort netip.AddrPort, sni string) TestAttemptResult {
func test_TCP_TLS_warp_plus_custom(ctx context.Context, l *slog.Logger, addrPort netip.AddrPort, sni string, host string) TestAttemptResult {
counter, _, _, _ := runtime.Caller(0)
l = l.With("test", strings.Split(runtime.FuncForPC(counter).Name(), ".")[1], "ip", addrPort.Addr().String())

Expand Down Expand Up @@ -120,7 +120,15 @@ func test_TCP_TLS_warp_plus_custom(ctx context.Context, l *slog.Logger, addrPort
res.TLSHandshakeDuration = time.Since(t0)

tlsState := tlsConn.ConnectionState()
l.Info("success", "handshake", tlsState.HandshakeComplete)
l.Info("handshake success", "handshake", tlsState.HandshakeComplete)

ttfb, err := measureTTFB(ctx, tlsConn, host)
if err != nil {
res.err = err
l.Error(err.Error())
}
res.TTFBDuration = ttfb

return res
}

Expand Down
15 changes: 11 additions & 4 deletions tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type TestOptions struct {
ManualIP netip.Addr
Port uint16
SNI string
Host string
Repeat uint
}

Expand All @@ -33,10 +34,12 @@ type TestResult struct {
type TestAttemptResult struct {
TransportEstablishDuration time.Duration
TLSHandshakeDuration time.Duration
TTFBDuration time.Duration
Conn net.Conn
err error
}

type testFunc func(context.Context, *slog.Logger, netip.AddrPort, string) TestAttemptResult
type testFunc func(context.Context, *slog.Logger, netip.AddrPort, string, string) TestAttemptResult

// Represents a single test function and its label.
type testCase struct {
Expand Down Expand Up @@ -91,7 +94,7 @@ func runTests(ctx context.Context, l *slog.Logger, to TestOptions) error {
for i := uint(0); i < to.Repeat; i++ {
// Create a context with 10-second timeout for each individual test
testCtx, cancel := context.WithTimeout(ctx, 10*time.Second)
tr.Attempts[i] = test(testCtx, l, addrPort, to.SNI)
tr.Attempts[i] = test(testCtx, l, addrPort, to.SNI, to.Host)
cancel() // Always cancel to release resources
time.Sleep(2 * time.Second)
}
Expand All @@ -112,7 +115,7 @@ func printTable(results map[string][]TestResult, order []string) {
headerFmt := color.New(color.FgHiMagenta, color.Bold, color.Underline).SprintfFunc()
columnFmt := color.New(color.FgHiCyan, color.Bold).SprintfFunc()

tbl := table.New("Test Method", "SNI", "IP:Port", "Handshake Status", "Transport Time", "TLS Handshake Time")
tbl := table.New("Method", "SNI", "IP:Port", "Handshake", "Transport", "TLS Handshake", "TTFB")
tbl.WithHeaderFormatter(headerFmt).WithFirstColumnFormatter(columnFmt)

for _, testName := range order {
Expand All @@ -122,13 +125,15 @@ func printTable(results map[string][]TestResult, order []string) {
successCount int
totalTransport time.Duration
totalTLS time.Duration
totalTTFB time.Duration
)

for _, attempt := range testResult.Attempts {
if attempt.err == nil {
successCount++
totalTransport += attempt.TransportEstablishDuration
totalTLS += attempt.TLSHandshakeDuration
totalTTFB += attempt.TTFBDuration
}
}

Expand All @@ -143,10 +148,11 @@ func printTable(results map[string][]TestResult, order []string) {
status = fmt.Sprintf("Partial (%d/%d)", successCount, totalAttempts)
}

var avgTransport, avgTLS time.Duration
var avgTransport, avgTLS, avgTTFB time.Duration
if successCount > 0 {
avgTransport = totalTransport / time.Duration(successCount)
avgTLS = totalTLS / time.Duration(successCount)
avgTTFB = totalTTFB / time.Duration(successCount)
}

formatDur := func(d time.Duration) string {
Expand All @@ -163,6 +169,7 @@ func printTable(results map[string][]TestResult, order []string) {
status,
formatDur(avgTransport),
formatDur(avgTLS),
formatDur(avgTTFB),
)
}
}
Expand Down
Loading