Skip to content

Commit

Permalink
Release: ✨ Support extension 65037 as well as socks5h and socks4 prox…
Browse files Browse the repository at this point in the history
…ies [1.0.25] (#308)
  • Loading branch information
Danny-Dasilva authored Jan 8, 2024
1 parent a120dac commit 9df73ca
Show file tree
Hide file tree
Showing 20 changed files with 6,248 additions and 168 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/manual_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [15.x]
node-version: [16.x]
go-version: ['1.20']
steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

strategy:
matrix:
node-version: [15.x]
node-version: [16.x]
go-version: ['1.20']
steps:
- uses: actions/checkout@v4
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/test_golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ jobs:
run: |
docker run -d -p 1087:1080 serjs/go-socks5-proxy
- name: Start SOCKS4 Proxy (only on ubuntu)
if: matrix.platform == 'ubuntu-latest'
run: |
docker run -d -p 9050:9050 clue/psocksd
- name: Integration Tests
working-directory: ./cycletls
run: go test --race -v -tags=integration ./...
2 changes: 1 addition & 1 deletion .github/workflows/test_npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

strategy:
matrix:
node-version: [14.x]
node-version: [16.x]
go-version: ['1.20']
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_npm_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

strategy:
matrix:
node-version: [15.x]
node-version: [16.x]
go-version: ['1.20']
steps:
- uses: actions/checkout@v4
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<img src="docs/media/Banner.png" alt="CycleTLS"/>
<br>

Currently a WIP and in Active development. See the ![Projects](https://github.com/Danny-Dasilva/CycleTLS/projects/1) Tab for more info
Accepting Community Support and PR's



Expand All @@ -29,7 +29,7 @@ If you have a API change or feature request feel free to open an [Issue](https:/

- [High-performance](#-performance) Built-in goroutine pool used for handling asynchronous requests
- Custom header ordering via [fhttp](https://github.com/useflyent/fhttp)
- Proxy support
- Proxy support | Socks4, Socks5, Socks5h
- Ja3 Token configuration


Expand All @@ -54,7 +54,7 @@ Table of contents
## Dependencies

```
node ^v14.0
node ^v16.0
golang ^v1.20x
```

Expand Down
36 changes: 30 additions & 6 deletions cycletls/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,30 @@ import (
"encoding/base64"
"errors"
"fmt"
http "github.com/Danny-Dasilva/fhttp"
http2 "github.com/Danny-Dasilva/fhttp/http2"
"golang.org/x/net/proxy"
"io"
"net"
"net/url"
"strconv"
"sync"

http "github.com/Danny-Dasilva/fhttp"
http2 "github.com/Danny-Dasilva/fhttp/http2"
"golang.org/x/net/proxy"
"h12.io/socks"
)

type SocksDialer struct {
socksDial func(string, string) (net.Conn, error)
}

func (d *SocksDialer) DialContext(_ context.Context, network, addr string) (net.Conn, error) {
return d.socksDial(network, addr)
}

func (d *SocksDialer) Dial(network, addr string) (net.Conn, error) {
return d.socksDial(network, addr)
}

// connectDialer allows to configure one-time use HTTP CONNECT client
type connectDialer struct {
ProxyURL url.URL
Expand Down Expand Up @@ -64,7 +78,7 @@ func newConnectDialer(proxyURLStr string, UserAgent string) (proxy.ContextDialer
if proxyURL.Port() == "" {
proxyURL.Host = net.JoinHostPort(proxyURL.Host, "443")
}
case "socks5":
case "socks5", "socks5h":
var auth *proxy.Auth
if proxyURL.User != nil {
if proxyURL.User.Username() != "" {
Expand All @@ -73,7 +87,11 @@ func newConnectDialer(proxyURLStr string, UserAgent string) (proxy.ContextDialer
auth = &proxy.Auth{User: username, Password: password}
}
}
dialSocksProxy, err := proxy.SOCKS5("tcp", proxyURL.Host, auth, nil)
var forward proxy.Dialer
if proxyURL.Scheme == "socks5h" {
forward = proxy.Direct
}
dialSocksProxy, err := proxy.SOCKS5("tcp", proxyURL.Host, auth, forward)
if err != nil {
return nil, fmt.Errorf("Error creating SOCKS5 proxy, reason %s", err)
}
Expand All @@ -84,6 +102,12 @@ func newConnectDialer(proxyURLStr string, UserAgent string) (proxy.ContextDialer
}
client.DefaultHeader.Set("User-Agent", UserAgent)
return client, nil
case "socks4":
var dialer *SocksDialer
dialer = &SocksDialer{socks.DialSocksProxy(socks.SOCKS4, proxyURL.Host)}
client.Dialer = dialer
client.DefaultHeader.Set("User-Agent", UserAgent)
return client, nil
case "":
return nil, errors.New("specify scheme explicitly (https://)")
default:
Expand Down Expand Up @@ -121,7 +145,7 @@ type ContextKeyHeader struct{}
// ctx.Value will be inspected for optional ContextKeyHeader{} key, with `http.Header` value,
// which will be added to outgoing request headers, overriding any colliding c.DefaultHeader
func (c *connectDialer) DialContext(ctx context.Context, network, address string) (net.Conn, error) {
if c.ProxyURL.Scheme == "socks5" {
if c.ProxyURL.Scheme == "socks5" || c.ProxyURL.Scheme == "socks4" || c.ProxyURL.Scheme == "socks5h" {
return c.Dialer.DialContext(ctx, network, address)
}

Expand Down
15 changes: 8 additions & 7 deletions cycletls/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ require (
github.com/PuerkitoBio/goquery v1.8.0
github.com/andybalholm/brotli v1.0.6
github.com/gorilla/websocket v1.5.1
github.com/refraction-networking/utls v1.5.4
golang.org/x/net v0.18.0
github.com/refraction-networking/utls v1.6.0
golang.org/x/net v0.19.0
h12.io/socks v1.0.3
)

require (
github.com/andybalholm/cascadia v1.3.1 // indirect
github.com/cloudflare/circl v1.3.6 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/gaukas/godicttls v0.0.4 // indirect
github.com/klauspost/compress v1.17.3 // indirect
github.com/quic-go/quic-go v0.40.0 // indirect
golang.org/x/crypto v0.15.0 // indirect
golang.org/x/sys v0.14.0 // indirect
github.com/klauspost/compress v1.17.4 // indirect
github.com/quic-go/quic-go v0.40.1 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
)
18 changes: 18 additions & 0 deletions cycletls/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk
github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
github.com/cloudflare/circl v1.3.6 h1:/xbKIqSHbZXHwkhbrhrt2YOHIwYJlXH94E3tI/gDlUg=
github.com/cloudflare/circl v1.3.6/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU=
github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA=
github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -87,6 +89,7 @@ github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
github.com/grpc-ecosystem/grpc-gateway v1.5.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw=
github.com/h12w/go-socks5 v0.0.0-20200522160539-76189e178364/go.mod h1:eDJQioIyy4Yn3MVivT7rv/39gAJTrA7lgmYr8EW950c=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU=
Expand All @@ -96,6 +99,8 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o
github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/klauspost/compress v1.17.3 h1:qkRjuerhUU1EmXLYGkSH6EZL+vPSxIrYjLNAK4slzwA=
github.com/klauspost/compress v1.17.3/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4=
github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
Expand Down Expand Up @@ -144,6 +149,7 @@ github.com/onsi/gomega v1.27.4/go.mod h1:riYq/GJKh8hhoM01HN6Vmuy93AarCXCBGpvFDK3
github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE=
github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg=
github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8=
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
Expand All @@ -155,8 +161,12 @@ github.com/quic-go/qtls-go1-20 v0.3.1/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58
github.com/quic-go/quic-go v0.37.4/go.mod h1:YsbH1r4mSHPJcLF4k4zruUkLBqctEMBDR6VPvcYjIsU=
github.com/quic-go/quic-go v0.40.0 h1:GYd1iznlKm7dpHD7pOVpUvItgMPo/jrMgDWZhMCecqw=
github.com/quic-go/quic-go v0.40.0/go.mod h1:PeN7kuVJ4xZbxSv/4OX6S1USOX8MJvydwpTx31vx60c=
github.com/quic-go/quic-go v0.40.1 h1:X3AGzUNFs0jVuO3esAGnTfvdgvL4fq655WaOi1snv1Q=
github.com/quic-go/quic-go v0.40.1/go.mod h1:PeN7kuVJ4xZbxSv/4OX6S1USOX8MJvydwpTx31vx60c=
github.com/refraction-networking/utls v1.5.4 h1:9k6EO2b8TaOGsQ7Pl7p9w6PUhx18/ZCeT0WNTZ7Uw4o=
github.com/refraction-networking/utls v1.5.4/go.mod h1:SPuDbBmgLGp8s+HLNc83FuavwZCFoMmExj+ltUHiHUw=
github.com/refraction-networking/utls v1.6.0 h1:X5vQMqVx7dY7ehxxqkFER/W6DSjy8TMqSItXm8hRDYQ=
github.com/refraction-networking/utls v1.6.0/go.mod h1:kHJ6R9DFFA0WsRgBM35iiDku4O7AqPR6y79iuzW7b10=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/shurcooL/component v0.0.0-20170202220835-f88ec8f54cc4/go.mod h1:XhFIlyj5a1fBNx5aJTbKoIq0mNaPvOagO+HjB3EtxrY=
Expand Down Expand Up @@ -209,6 +219,8 @@ golang.org/x/crypto v0.4.0/go.mod h1:3quD/ATkf6oY+rnes5c3ExXTbLc8mueNue5/DoinL80
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA=
golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g=
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20221205204356-47842c84f3db/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
Expand Down Expand Up @@ -254,6 +266,8 @@ golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg=
golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ=
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
Expand Down Expand Up @@ -303,6 +317,8 @@ golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
Expand Down Expand Up @@ -388,6 +404,8 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
grpc.go4.org v0.0.0-20170609214715-11d0a25b4919/go.mod h1:77eQGdRu53HpSqPFJFmuJdjuHRquDANNeA4x7B8WQ9o=
h12.io/socks v1.0.3 h1:Ka3qaQewws4j4/eDQnOdpr4wXsC//dXtWvftlIcCQUo=
h12.io/socks v1.0.3/go.mod h1:AIhxy1jOId/XCz9BO+EIgNL2rQiPTBNnOfnVnQ+3Eck=
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Expand Down
4 changes: 1 addition & 3 deletions cycletls/tests/integration/cookie_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ func TestCookies(t *testing.T) {
}

eq := reflect.DeepEqual(resp.JSONBody(), data)
if eq {
log.Println("They're equal.")
} else {
if !eq {
t.Fatalf("Expected %s Got %s, expected cookies not found", data, resp.JSONBody())
}
}
16 changes: 6 additions & 10 deletions cycletls/tests/integration/latest_fingerprint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ type PeetResp struct {
}

var PeetRequests = []AkamaiOptions{
{"aa7744226c695c0b2e440419848cf700", // Firefox 101
"771,4865-4867-4866-49195-49199-52393-52392-49196-49200-49162-49161-49171-49172-156-157-47-53-10,0-23-65281-10-11-35-16-5-51-43-13-45-28-21,29-23-24-25-256-257,0",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:101.0) Gecko/20100101 Firefox/101.0",
{"c0a45cc83cb2005bbd2a860db187a357", // Firefox 121
"771,4865-4867-4866-49195-49199-52393-52392-49196-49200-49162-49161-49171-49172-156-157-47-53,0-23-65281-10-11-16-5-34-51-43-13-45-28-65037,29-23-24-25-256-257,0",
"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:121.0) Gecko/20100101 Firefox/121.0",
"1:65536,4:131072,5:16384|12517377|3:0:0:201,5:0:0:101,7:0:0:1,9:0:7:1,11:0:3:1,13:0:0:241|m,p,a,s",
"fd4f649c50a64e33cc9e2407055bafbe",
200},
{"e1d8b04eeb8ef3954ec4f49267a783ef", // Chrome 104
"771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-17513,29-23-24,0",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36",
{"d742731fb59499b2ca4cf990dd929c0a", // Chrome 120
"771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,45-27-23-10-13-35-5-65037-16-51-0-18-43-11-17513-65281,29-23-24,0",
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
"1:65536,3:1000,4:6291456,5:16384,6:262144|15663105|0|m,a,s,p",
"c1375f42959bb1bf1ade5d15eed59ba6",
200},
Expand All @@ -65,10 +65,6 @@ func TestLatestVersions(t *testing.T) {
if err != nil {
t.Fatal("Unmarshal Error")
}

if jsonResp.Ja3Hash != options.Ja3Hash {
t.Fatal("Expected:", options.Ja3Hash, "Got:", jsonResp.Ja3Hash, "for Ja3Hash")
}
if jsonResp.Ja3 != options.Ja3 {
t.Fatal("Expected:", options.Ja3, "Got:", jsonResp.Ja3, "for Ja3")
}
Expand Down
65 changes: 45 additions & 20 deletions cycletls/tests/integration/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,50 @@ func TestProxySuccess(t *testing.T) {
if resp.Status != 200 {
t.Fatalf("Expected %d Got %d for Status", 200, resp.Status)
}
log.Print("Body: " + resp.Body)
}
func TestSocks4Proxy(t *testing.T) {
if runtime.GOOS != "linux" {
t.Skip("Skipping this test on non-linux platforms")
return
}
client := cycletls.Init()
resp, err := client.Do("https://ipinfo.io/json", cycletls.Options{
Body: "",
Ja3: "771,4865-4867-4866-49195-49199-52393-52392-49196-49200-49162-49161-49171-49172-51-57-47-53-10,0-23-65281-10-11-35-16-5-51-43-13-45-28-21,29-23-24-25-256-257,0",
UserAgent: "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0",
Proxy: "socks4://abc:[email protected]:9050",
Headers: map[string]string{
"Accept": "Application/json, text/plain, */*",
},
}, "GET")
if err != nil {
t.Fatalf("Request Failed: " + err.Error())
}
if resp.Status != 200 {
t.Fatalf("Expected %d Got %d for Status", 200, resp.Status)
}
}

// func TestHttpError(t *testing.T) {

// client := cycletls.Init()
// resp, err := client.Do("https://ipinfo.io/json", cycletls.Options{
// Body: "",
// Ja3: "771,4865-4867-4866-49195-49199-52393-52392-49196-49200-49162-49161-49171-49172-51-57-47-53-10,0-23-65281-10-11-35-16-5-51-43-13-45-28-21,29-23-24-25-256-257,0",
// UserAgent: "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0",
// Proxy: "http://127.0.0.1:10809",
// Headers: map[string]string{
// "Accept": "Application/json, text/plain, */*",
// },
// }, "GET")
// if err != nil {
// log.Print("Request Failed: " + err.Error())
// }
// log.Print("Status: " + strconv.Itoa(resp.Status))
// log.Print("Body: " + resp.Body)

// }
func TestSocks5hProxy(t *testing.T) {
if runtime.GOOS != "linux" {
t.Skip("Skipping this test on non-linux platforms")
return
}
client := cycletls.Init()
resp, err := client.Do("https://httpbin.org/ip", cycletls.Options{
Body: "",
Ja3: "771,4865-4867-4866-49195-49199-52393-52392-49196-49200-49162-49161-49171-49172-51-57-47-53-10,0-23-65281-10-11-35-16-5-51-43-13-45-28-21,29-23-24-25-256-257,0",
UserAgent: "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0",
Proxy: "socks5h://127.0.0.1:9050",
Headers: map[string]string{
"Accept": "Application/json, text/plain, */*",
},
}, "GET")
if err != nil {
t.Fatalf("Request Failed: " + err.Error())
}
if resp.Status != 200 {
t.Fatalf("Expected %d Got %d for Status", 200, resp.Status)
}
log.Print("Body: " + resp.Body)
}
7 changes: 3 additions & 4 deletions cycletls/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,8 @@ func genMap() (extMap map[string]utls.TLSExtension) {
utls.PSSWithSHA512,
utls.PKCS1WithSHA256,
utls.PKCS1WithSHA384,
utls.PKCS1WithSHA512,
utls.ECDSAWithSHA1,
utls.PKCS1WithSHA1,
utls.SignatureScheme(0x0806),
utls.SignatureScheme(0x0601),
},
}, // signature_algorithms_cert
"51": &utls.KeyShareExtension{KeyShares: []utls.KeyShare{
Expand All @@ -342,7 +341,7 @@ func genMap() (extMap map[string]utls.TLSExtension) {
"65281": &utls.RenegotiationInfoExtension{
Renegotiation: utls.RenegotiateOnceAsClient,
},
"65037": &utls.GenericExtension{Id: 65037},
"65037": utls.BoringGREASEECH(),
}
return

Expand Down
Loading

0 comments on commit 9df73ca

Please sign in to comment.