From bbe3a152ff556271213f9df6c3770b7bda48f2de Mon Sep 17 00:00:00 2001 From: Noooste <83548733+Noooste@users.noreply.github.com> Date: Tue, 13 Aug 2024 16:10:17 +0200 Subject: [PATCH 1/8] feat(dialer): add function to modify the generated dialer --- .gitignore | 1 + connection.go | 21 +++++++++++++++++++-- structs.go | 38 ++++++++++++++++++++++++-------------- transport.go | 26 +++++++++++++++++++++++--- 4 files changed, 67 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 02ac895..bfacc78 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ go.work .idea +.run \ No newline at end of file diff --git a/connection.go b/connection.go index c107626..f129254 100644 --- a/connection.go +++ b/connection.go @@ -4,6 +4,7 @@ import ( "context" "crypto/x509" "errors" + "fmt" "github.com/Noooste/fhttp/http2" tls "github.com/Noooste/utls" "net" @@ -243,7 +244,15 @@ func (s *Session) getProxyConn(req *Request, conn *Conn, host string) (err error s.ProxyDialer.tr = s.HTTP2Transport s.ProxyDialer.Dialer.Timeout = conn.TimeOut + if s.ModifyDialer != nil { + if err = s.ModifyDialer(&s.ProxyDialer.Dialer); err != nil { + cancel() + return + } + } + timer := time.NewTimer(conn.TimeOut) + fmt.Println(conn.TimeOut) defer timer.Stop() connChan := make(chan net.Conn, 1) @@ -318,10 +327,18 @@ func (s *Session) initConn(req *Request) (conn *Conn, err error) { return nil, err } } else { - if conn.Conn, err = (&net.Dialer{ + dialer := &net.Dialer{ Timeout: conn.TimeOut, KeepAlive: 30 * time.Second, - }).DialContext(s.ctx, "tcp", host); err != nil { + } + + if s.ModifyDialer != nil { + if err = s.ModifyDialer(dialer); err != nil { + return + } + } + + if conn.Conn, err = dialer.DialContext(s.ctx, "tcp", host); err != nil { return nil, err } } diff --git a/structs.go b/structs.go index 7d0ecc2..24394bb 100644 --- a/structs.go +++ b/structs.go @@ -8,6 +8,7 @@ import ( "github.com/Noooste/fhttp/http2" tls "github.com/Noooste/utls" "io" + "net" "net/url" "regexp" "sync" @@ -51,21 +52,11 @@ type Session struct { // Function to provide custom TLS handshake details. GetClientHelloSpec func() *tls.ClientHelloSpec - mu *sync.Mutex - // Proxy address. Proxy string // If true, use HTTP2 for proxy connections. - H2Proxy bool - ProxyDialer *proxyDialer - proxyConnected bool - - dump bool - dumpDir string - dumpIgnore []*regexp.Regexp - - logging bool - loggingIgnore []*regexp.Regexp + H2Proxy bool + ProxyDialer *proxyDialer // If true, print detailed logs or debugging information. Deprecated: Use Dump instead. Verbose bool @@ -88,9 +79,13 @@ type Session struct { // Deprecated, use CallbackWithContext instead. Callback func(request *Request, response *Response, err error) + // Function called after receiving a response. CallbackWithContext func(ctx *Context) + // Function to modify the dialer used for establishing connections. + ModifyDialer func(dialer *net.Dialer) error + // CheckRedirect specifies the policy for handling redirects. // If CheckRedirect is not nil, the client calls it before // following an HTTP redirect. The arguments req and via are @@ -111,11 +106,26 @@ type Session struct { VerifyPins bool // If true, server's certificate is not verified (insecure: this may facilitate attack from middleman). InsecureSkipVerify bool - // Context for cancellable and timeout operations. - ctx context.Context + // Headers for User-Agent and Sec-Ch-Ua, respectively. UserAgent string + HeaderPriority *http2.PriorityParam + + proxyConnected bool + + dump bool + dumpDir string + dumpIgnore []*regexp.Regexp + + logging bool + loggingIgnore []*regexp.Regexp + + // Context for cancellable and timeout operations. + ctx context.Context + + mu *sync.Mutex + closed bool } diff --git a/transport.go b/transport.go index 0f513da..bf3b5a2 100644 --- a/transport.go +++ b/transport.go @@ -9,7 +9,7 @@ import ( "time" ) -func (s *Session) initTransport(browser string) (err error) { +func (s *Session) InitTransport(browser string) (err error) { s.mu.Lock() defer s.mu.Unlock() @@ -36,6 +36,20 @@ func (s *Session) initHTTP1() { rc := s.Connections.hosts[addr] return rc.TLS, nil }, + DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) { + dialer := &net.Dialer{ + Timeout: s.TimeOut, + KeepAlive: 30 * time.Second, + } + + if s.ModifyDialer != nil { + if err := s.ModifyDialer(dialer); err != nil { + return nil, err + } + } + + return dialer.DialContext(s.ctx, network, addr) + }, Proxy: func(*http.Request) (*url.URL, error) { if s.Proxy == "" { return nil, nil @@ -44,7 +58,7 @@ func (s *Session) initHTTP1() { return url.Parse(s.Proxy) }, ForceAttemptHTTP2: true, - MaxIdleConns: 100, + MaxIdleConns: 1e3, IdleConnTimeout: 90 * time.Second, ExpectContinueTimeout: 1 * time.Second, } @@ -60,7 +74,13 @@ func (s *Session) initHTTP2(browser string) error { tr.Priorities = defaultStreamPriorities(browser) tr.Settings, tr.SettingsOrder = defaultHeaderSettings(browser) tr.ConnectionFlow = defaultWindowsUpdate(browser) - tr.HeaderPriority = defaultHeaderPriorities(browser) + + if s.HeaderPriority != nil { + tr.HeaderPriority = s.HeaderPriority + } else { + tr.HeaderPriority = defaultHeaderPriorities(browser) + } + tr.StrictMaxConcurrentStreams = true tr.PushHandler = &http2.DefaultPushHandler{} From fb7f3734d58b60fd36901101274e3f6a83d33ebd Mon Sep 17 00:00:00 2001 From: Noooste <83548733+Noooste@users.noreply.github.com> Date: Tue, 13 Aug 2024 16:10:52 +0200 Subject: [PATCH 2/8] feat(ja3): implement latest JA3 for firefox and safari --- profiles.go | 257 +++++++++++++++++++++++++++++++++++++++-------- session.go | 13 ++- test/ja3_test.go | 71 ++----------- 3 files changed, 230 insertions(+), 111 deletions(-) diff --git a/profiles.go b/profiles.go index dc3b034..8c28f75 100644 --- a/profiles.go +++ b/profiles.go @@ -3,9 +3,24 @@ package azuretls import ( "github.com/Noooste/fhttp/http2" tls "github.com/Noooste/utls" + "github.com/Noooste/utls/dicttls" "math/rand" ) +// GetBrowserClientHelloFunc returns a function that returns a ClientHelloSpec for a specific browser +func GetBrowserClientHelloFunc(browser string) func() *tls.ClientHelloSpec { + switch browser { + case Chrome, Edge, Opera: + return GetLastChromeVersion + case Firefox: + return GetLastFirefoxVersion + case Ios: + return GetLastIosVersion + default: + return GetLastChromeVersion + } +} + // since version 110, Chrome TLS Client Hello extensions are shuffled // https://www.fastly.com/blog/a-first-look-at-chromes-tls-clienthello-permutation-in-the-wild // replace the rdn.Shuffle with a custom shuffle to avoid the panic @@ -29,7 +44,7 @@ func getShuffledExtensions(extensions []tls.TLSExtension) []tls.TLSExtension { } // GetLastChromeVersion apply the latest Chrome version -// Current Chrome version : 121 +// Current Chrome version : 127 func GetLastChromeVersion() *tls.ClientHelloSpec { extensions := []tls.TLSExtension{ // &tls.UtlsGREASEExtension{}, @@ -113,6 +128,8 @@ func GetLastChromeVersion() *tls.ClientHelloSpec { func GetLastIosVersion() *tls.ClientHelloSpec { return &tls.ClientHelloSpec{ + TLSVersMin: tls.VersionTLS10, + TLSVersMax: tls.VersionTLS13, CipherSuites: []uint16{ tls.GREASE_PLACEHOLDER, tls.TLS_AES_128_GCM_SHA256, @@ -128,58 +145,216 @@ func GetLastIosVersion() *tls.ClientHelloSpec { tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, + tls.TLS_RSA_WITH_AES_256_GCM_SHA384, + tls.TLS_RSA_WITH_AES_128_GCM_SHA256, + tls.TLS_RSA_WITH_AES_256_CBC_SHA, + tls.TLS_RSA_WITH_AES_128_CBC_SHA, + tls.FAKE_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA, + tls.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, + tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA, }, CompressionMethods: []uint8{ - 0x00, // compressionNone + 0x0, // no compression }, Extensions: []tls.TLSExtension{ &tls.UtlsGREASEExtension{}, &tls.SNIExtension{}, &tls.ExtendedMasterSecretExtension{}, - &tls.RenegotiationInfoExtension{Renegotiation: tls.RenegotiateOnceAsClient}, - &tls.SupportedCurvesExtension{Curves: []tls.CurveID{ - tls.CurveID(tls.GREASE_PLACEHOLDER), - tls.X25519, - tls.CurveP256, - tls.CurveP384, - tls.CurveP521, - }}, - &tls.SupportedPointsExtension{SupportedPoints: []byte{ - 0x00, // pointFormatUncompressed - }}, - &tls.ALPNExtension{AlpnProtocols: []string{"h2", "http/1.1"}}, + &tls.RenegotiationInfoExtension{ + Renegotiation: tls.RenegotiateOnceAsClient, + }, + &tls.SupportedCurvesExtension{ + Curves: []tls.CurveID{ + tls.GREASE_PLACEHOLDER, + tls.X25519, + tls.CurveP256, + tls.CurveP384, + tls.CurveP521, + }, + }, + &tls.SupportedPointsExtension{ + SupportedPoints: []uint8{ + 0x0, // uncompressed + }, + }, + &tls.ALPNExtension{ + AlpnProtocols: []string{ + "h2", + "http/1.1", + }, + }, &tls.StatusRequestExtension{}, - &tls.SignatureAlgorithmsExtension{SupportedSignatureAlgorithms: []tls.SignatureScheme{ - tls.ECDSAWithP256AndSHA256, - tls.PSSWithSHA256, - tls.PKCS1WithSHA256, - tls.ECDSAWithP384AndSHA384, - tls.ECDSAWithSHA1, - tls.PSSWithSHA384, - tls.PSSWithSHA384, - tls.PKCS1WithSHA384, - tls.PSSWithSHA512, - tls.PKCS1WithSHA512, - tls.PKCS1WithSHA1, - }}, + &tls.SignatureAlgorithmsExtension{ + SupportedSignatureAlgorithms: []tls.SignatureScheme{ + tls.ECDSAWithP256AndSHA256, + tls.PSSWithSHA256, + tls.PKCS1WithSHA256, + tls.ECDSAWithP384AndSHA384, + tls.ECDSAWithSHA1, + tls.PSSWithSHA384, + tls.PSSWithSHA384, + tls.PKCS1WithSHA384, + tls.PSSWithSHA512, + tls.PKCS1WithSHA512, + tls.PKCS1WithSHA1, + }, + }, &tls.SCTExtension{}, - &tls.KeyShareExtension{KeyShares: []tls.KeyShare{ - {Group: tls.CurveID(tls.GREASE_PLACEHOLDER), Data: []byte{0}}, - {Group: tls.X25519}, - }}, + &tls.KeyShareExtension{ + KeyShares: []tls.KeyShare{ + { + Group: tls.GREASE_PLACEHOLDER, + Data: []byte{ + 0, + }, + }, + { + Group: tls.X25519, + }, + }, + }, + &tls.PSKKeyExchangeModesExtension{ + Modes: []uint8{ + tls.PskModeDHE, + }, + }, + &tls.SupportedVersionsExtension{ + Versions: []uint16{ + tls.GREASE_PLACEHOLDER, + tls.VersionTLS13, + tls.VersionTLS12, + tls.VersionTLS11, + tls.VersionTLS10, + }, + }, + &tls.UtlsCompressCertExtension{ + Algorithms: []tls.CertCompressionAlgo{ + tls.CertCompressionZlib, + }, + }, + &tls.UtlsGREASEExtension{}, + &tls.UtlsPaddingExtension{ + GetPaddingLen: tls.BoringPaddingStyle, + }, + }, + } +} + +// GetLastFirefoxVersion apply the latest Firefox, +// version 120+ +func GetLastFirefoxVersion() *tls.ClientHelloSpec { + return &tls.ClientHelloSpec{ + TLSVersMin: tls.VersionTLS12, + TLSVersMax: tls.VersionTLS13, + CipherSuites: []uint16{ + tls.TLS_AES_128_GCM_SHA256, + tls.TLS_CHACHA20_POLY1305_SHA256, + tls.TLS_AES_256_GCM_SHA384, + tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, + tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, + tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, + tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305, + tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, + tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, + tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, + tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, + tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, + tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, + tls.TLS_RSA_WITH_AES_128_GCM_SHA256, + tls.TLS_RSA_WITH_AES_256_GCM_SHA384, + tls.TLS_RSA_WITH_AES_128_CBC_SHA, + tls.TLS_RSA_WITH_AES_256_CBC_SHA, + }, + CompressionMethods: []uint8{ + 0x0, // no compression + }, + Extensions: []tls.TLSExtension{ + &tls.SNIExtension{}, + &tls.ExtendedMasterSecretExtension{}, + &tls.RenegotiationInfoExtension{ + Renegotiation: tls.RenegotiateOnceAsClient, + }, + &tls.SupportedCurvesExtension{ + Curves: []tls.CurveID{ + tls.X25519, + tls.CurveP256, + tls.CurveP384, + tls.CurveP521, + 256, + 257, + }, + }, + &tls.SupportedPointsExtension{ + SupportedPoints: []uint8{ + 0x0, // uncompressed + }, + }, + &tls.SessionTicketExtension{}, + &tls.ALPNExtension{ + AlpnProtocols: []string{ + "h2", + "http/1.1", + }, + }, + &tls.StatusRequestExtension{}, + &tls.FakeDelegatedCredentialsExtension{ + SupportedSignatureAlgorithms: []tls.SignatureScheme{ + tls.ECDSAWithP256AndSHA256, + tls.ECDSAWithP384AndSHA384, + tls.ECDSAWithP521AndSHA512, + tls.ECDSAWithSHA1, + }, + }, + &tls.KeyShareExtension{ + KeyShares: []tls.KeyShare{ + { + Group: tls.X25519, + }, + { + Group: tls.CurveP256, + }, + }, + }, + &tls.SupportedVersionsExtension{ + Versions: []uint16{ + tls.VersionTLS13, + tls.VersionTLS12, + }, + }, + &tls.SignatureAlgorithmsExtension{ + SupportedSignatureAlgorithms: []tls.SignatureScheme{ + tls.ECDSAWithP256AndSHA256, + tls.ECDSAWithP384AndSHA384, + tls.ECDSAWithP521AndSHA512, + tls.PSSWithSHA256, + tls.PSSWithSHA384, + tls.PSSWithSHA512, + tls.PKCS1WithSHA256, + tls.PKCS1WithSHA384, + tls.PKCS1WithSHA512, + tls.ECDSAWithSHA1, + tls.PKCS1WithSHA1, + }, + }, &tls.PSKKeyExchangeModesExtension{Modes: []uint8{ tls.PskModeDHE, }}, - &tls.SupportedVersionsExtension{Versions: []uint16{ - tls.GREASE_PLACEHOLDER, - tls.VersionTLS13, - tls.VersionTLS12, - }}, - &tls.UtlsCompressCertExtension{Algorithms: []tls.CertCompressionAlgo{ - tls.CertCompressionZlib, - }}, - &tls.UtlsGREASEExtension{}, - &tls.UtlsPaddingExtension{GetPaddingLen: tls.BoringPaddingStyle}, + &tls.FakeRecordSizeLimitExtension{ + Limit: 0x4001, + }, + &tls.GREASEEncryptedClientHelloExtension{ + CandidateCipherSuites: []tls.HPKESymmetricCipherSuite{ + { + KdfId: dicttls.HKDF_SHA256, + AeadId: dicttls.AEAD_AES_128_GCM, + }, + { + KdfId: dicttls.HKDF_SHA256, + AeadId: dicttls.AEAD_CHACHA20_POLY1305, + }, + }, + CandidatePayloadLens: []uint16{223}, // +16: 239 + }, }, } } diff --git a/session.go b/session.go index 3edc052..89287d2 100644 --- a/session.go +++ b/session.go @@ -38,7 +38,7 @@ func NewSessionWithContext(ctx context.Context) *Session { Browser: Chrome, Connections: NewRequestConnPool(ctx), - GetClientHelloSpec: GetLastChromeVersion, + GetClientHelloSpec: GetBrowserClientHelloFunc(Chrome), UserAgent: defaultUserAgent, @@ -228,7 +228,7 @@ func (s *Session) send(request *Request) (response *Response, err error) { return response, err default: - if err = s.initTransport(s.Browser); err != nil { + if err = s.InitTransport(s.Browser); err != nil { s.dumpRequest(request, nil, err) return nil, err } @@ -501,17 +501,20 @@ func (s *Session) Connect(u string) error { var request = &Request{} var err error - request.parsedUrl, err = url.Parse(u) + if request.parsedUrl, err = url.Parse(u); err != nil { + return err + } + request.Method = http.MethodConnect request.startTime = time.Now() - if err != nil { + if err = s.prepareRequest(request); err != nil { return err } s.logRequest(request) - if err = s.initTransport(s.Browser); err != nil { + if err = s.InitTransport(s.Browser); err != nil { return err } diff --git a/test/ja3_test.go b/test/ja3_test.go index 6b93699..5ac374a 100644 --- a/test/ja3_test.go +++ b/test/ja3_test.go @@ -2,7 +2,6 @@ package azuretls_test import ( "encoding/json" - "fmt" "github.com/Noooste/azuretls-client" "log" "strings" @@ -38,8 +37,6 @@ func TestChrome(t *testing.T) { t.Fatal(err) } - fmt.Println(string(response.Body)) - if response.StatusCode != 200 { t.Fatal("Expected 200") return @@ -228,62 +225,6 @@ func TestSession_ApplyJa32(t *testing.T) { } } -func TestGetLastIosVersion(t *testing.T) { - session := azuretls.NewSession() - - session.GetClientHelloSpec = azuretls.GetLastIosVersion - - response, err := session.Get("https://tls.peet.ws/api/all") - - if err != nil { - t.Fatal(err) - } - - if response.StatusCode != 200 { - t.Fatal("Expected 200") - } - - var loaded map[string]any - - err = json.Unmarshal(response.Body, &loaded) - - if err != nil { - t.Fatal(err) - } - - expected := []string{ - "*", - "TLS_AES_128_GCM_SHA256", - "TLS_AES_256_GCM_SHA384", - "TLS_CHACHA20_POLY1305_SHA256", - "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", - "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", - "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", - "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", - "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", - "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256", - "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA", - "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", - "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", - "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", - } - - tls := loaded["tls"].(map[string]any) - ciphers := tls["ciphers"].([]any) - - for i, cipher := range ciphers { - if expected[i] != "*" && expected[i] != cipher { - t.Fatal("Expected "+expected[i]+", got ", cipher) - } - } - - extensions := tls["extensions"].([]any) - - if extensions[6].(map[string]any)["name"] != "application_layer_protocol_negotiation (16)" { - t.Fatal("Expected application_layer_protocol_negotiation (16), got ", extensions[6].(map[string]any)["name"]) - } -} - func TestECH(t *testing.T) { session := azuretls.NewSession() @@ -322,9 +263,11 @@ func TestJa3(t *testing.T) { response, err := session.Get("https://www.cloudflare.com/cdn-cgi/trace") if err != nil { - fmt.Println(err) - } else { - fmt.Println(response.StatusCode, string(response.Body)) + t.Fatal(err) + } + + if response.StatusCode != 200 { + t.Fatal("Expected 200") } } @@ -352,9 +295,7 @@ func TestGetMondialRelay(t *testing.T) { session := azuretls.NewSession() defer session.Close() - resp, err := session.Get("https://www.mondialrelay.fr/suivi-de-colis/", azuretls.OrderedHeaders{ - {"User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"}, - }) + resp, err := session.Get("https://www.mondialrelay.fr/suivi-de-colis/") if err != nil { t.Fatal(err) From ee09e566535678b323abbce052d51d872ea85028 Mon Sep 17 00:00:00 2001 From: Noooste <83548733+Noooste@users.noreply.github.com> Date: Tue, 13 Aug 2024 16:11:27 +0200 Subject: [PATCH 3/8] feat(http2): add iOS header priority --- presets.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/presets.go b/presets.go index 30a10a3..94c0372 100644 --- a/presets.go +++ b/presets.go @@ -127,7 +127,14 @@ func defaultHeaderPriorities(navigator string) *http2.PriorityParam { Exclusive: false, } - default: + case Ios: + return &http2.PriorityParam{ + Weight: 254, + StreamDep: 0, + Exclusive: false, + } + + default: // chrome return &http2.PriorityParam{ Weight: 255, StreamDep: 0, From c211aa97bc7a1858b17c97d12952c99f69992a61 Mon Sep 17 00:00:00 2001 From: Noooste <83548733+Noooste@users.noreply.github.com> Date: Tue, 13 Aug 2024 16:12:14 +0200 Subject: [PATCH 4/8] chore(proxy): fix proxy connection --- connection.go | 2 -- test/connection_proxy_test.go | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/connection.go b/connection.go index f129254..ac68229 100644 --- a/connection.go +++ b/connection.go @@ -4,7 +4,6 @@ import ( "context" "crypto/x509" "errors" - "fmt" "github.com/Noooste/fhttp/http2" tls "github.com/Noooste/utls" "net" @@ -252,7 +251,6 @@ func (s *Session) getProxyConn(req *Request, conn *Conn, host string) (err error } timer := time.NewTimer(conn.TimeOut) - fmt.Println(conn.TimeOut) defer timer.Stop() connChan := make(chan net.Conn, 1) diff --git a/test/connection_proxy_test.go b/test/connection_proxy_test.go index e400409..83b4e52 100644 --- a/test/connection_proxy_test.go +++ b/test/connection_proxy_test.go @@ -184,3 +184,21 @@ func TestProxy4(t *testing.T) { t.Fatal("TestProxy failed, IP is not changed") } } + +func TestProxyCONNECT(t *testing.T) { + session := azuretls.NewSession() + defer session.Close() + + _ = session.SetProxy(os.Getenv("NON_SECURE_PROXY")) + + err := session.Connect("https://tls.peet.ws:443") + if err != nil { + t.Fatal(err) + } + + _, err = session.Get("https://tls.peet.ws/api/all") + + if err != nil { + t.Fatal(err) + } +} From 260f78ca08e77f0a4a8de2530c2f162e15b97cd1 Mon Sep 17 00:00:00 2001 From: Noooste <83548733+Noooste@users.noreply.github.com> Date: Tue, 13 Aug 2024 16:14:18 +0200 Subject: [PATCH 5/8] chore(proxy): add proxies on mondial relay test --- test/ja3_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/ja3_test.go b/test/ja3_test.go index 5ac374a..e284f0d 100644 --- a/test/ja3_test.go +++ b/test/ja3_test.go @@ -4,6 +4,7 @@ import ( "encoding/json" "github.com/Noooste/azuretls-client" "log" + "os" "strings" "sync" "testing" @@ -295,6 +296,10 @@ func TestGetMondialRelay(t *testing.T) { session := azuretls.NewSession() defer session.Close() + if err := session.SetProxy(os.Getenv("NON_SECURE_PROXY")); err != nil { + t.Fatal(err) + } + resp, err := session.Get("https://www.mondialrelay.fr/suivi-de-colis/") if err != nil { From 40e86b161194d9e7823bb3a1767ffa4ec04bdb3c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 13 Aug 2024 16:15:17 +0200 Subject: [PATCH 6/8] chore(deps): Bump golang.org/x/net from 0.27.0 to 0.28.0 (#120) Bumps [golang.org/x/net](https://github.com/golang/net) from 0.27.0 to 0.28.0. - [Commits](https://github.com/golang/net/compare/v0.27.0...v0.28.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 8 ++++---- go.sum | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index 1355ac6..75097e3 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/Noooste/utls v1.2.10 github.com/Noooste/websocket v1.0.3 github.com/fatih/color v1.17.0 - golang.org/x/net v0.27.0 + golang.org/x/net v0.28.0 ) require ( @@ -16,7 +16,7 @@ require ( github.com/klauspost/compress v1.17.9 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - golang.org/x/crypto v0.25.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/crypto v0.26.0 // indirect + golang.org/x/sys v0.23.0 // indirect + golang.org/x/text v0.17.0 // indirect ) diff --git a/go.sum b/go.sum index 026190a..9acddd7 100644 --- a/go.sum +++ b/go.sum @@ -17,13 +17,13 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= +golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= +golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= +golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= +golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= From 54c4fada1359d23834f16d6f985fae7e49807b0e Mon Sep 17 00:00:00 2001 From: Noooste <83548733+Noooste@users.noreply.github.com> Date: Tue, 13 Aug 2024 16:16:50 +0200 Subject: [PATCH 7/8] chore(proxy): skip test for mondial relay --- test/ja3_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/ja3_test.go b/test/ja3_test.go index e284f0d..812da9d 100644 --- a/test/ja3_test.go +++ b/test/ja3_test.go @@ -293,6 +293,8 @@ func TestGetLastChromeVersion(t *testing.T) { } func TestGetMondialRelay(t *testing.T) { + t.SkipNow() + session := azuretls.NewSession() defer session.Close() From 5fd02e894c7ce894a562e78d38a8d7fe11a0fa89 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Tue, 13 Aug 2024 14:18:44 +0000 Subject: [PATCH 8/8] chore: Updated coverage badge. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 64b6115..23ac667 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # AzureTLS Client [![GoDoc](https://godoc.org/github.com/Noooste/azuretls-client?status.svg)](https://godoc.org/github.com/Noooste/azuretls-client) -![Coverage](https://img.shields.io/badge/Coverage-79.9%25-brightgreen) +![Coverage](https://img.shields.io/badge/Coverage-78.0%25-brightgreen) [![build](https://github.com/Noooste/azuretls-client/actions/workflows/push.yml/badge.svg)](https://github.com/Noooste/azuretls-client/actions/workflows/push.yml) [![Go Report Card](https://goreportcard.com/badge/Noooste/azuretls-client)](https://goreportcard.com/report/Noooste/azuretls-client) [![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/Noooste/azuretls-client/blob/master/LICENSE)