Skip to content

Commit

Permalink
Merge pull request #29 from ooni/updatego
Browse files Browse the repository at this point in the history
chore: update submodules
  • Loading branch information
bassosimone authored Aug 18, 2022
2 parents 7e0e0fd + a56c194 commit f39504c
Show file tree
Hide file tree
Showing 18 changed files with 152 additions and 68 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ and otherwise replace `tls.Client` with `TLSClientFactory`;
- [ ] ensure [stdlibwrapper.go](stdlibwrapper.go) copies all
the `Request` and `Response` fields;

- [ ] run `go get -u -v ./... && go mod tidy`;

- [ ] commit the changes and push `merged-main` to gitub;

- [ ] open a PR and merge it *using a merge commit*;
Expand Down
1 change: 1 addition & 0 deletions example/example-proxy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/example-proxy
12 changes: 7 additions & 5 deletions example/example-proxy/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ go 1.18

require (
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5
github.com/ooni/oohttp v0.0.0-20220521113303-fb27ebcf5f1e
github.com/refraction-networking/utls v1.1.0
github.com/ooni/oohttp v0.2.1-0.20220818115853-7e0e0fdc8484
github.com/refraction-networking/utls v1.1.1
)

require (
golang.org/x/crypto v0.0.0-20220518034528-6f7dac969898 // indirect
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/klauspost/compress v1.15.9 // indirect
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8 // indirect
golang.org/x/net v0.0.0-20220812174116-3211cb980234 // indirect
golang.org/x/sys v0.0.0-20220817070843-5a390386f1f2 // indirect
golang.org/x/text v0.3.7 // indirect
)
35 changes: 25 additions & 10 deletions example/example-proxy/go.sum
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=
github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/ooni/oohttp v0.0.0-20220521113303-fb27ebcf5f1e h1:hM6+SmEh6aCzXZDIHTwA0UeyjXNy7EfK1NpE3zr3WBo=
github.com/ooni/oohttp v0.0.0-20220521113303-fb27ebcf5f1e/go.mod h1:p2VVLbs+BXBIgTHITV9Vw8Rv6G1u66JUWP/8KCgDGNo=
github.com/refraction-networking/utls v1.1.0 h1:dKXJwSqni/t5csYJ+aQcEgqB7AMWYi6EUc9u3bEmjX0=
github.com/refraction-networking/utls v1.1.0/go.mod h1:tz9gX959MEFfFN5whTIocCLUG57WiILqtdVxI8c6Wj0=
golang.org/x/crypto v0.0.0-20220518034528-6f7dac969898 h1:SLP7Q4Di66FONjDJbCYrCRrh97focO6sLogHO7/g8F0=
golang.org/x/crypto v0.0.0-20220518034528-6f7dac969898/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 h1:NWy5+hlRbC7HK+PmcXVUmW1IMyFce7to56IUvhUFm7Y=
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.15.9 h1:wKRjX6JRtDdrE9qwa4b/Cip7ACOshUI4smpCQanqjSY=
github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU=
github.com/ooni/oohttp v0.2.1-0.20220818115853-7e0e0fdc8484 h1:nGWGi89yQRBDiG1++ANsbh8gYj76lAcQvnhlgrQ/1DY=
github.com/ooni/oohttp v0.2.1-0.20220818115853-7e0e0fdc8484/go.mod h1:p2VVLbs+BXBIgTHITV9Vw8Rv6G1u66JUWP/8KCgDGNo=
github.com/refraction-networking/utls v1.1.1 h1:4p66eNC+MOrL3tI7oMdA5Z8d1TgQXB8fxfuueE9DA7U=
github.com/refraction-networking/utls v1.1.1/go.mod h1:+D89TUtA8+NKVFj1IXWr0p3tSdX1+SqUB7rL0QnGqyg=
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8 h1:GIAS/yBem/gq2MUqgNIzUHW7cJMmx3TGZOrnyYaNQ6c=
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20211111160137-58aab5ef257a/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220812174116-3211cb980234 h1:RDqmgfe7SvlMWoqC3xwQ2blLO3fcWcxMa3eBLRdRW7E=
golang.org/x/net v0.0.0-20220812174116-3211cb980234/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220817070843-5a390386f1f2 h1:fqTvyMIIj+HRzMmnzr9NtpHP6uVpvB5fkHcgPDC4nu8=
golang.org/x/sys v0.0.0-20220817070843-5a390386f1f2/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
7 changes: 3 additions & 4 deletions example/example-proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,9 @@ func useProxy(URL, proxy string,

func main() {
proxy := flag.String("proxy", "127.0.0.1:54321", "where the proxy should listen")
// The default URL we use should return us the JA3 fingerprint
// we're using to communicate with the server. We expect such a
// fingerprint to change when we use the `-utls` flag.
url := flag.String("url", "https://ja3er.com/json", "the URL to get")
// Unfortunately ja3er.com is down. So we're now using as the default
// destination a google website. Not as useful as ja3er.com.
url := flag.String("url", "https://google.com/robots.txt", "the URL to get")
utls := flag.Bool("utls", false, "try using uTLS")
flag.Parse()
var ffun func(conn net.Conn, config *tls.Config) oohttp.TLSConn
Expand Down
14 changes: 13 additions & 1 deletion example/example-proxy/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import (

// utlsConnAdapter adapts utls.UConn to the oohttp.TLSConn interface.
type utlsConnAdapter struct {
// UConn is the underlying utls.UConn
*utls.UConn

// conn is here to implement NetConn
conn net.Conn
}

var _ oohttp.TLSConn = &utlsConnAdapter{}
Expand Down Expand Up @@ -49,6 +53,11 @@ func (c *utlsConnAdapter) HandshakeContext(ctx context.Context) error {
}
}

// NetConn implements TLSConn's NetConn
func (c *utlsConnAdapter) NetConn() net.Conn {
return c.conn
}

// utlsFactory creates a new uTLS connection.
func utlsFactory(conn net.Conn, config *tls.Config) oohttp.TLSConn {
uConfig := &utls.Config{
Expand All @@ -58,5 +67,8 @@ func utlsFactory(conn net.Conn, config *tls.Config) oohttp.TLSConn {
InsecureSkipVerify: config.InsecureSkipVerify,
DynamicRecordSizingDisabled: config.DynamicRecordSizingDisabled,
}
return &utlsConnAdapter{utls.UClient(conn, uConfig, utls.HelloFirefox_55)}
return &utlsConnAdapter{
UConn: utls.UClient(conn, uConfig, utls.HelloFirefox_55),
conn: conn,
}
}
2 changes: 1 addition & 1 deletion example/example-utls-with-dial/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/example-utls
/example-utls-with-dial
12 changes: 7 additions & 5 deletions example/example-utls-with-dial/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ module github.com/ooni/oohttp/example/example-utls-with-dial

go 1.18

require github.com/ooni/oohttp v0.0.0-20220521113303-fb27ebcf5f1e
require github.com/ooni/oohttp v0.2.1-0.20220818115853-7e0e0fdc8484

require (
github.com/refraction-networking/utls v1.1.0
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 // indirect
github.com/refraction-networking/utls v1.1.1
golang.org/x/net v0.0.0-20220812174116-3211cb980234 // indirect
golang.org/x/text v0.3.7 // indirect
)

require (
golang.org/x/crypto v0.0.0-20220518034528-6f7dac969898 // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/klauspost/compress v1.15.9 // indirect
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8 // indirect
golang.org/x/sys v0.0.0-20220817070843-5a390386f1f2 // indirect
)
35 changes: 25 additions & 10 deletions example/example-utls-with-dial/go.sum
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
github.com/ooni/oohttp v0.0.0-20220521113303-fb27ebcf5f1e h1:hM6+SmEh6aCzXZDIHTwA0UeyjXNy7EfK1NpE3zr3WBo=
github.com/ooni/oohttp v0.0.0-20220521113303-fb27ebcf5f1e/go.mod h1:p2VVLbs+BXBIgTHITV9Vw8Rv6G1u66JUWP/8KCgDGNo=
github.com/refraction-networking/utls v1.1.0 h1:dKXJwSqni/t5csYJ+aQcEgqB7AMWYi6EUc9u3bEmjX0=
github.com/refraction-networking/utls v1.1.0/go.mod h1:tz9gX959MEFfFN5whTIocCLUG57WiILqtdVxI8c6Wj0=
golang.org/x/crypto v0.0.0-20220518034528-6f7dac969898 h1:SLP7Q4Di66FONjDJbCYrCRrh97focO6sLogHO7/g8F0=
golang.org/x/crypto v0.0.0-20220518034528-6f7dac969898/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 h1:NWy5+hlRbC7HK+PmcXVUmW1IMyFce7to56IUvhUFm7Y=
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=
github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.15.9 h1:wKRjX6JRtDdrE9qwa4b/Cip7ACOshUI4smpCQanqjSY=
github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU=
github.com/ooni/oohttp v0.2.1-0.20220818115853-7e0e0fdc8484 h1:nGWGi89yQRBDiG1++ANsbh8gYj76lAcQvnhlgrQ/1DY=
github.com/ooni/oohttp v0.2.1-0.20220818115853-7e0e0fdc8484/go.mod h1:p2VVLbs+BXBIgTHITV9Vw8Rv6G1u66JUWP/8KCgDGNo=
github.com/refraction-networking/utls v1.1.1 h1:4p66eNC+MOrL3tI7oMdA5Z8d1TgQXB8fxfuueE9DA7U=
github.com/refraction-networking/utls v1.1.1/go.mod h1:+D89TUtA8+NKVFj1IXWr0p3tSdX1+SqUB7rL0QnGqyg=
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8 h1:GIAS/yBem/gq2MUqgNIzUHW7cJMmx3TGZOrnyYaNQ6c=
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20211111160137-58aab5ef257a/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220812174116-3211cb980234 h1:RDqmgfe7SvlMWoqC3xwQ2blLO3fcWcxMa3eBLRdRW7E=
golang.org/x/net v0.0.0-20220812174116-3211cb980234/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220817070843-5a390386f1f2 h1:fqTvyMIIj+HRzMmnzr9NtpHP6uVpvB5fkHcgPDC4nu8=
golang.org/x/sys v0.0.0-20220817070843-5a390386f1f2/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
5 changes: 4 additions & 1 deletion example/example-utls-with-dial/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ func dialTLSContext(ctx context.Context, network string, addr string) (net.Conn,
// Implementation note: using Firefox 55 ClientHello because that
// avoids a bunch of issues, e.g., Brotli encrypted x509 certs.
uconn := utls.UClient(conn, uconfig, utls.HelloFirefox_55)
uadapter := &utlsConnAdapter{uconn}
uadapter := &utlsConnAdapter{
UConn: uconn,
conn: conn,
}
if err := uadapter.HandshakeContext(ctx); err != nil {
conn.Close()
return nil, err
Expand Down
7 changes: 3 additions & 4 deletions example/example-utls-with-dial/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ func newClient(txp http.RoundTripper) *http.Client {
var defaultClient = newClient(defaultTransport)

func main() {
// The default URL we use should return us the JA3 fingerprint
// we're using to communicate with the server. We expect such a
// fingerprint to change when we use the `-utls` flag.
url := flag.String("url", "https://ja3er.com/json", "the URL to get")
// Unfortunately ja3er.com is down. So we're now using as the default
// destination a google website. Not as useful as ja3er.com.
url := flag.String("url", "https://google.com/robots.txt", "the URL to get")
flag.Parse()
resp, err := defaultClient.Get(*url)
if err != nil {
Expand Down
10 changes: 10 additions & 0 deletions example/example-utls-with-dial/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ package main
import (
"context"
"crypto/tls"
"net"

oohttp "github.com/ooni/oohttp"
utls "github.com/refraction-networking/utls"
)

// utlsConnAdapter adapts utls.UConn to the oohttp.TLSConn interface.
type utlsConnAdapter struct {
// UConn is the underlying utls.UConn
*utls.UConn

// conn is here to implement NetConn
conn net.Conn
}

var _ oohttp.TLSConn = &utlsConnAdapter{}
Expand Down Expand Up @@ -47,3 +52,8 @@ func (c *utlsConnAdapter) HandshakeContext(ctx context.Context) error {
return ctx.Err()
}
}

// NetConn implements TLSConn's NetConn
func (c *utlsConnAdapter) NetConn() net.Conn {
return c.conn
}
12 changes: 7 additions & 5 deletions example/example-utls/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ module github.com/ooni/oohttp/example/example-utls

go 1.18

require github.com/ooni/oohttp v0.0.0-20220521113303-fb27ebcf5f1e
require github.com/ooni/oohttp v0.2.1-0.20220818115853-7e0e0fdc8484

require (
github.com/refraction-networking/utls v1.1.0
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 // indirect
github.com/refraction-networking/utls v1.1.1
golang.org/x/net v0.0.0-20220812174116-3211cb980234 // indirect
golang.org/x/text v0.3.7 // indirect
)

require (
golang.org/x/crypto v0.0.0-20220518034528-6f7dac969898 // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/klauspost/compress v1.15.9 // indirect
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8 // indirect
golang.org/x/sys v0.0.0-20220817070843-5a390386f1f2 // indirect
)
35 changes: 25 additions & 10 deletions example/example-utls/go.sum
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
github.com/ooni/oohttp v0.0.0-20220521113303-fb27ebcf5f1e h1:hM6+SmEh6aCzXZDIHTwA0UeyjXNy7EfK1NpE3zr3WBo=
github.com/ooni/oohttp v0.0.0-20220521113303-fb27ebcf5f1e/go.mod h1:p2VVLbs+BXBIgTHITV9Vw8Rv6G1u66JUWP/8KCgDGNo=
github.com/refraction-networking/utls v1.1.0 h1:dKXJwSqni/t5csYJ+aQcEgqB7AMWYi6EUc9u3bEmjX0=
github.com/refraction-networking/utls v1.1.0/go.mod h1:tz9gX959MEFfFN5whTIocCLUG57WiILqtdVxI8c6Wj0=
golang.org/x/crypto v0.0.0-20220518034528-6f7dac969898 h1:SLP7Q4Di66FONjDJbCYrCRrh97focO6sLogHO7/g8F0=
golang.org/x/crypto v0.0.0-20220518034528-6f7dac969898/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 h1:NWy5+hlRbC7HK+PmcXVUmW1IMyFce7to56IUvhUFm7Y=
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=
github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.15.9 h1:wKRjX6JRtDdrE9qwa4b/Cip7ACOshUI4smpCQanqjSY=
github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU=
github.com/ooni/oohttp v0.2.1-0.20220818115853-7e0e0fdc8484 h1:nGWGi89yQRBDiG1++ANsbh8gYj76lAcQvnhlgrQ/1DY=
github.com/ooni/oohttp v0.2.1-0.20220818115853-7e0e0fdc8484/go.mod h1:p2VVLbs+BXBIgTHITV9Vw8Rv6G1u66JUWP/8KCgDGNo=
github.com/refraction-networking/utls v1.1.1 h1:4p66eNC+MOrL3tI7oMdA5Z8d1TgQXB8fxfuueE9DA7U=
github.com/refraction-networking/utls v1.1.1/go.mod h1:+D89TUtA8+NKVFj1IXWr0p3tSdX1+SqUB7rL0QnGqyg=
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8 h1:GIAS/yBem/gq2MUqgNIzUHW7cJMmx3TGZOrnyYaNQ6c=
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20211111160137-58aab5ef257a/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220812174116-3211cb980234 h1:RDqmgfe7SvlMWoqC3xwQ2blLO3fcWcxMa3eBLRdRW7E=
golang.org/x/net v0.0.0-20220812174116-3211cb980234/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220817070843-5a390386f1f2 h1:fqTvyMIIj+HRzMmnzr9NtpHP6uVpvB5fkHcgPDC4nu8=
golang.org/x/sys v0.0.0-20220817070843-5a390386f1f2/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
7 changes: 3 additions & 4 deletions example/example-utls/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ func newClient(txp http.RoundTripper) *http.Client {
}

func main() {
// The default URL we use should return us the JA3 fingerprint
// we're using to communicate with the server. We expect such a
// fingerprint to change when we use the `-utls` flag.
url := flag.String("url", "https://ja3er.com/json", "the URL to get")
// Unfortunately ja3er.com is down. So we're now using as the default
// destination a google website. Not as useful as ja3er.com.
url := flag.String("url", "https://google.com/robots.txt", "the URL to get")
utls := flag.Bool("utls", false, "try using uTLS")
flag.Parse()
var ffun func(conn net.Conn, config *tls.Config) oohttp.TLSConn
Expand Down
14 changes: 13 additions & 1 deletion example/example-utls/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import (

// utlsConnAdapter adapts utls.UConn to the oohttp.TLSConn interface.
type utlsConnAdapter struct {
// UConn is the underlying utls.UConn
*utls.UConn

// conn is here to implement NetConn
conn net.Conn
}

var _ oohttp.TLSConn = &utlsConnAdapter{}
Expand Down Expand Up @@ -49,6 +53,11 @@ func (c *utlsConnAdapter) HandshakeContext(ctx context.Context) error {
}
}

// NetConn implements TLSConn's NetConn
func (c *utlsConnAdapter) NetConn() net.Conn {
return c.conn
}

// utlsFactory creates a new uTLS connection.
func utlsFactory(conn net.Conn, config *tls.Config) oohttp.TLSConn {
uConfig := &utls.Config{
Expand All @@ -58,5 +67,8 @@ func utlsFactory(conn net.Conn, config *tls.Config) oohttp.TLSConn {
InsecureSkipVerify: config.InsecureSkipVerify,
DynamicRecordSizingDisabled: config.DynamicRecordSizingDisabled,
}
return &utlsConnAdapter{utls.UClient(conn, uConfig, utls.HelloFirefox_55)}
return &utlsConnAdapter{
UConn: utls.UClient(conn, uConfig, utls.HelloFirefox_55),
conn: conn,
}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ module github.com/ooni/oohttp

go 1.18

require golang.org/x/net v0.0.0-20220412020605-290c469a71a5
require golang.org/x/net v0.0.0-20220812174116-3211cb980234

require golang.org/x/text v0.3.7 // indirect
Loading

0 comments on commit f39504c

Please sign in to comment.