Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
T
tls-forward
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangmingming
tls-forward
Commits
a22e7a1e
Commit
a22e7a1e
authored
Jan 08, 2024
by
wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
每次请求后关闭连接
parent
82428bca
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
6 deletions
+22
-6
go.mod
go.mod
+1
-1
go.sum
go.sum
+2
-0
client.go
tls/client.go
+4
-3
tls.go
tls/tls.go
+15
-2
No files found.
go.mod
View file @
a22e7a1e
...
@@ -38,7 +38,7 @@ require (
...
@@ -38,7 +38,7 @@ require (
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.1
5
.0 // indirect
golang.org/x/sys v0.1
6
.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
...
...
go.sum
View file @
a22e7a1e
...
@@ -131,6 +131,8 @@ golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
...
@@ -131,6 +131,8 @@ 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.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
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.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/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
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.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
...
...
tls/client.go
View file @
a22e7a1e
...
@@ -100,7 +100,7 @@ func (c *Client) GetSessionCookies() map[string]string {
...
@@ -100,7 +100,7 @@ func (c *Client) GetSessionCookies() map[string]string {
}
}
func
(
c
*
Client
)
GetText
()
string
{
func
(
c
*
Client
)
GetText
()
string
{
defer
c
.
Response
.
Body
.
Close
()
//http.DecompressBody(c.Response)
//http.DecompressBody(c.Response)
//rb, _ := io.ReadAll(c.Response.Body)
//rb, _ := io.ReadAll(c.Response.Body)
content
,
_
:=
ioutil
.
ReadAll
(
c
.
Response
.
Body
)
content
,
_
:=
ioutil
.
ReadAll
(
c
.
Response
.
Body
)
...
@@ -127,8 +127,8 @@ var chromes = []profiles.ClientProfile{
...
@@ -127,8 +127,8 @@ var chromes = []profiles.ClientProfile{
//profiles.Chrome_110,
//profiles.Chrome_110,
//profiles.Chrome_107,
//profiles.Chrome_107,
//profiles.Chrome_108,
//profiles.Chrome_108,
//
profiles.Chrome_117,
profiles
.
Chrome_117
,
profiles
.
Firefox_120
,
//
profiles.Firefox_120,
//profiles.Safari_15_6_1,
//profiles.Safari_15_6_1,
//profiles.Safari_16_0,
//profiles.Safari_16_0,
//tls_client.Safari_Ipad_15_6,
//tls_client.Safari_Ipad_15_6,
...
@@ -165,6 +165,7 @@ func NewClient(forWard ForwardItem, ios bool) (Client, error) {
...
@@ -165,6 +165,7 @@ func NewClient(forWard ForwardItem, ios bool) (Client, error) {
if
err
!=
nil
{
if
err
!=
nil
{
return
Client
{},
err
return
Client
{},
err
}
}
return
Client
{
Client
:
client
,
Item
:
forWard
,
Jar
:
jar
,
TlsVersion
:
tlsVersion
.
GetClientHelloStr
()},
nil
return
Client
{
Client
:
client
,
Item
:
forWard
,
Jar
:
jar
,
TlsVersion
:
tlsVersion
.
GetClientHelloStr
()},
nil
}
}
...
...
tls/tls.go
View file @
a22e7a1e
...
@@ -57,7 +57,13 @@ func ForwardIOS(c *gin.Context) {
...
@@ -57,7 +57,13 @@ func ForwardIOS(c *gin.Context) {
res
[
"cost_time"
]
=
time
.
Now
()
.
Sub
(
t1
)
.
Milliseconds
()
res
[
"cost_time"
]
=
time
.
Now
()
.
Sub
(
t1
)
.
Milliseconds
()
res
[
"url"
]
=
client
.
GetRespUrl
()
res
[
"url"
]
=
client
.
GetRespUrl
()
res
[
"text"
]
=
client
.
GetText
()
res
[
"text"
]
=
client
.
GetText
()
defer
func
()
{
err
:=
client
.
Response
.
Body
.
Close
()
if
err
!=
nil
{
fmt
.
Errorf
(
"text %s"
,
err
.
Error
())
return
}
}()
logrus
.
Infof
(
"%s 转发 %s %s %d 耗时 %s"
,
client
.
TlsVersion
,
forWard
.
Url
,
forWard
.
Proxy
,
client
.
GetStatusCode
(),
time
.
Now
()
.
Sub
(
t1
)
.
String
())
logrus
.
Infof
(
"%s 转发 %s %s %d 耗时 %s"
,
client
.
TlsVersion
,
forWard
.
Url
,
forWard
.
Proxy
,
client
.
GetStatusCode
(),
time
.
Now
()
.
Sub
(
t1
)
.
String
())
c
.
JSON
(
200
,
res
)
c
.
JSON
(
200
,
res
)
}
}
...
@@ -99,7 +105,14 @@ func Forward(c *gin.Context) {
...
@@ -99,7 +105,14 @@ func Forward(c *gin.Context) {
res
[
"cost_time"
]
=
time
.
Now
()
.
Sub
(
t1
)
.
Milliseconds
()
res
[
"cost_time"
]
=
time
.
Now
()
.
Sub
(
t1
)
.
Milliseconds
()
res
[
"url"
]
=
client
.
GetRespUrl
()
res
[
"url"
]
=
client
.
GetRespUrl
()
res
[
"text"
]
=
client
.
GetText
()
res
[
"text"
]
=
client
.
GetText
()
defer
func
()
{
err
:=
client
.
Response
.
Body
.
Close
()
if
err
!=
nil
{
fmt
.
Errorf
(
"text %s"
,
err
.
Error
())
return
}
}()
client
.
Client
.
CloseIdleConnections
()
logrus
.
Infof
(
"%s 转发 %s %s %d 耗时 %s"
,
client
.
TlsVersion
,
forWard
.
Url
,
forWard
.
Proxy
,
client
.
GetStatusCode
(),
time
.
Now
()
.
Sub
(
t1
)
.
String
())
logrus
.
Infof
(
"%s 转发 %s %s %d 耗时 %s"
,
client
.
TlsVersion
,
forWard
.
Url
,
forWard
.
Proxy
,
client
.
GetStatusCode
(),
time
.
Now
()
.
Sub
(
t1
)
.
String
())
c
.
JSON
(
200
,
res
)
c
.
JSON
(
200
,
res
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment