Commit db87d34c authored by wang's avatar wang

更改

parent 295f2d60
module tls-forward
go 1.20
go 1.21
toolchain go1.22.0
require (
github.com/antonfisher/nested-logrus-formatter v1.3.1
github.com/bogdanfinn/tls-client v1.7.2
github.com/gin-gonic/gin v1.9.0
github.com/natefinch/lumberjack v2.0.0+incompatible
github.com/sirupsen/logrus v1.9.0
github.com/sirupsen/logrus v1.9.3
)
require (
......@@ -18,6 +20,7 @@ require (
github.com/bytedance/sonic v1.8.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
......@@ -31,14 +34,17 @@ require (
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/quic-go/quic-go v0.40.1 // indirect
github.com/stretchr/testify v1.8.1 // indirect
github.com/tam7t/hpkp v0.0.0-20160821193359-2b70b4024ed5 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.9 // indirect
github.com/wmm1996528/cronet-go v1.1.2 // indirect
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
......
......@@ -87,6 +87,8 @@ github.com/quic-go/quic-go v0.40.1/go.mod h1:PeN7kuVJ4xZbxSv/4OX6S1USOX8MJvydwpT
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
......@@ -103,6 +105,8 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go/codec v1.2.9 h1:rmenucSohSTiyL09Y+l2OCk+FrMxGMzho2+tjr5ticU=
github.com/ugorji/go/codec v1.2.9/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/wmm1996528/cronet-go v1.1.2 h1:eA4mtAJIkKC4phDQ9GWRgk6bvWEPkPbWVAH2JYPFsgM=
github.com/wmm1996528/cronet-go v1.1.2/go.mod h1:cgCEgPXbA06M5DycAmbNeFH02pPOhwMq1x7u3e8Weh8=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 h1:18EFjUmQOcUvxNYSkA6jO9VAiXCnxFY6NyDX0bHDmkU=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE=
......@@ -133,6 +137,8 @@ golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.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/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
......
......@@ -8,19 +8,20 @@ import (
"encoding/binary"
"errors"
"github.com/andybalholm/brotli"
http "github.com/bogdanfinn/fhttp"
tls_client "github.com/bogdanfinn/tls-client"
"github.com/bogdanfinn/tls-client/profiles"
"github.com/sirupsen/logrus"
"github.com/wmm1996528/cronet-go"
"io/ioutil"
"math/big"
"net/http"
"net/http/cookiejar"
"net/url"
"strings"
)
type Client struct {
Client tls_client.HttpClient
Jar tls_client.CookieJar
Client *http.Client
Jar *cookiejar.Jar
Item ForwardItem
Response *http.Response
uri *url.URL
......@@ -139,36 +140,29 @@ func RandRandom(a int64) int64 {
return res.Int64()
}
func NewClient(forWard ForwardItem, ios bool) (Client, error) {
jar := tls_client.NewCookieJar()
tlsVersion := chromes[RandRandom(int64(len(chromes)))]
if ios {
tlsVersion = profiles.Safari_IOS_16_0
}
options := []tls_client.HttpClientOption{
tls_client.WithTimeoutSeconds(forWard.Timeout),
tls_client.WithClientProfile(tlsVersion),
tls_client.WithProxyUrl(forWard.Proxy),
//tls_client.WithForceHttp1(),
tls_client.WithCookieJar(jar),
tls_client.WithRandomTLSExtensionOrder(),
//tls_client.WithProxyUrl("http://user:pass@host:port"),
tls_client.WithInsecureSkipVerify(),
}
//if forWard.RandomTls {
options = append(options, tls_client.WithRandomTLSExtensionOrder())
//}
logger := tls_client.NewNoopLogger()
if forWard.Debug {
logger = tls_client.NewDebugLogger(tls_client.NewDebugLogger(tls_client.NewLogger()))
}
client, err := tls_client.NewHttpClient(logger, options...)
client.SetFollowRedirect(forWard.AllowRedirects)
if err != nil {
return Client{}, err
}
return Client{Client: client, Item: forWard, Jar: jar, TlsVersion: tlsVersion.GetClientHelloStr()}, nil
engineParams := cronet.NewEngineParams()
//engineParams.SetProxyServer("http://127.0.0.1:8081")
//engineParams.SetProxyServer("http://user-uni003-region-de-sessid-1125-sesstime-5-keep-true:q39CEBTs5A5YQXor@pr.roxlabs.cn:4600")
//engineParams.SetProxyServer("http://user-uni003-region-de-sessid-1231-sesstime-5-keep-true:q39CEBTs5A5YQXor@pr.roxlabs.cn:4600")
engineParams.SetProxyServer(forWard.Proxy)
engineParams.SetEnableHTTP2(true)
engineParams.SetEnableQuic(false)
engineParams.SetEnableBrotli(true)
t := cronet.NewCronetTransport(engineParams, true)
//t.Engine.StartNetLogToFile("./1.log", true)
//ConfigureClientCertificate(&t.Engine, certPath, keyPath, []string{urlArg.Host, proxyArg.Host})
jar, _ := cookiejar.New(nil)
client := &http.Client{
Transport: t,
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
},
Jar: jar,
}
return Client{Client: client, Item: forWard, Jar: jar}, nil
}
// 解码Body数据
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment