Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
G
gost
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
gost
Commits
86e9772f
Commit
86e9772f
authored
Jun 14, 2019
by
ginuerzh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add knock option for probe resistance
parent
6f0bf7da
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
4 deletions
+15
-4
cmd/gost/route.go
cmd/gost/route.go
+1
-0
handler.go
handler.go
+8
-0
http.go
http.go
+3
-2
http2.go
http2.go
+3
-2
No files found.
cmd/gost/route.go
View file @
86e9772f
...
...
@@ -438,6 +438,7 @@ func (r *route) GenRouters() ([]router, error) {
gost
.
RetryHandlerOption
(
node
.
GetInt
(
"retry"
)),
// override the global retry option.
gost
.
TimeoutHandlerOption
(
time
.
Duration
(
node
.
GetInt
(
"timeout"
))
*
time
.
Second
),
gost
.
ProbeResistHandlerOption
(
node
.
Get
(
"probe_resist"
)),
gost
.
KnockingHandlerOption
(
node
.
Get
(
"knock"
)),
gost
.
NodeHandlerOption
(
node
),
gost
.
IPsHandlerOption
(
ips
),
)
...
...
handler.go
View file @
86e9772f
...
...
@@ -34,6 +34,7 @@ type HandlerOptions struct {
Resolver
Resolver
Hosts
*
Hosts
ProbeResist
string
KnockingHost
string
Node
Node
Host
string
IPs
[]
string
...
...
@@ -150,6 +151,13 @@ func ProbeResistHandlerOption(pr string) HandlerOption {
}
}
// KnockingHandlerOption adds the knocking host for probe resistance.
func
KnockingHandlerOption
(
host
string
)
HandlerOption
{
return
func
(
opts
*
HandlerOptions
)
{
opts
.
KnockingHost
=
host
}
}
// NodeHandlerOption set the server node for server handler.
func
NodeHandlerOption
(
node
Node
)
HandlerOption
{
return
func
(
opts
*
HandlerOptions
)
{
...
...
http.go
View file @
86e9772f
...
...
@@ -302,8 +302,9 @@ func (h *httpHandler) authenticate(conn net.Conn, req *http.Request, resp *http.
return
true
}
// probing resistance is enabled
if
ss
:=
strings
.
SplitN
(
h
.
options
.
ProbeResist
,
":"
,
2
);
len
(
ss
)
==
2
{
// probing resistance is enabled, and knocking host is mismatch.
if
ss
:=
strings
.
SplitN
(
h
.
options
.
ProbeResist
,
":"
,
2
);
len
(
ss
)
==
2
&&
(
h
.
options
.
KnockingHost
==
""
||
!
strings
.
EqualFold
(
req
.
URL
.
Hostname
(),
h
.
options
.
KnockingHost
))
{
resp
.
StatusCode
=
http
.
StatusServiceUnavailable
// default status code
switch
ss
[
0
]
{
...
...
http2.go
View file @
86e9772f
...
...
@@ -461,8 +461,9 @@ func (h *http2Handler) authenticate(w http.ResponseWriter, r *http.Request, resp
return
true
}
// probing resistance is enabled
if
ss
:=
strings
.
SplitN
(
h
.
options
.
ProbeResist
,
":"
,
2
);
len
(
ss
)
==
2
{
// probing resistance is enabled, and knocking host is mismatch.
if
ss
:=
strings
.
SplitN
(
h
.
options
.
ProbeResist
,
":"
,
2
);
len
(
ss
)
==
2
&&
(
h
.
options
.
KnockingHost
==
""
||
!
strings
.
EqualFold
(
r
.
URL
.
Hostname
(),
h
.
options
.
KnockingHost
))
{
resp
.
StatusCode
=
http
.
StatusServiceUnavailable
// default status code
w
.
Header
()
.
Del
(
"Proxy-Agent"
)
...
...
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