Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #13 from Jigsaw-Code/bemasc-sni
Browse files Browse the repository at this point in the history
Report SNI in retry stats
  • Loading branch information
Benjamin M. Schwartz committed Aug 8, 2019
2 parents 7061047 + ae489bd commit c8a40c8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/Jigsaw-Code/outline-go-tun2socks
go 1.12

require (
github.com/Jigsaw-Code/getsni v0.0.0-20190807203514-efe2dbf35d1f
github.com/eycorsican/go-tun2socks v1.14.2
github.com/karalabe/xgo v0.0.0-20190301120235-2d6d1848fb02 // indirect
github.com/miekg/dns v1.1.12 // indirect
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Jigsaw-Code/getsni v0.0.0-20190807203514-efe2dbf35d1f h1:PT61aMvdZPh/8L5FjmKu8DS4/VnmwSJICVZ/THpmLF0=
github.com/Jigsaw-Code/getsni v0.0.0-20190807203514-efe2dbf35d1f/go.mod h1:C68VBkZJR/wcvgo6pmdlm6snMHWiLE844lXJ028Qh8Y=
github.com/eycorsican/go-tun2socks v1.12.0 h1:sW+Bdy3IenYoIh8zDICdNPEQabaS0Uv9BaRMcqIxum8=
github.com/eycorsican/go-tun2socks v1.12.0/go.mod h1:itJVcg8T4Lc1r+72CNpCV/SUNO8of0z/jFeAt31cQbA=
github.com/eycorsican/go-tun2socks v1.13.0 h1:t+k1+mt5xvS8iWhmrYKEAiIWArQqSFJUU/B5Ivivjws=
Expand All @@ -18,6 +20,7 @@ golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a h1:YX8ljsm6wXlHZO+aRz9Exq
golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c h1:Vj5n4GlwjmQteupaxJ9+0FNOmBrHfq7vN4btdGoDZgI=
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f h1:R423Cnkcp5JABoeemiGEPlt9tHXFfw5kvc0yqlxRPWo=
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190321205749-f0864edee7f3/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
Expand Down
15 changes: 11 additions & 4 deletions tunnel/intra/retrier.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import (
"net"
"sync"
"time"

"github.com/Jigsaw-Code/getsni"
)

type RetryStats struct {
Bytes int32 // Number of bytes uploaded before the retry.
Chunks int16 // Number of writes before the retry.
Split int16 // Number of bytes in the first retried segment.
Timeout bool // True if the retry was caused by a timeout.
SNI string // TLS SNI observed, if present.
Bytes int32 // Number of bytes uploaded before the retry.
Chunks int16 // Number of writes before the retry.
Split int16 // Number of bytes in the first retried segment.
Timeout bool // True if the retry was caused by a timeout.
}

// retrier implements the DuplexConn interface.
Expand Down Expand Up @@ -204,8 +207,12 @@ func (r *retrier) Write(b []byte) (int, error) {
n, err = r.conn.Write(b)
attempted = true
r.hello = append(r.hello, b[:n]...)

r.stats.Chunks++
r.stats.Bytes = int32(len(r.hello))
if r.stats.SNI == "" {
r.stats.SNI, _ = getsni.GetSNI(r.hello)
}

// We require a response or another write within the specified timeout.
r.conn.SetReadDeadline(time.Now().Add(r.timeout))
Expand Down

0 comments on commit c8a40c8

Please sign in to comment.