Skip to content
Permalink
Browse files

Merge pull request #13 from Jigsaw-Code/bemasc-sni

Report SNI in retry stats
  • Loading branch information...
bemasc committed Aug 8, 2019
2 parents 7061047 + ae489bd commit c8a40c8c9e5c4c574fbff5f545bab33d079dced0
Showing with 15 additions and 4 deletions.
  1. +1 −0 go.mod
  2. +3 −0 go.sum
  3. +11 −4 tunnel/intra/retrier.go
1 go.mod
@@ -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
3 go.sum
@@ -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=
@@ -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=
@@ -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.
@@ -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))

0 comments on commit c8a40c8

Please sign in to comment.
You can’t perform that action at this time.