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
f8ae2583
Commit
f8ae2583
authored
Apr 19, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/IndexDoge/gost
parents
5f57bb1e
8404317a
Pipeline
#11783
failed with stages
in 1 minute and 8 seconds
Changes
5
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
4 deletions
+30
-4
chain.go
chain.go
+19
-4
cmd/gost/main.go
cmd/gost/main.go
+1
-0
cmd/gost/route.go
cmd/gost/route.go
+2
-0
sockopts_linux.go
sockopts_linux.go
+4
-0
sockopts_other.go
sockopts_other.go
+4
-0
No files found.
chain.go
View file @
f8ae2583
...
...
@@ -20,6 +20,7 @@ type Chain struct {
isRoute
bool
Retries
int
Mark
int
Interface
string
nodeGroups
[]
*
NodeGroup
route
[]
Node
// nodes in the selected route
}
...
...
@@ -36,9 +37,11 @@ func NewChain(nodes ...Node) *Chain {
// newRoute creates a chain route.
// a chain route is the final route after node selection.
func
newRoute
(
nodes
...
Node
)
*
Chain
{
func
(
c
*
Chain
)
newRoute
(
nodes
...
Node
)
*
Chain
{
chain
:=
NewChain
(
nodes
...
)
chain
.
isRoute
=
true
chain
.
Interface
=
c
.
Interface
chain
.
Mark
=
c
.
Mark
return
chain
}
...
...
@@ -170,6 +173,18 @@ func (c *Chain) dialWithOptions(ctx context.Context, network, address string, op
}
}
if
c
.
Interface
!=
""
{
controlFunction
=
func
(
_
,
_
string
,
cc
syscall
.
RawConn
)
error
{
return
cc
.
Control
(
func
(
fd
uintptr
)
{
err
:=
setSocketInterface
(
int
(
fd
),
c
.
Interface
)
if
err
!=
nil
{
log
.
Logf
(
"net dialer set interface %s error: %s"
,
c
.
Interface
,
err
)
}
})
}
}
if
route
.
IsEmpty
()
{
switch
network
{
case
"udp"
,
"udp4"
,
"udp6"
:
...
...
@@ -307,13 +322,13 @@ func (c *Chain) selectRoute() (route *Chain, err error) {
// selectRouteFor selects route with bypass testing.
func
(
c
*
Chain
)
selectRouteFor
(
addr
string
)
(
route
*
Chain
,
err
error
)
{
if
c
.
IsEmpty
()
{
return
newRoute
(),
nil
return
c
.
newRoute
(),
nil
}
if
c
.
isRoute
{
return
c
,
nil
}
route
=
newRoute
()
route
=
c
.
newRoute
()
var
nl
[]
Node
for
_
,
group
:=
range
c
.
nodeGroups
{
...
...
@@ -331,7 +346,7 @@ func (c *Chain) selectRouteFor(addr string) (route *Chain, err error) {
node
.
DialOptions
=
append
(
node
.
DialOptions
,
ChainDialOption
(
route
),
)
route
=
newRoute
()
// cutoff the chain for multiplex node.
route
=
c
.
newRoute
()
// cutoff the chain for multiplex node.
}
route
.
AddNode
(
node
)
...
...
cmd/gost/main.go
View file @
f8ae2583
...
...
@@ -33,6 +33,7 @@ func init() {
flag
.
Var
(
&
baseCfg
.
route
.
ServeNodes
,
"L"
,
"listen address, can listen on multiple ports (required)"
)
flag
.
IntVar
(
&
baseCfg
.
route
.
Mark
,
"M"
,
0
,
"Specify out connection mark"
)
flag
.
StringVar
(
&
configureFile
,
"C"
,
""
,
"configure file"
)
flag
.
StringVar
(
&
baseCfg
.
route
.
Interface
,
"I"
,
""
,
"Interface to bind"
)
flag
.
BoolVar
(
&
baseCfg
.
Debug
,
"D"
,
false
,
"enable debug log"
)
flag
.
BoolVar
(
&
printVersion
,
"V"
,
false
,
"print version"
)
if
pprofEnabled
{
...
...
cmd/gost/route.go
View file @
f8ae2583
...
...
@@ -31,12 +31,14 @@ type route struct {
ChainNodes
stringList
Retries
int
Mark
int
Interface
string
}
func
(
r
*
route
)
parseChain
()
(
*
gost
.
Chain
,
error
)
{
chain
:=
gost
.
NewChain
()
chain
.
Retries
=
r
.
Retries
chain
.
Mark
=
r
.
Mark
chain
.
Interface
=
r
.
Interface
gid
:=
1
// group ID
for
_
,
ns
:=
range
r
.
ChainNodes
{
...
...
sockopts_linux.go
View file @
f8ae2583
...
...
@@ -5,3 +5,7 @@ import "syscall"
func
setSocketMark
(
fd
int
,
value
int
)
(
e
error
)
{
return
syscall
.
SetsockoptInt
(
fd
,
syscall
.
SOL_SOCKET
,
syscall
.
SO_MARK
,
value
)
}
func
setSocketInterface
(
fd
int
,
value
string
)
(
e
error
)
{
return
syscall
.
SetsockoptString
(
fd
,
syscall
.
SOL_SOCKET
,
syscall
.
SO_BINDTODEVICE
,
value
)
}
\ No newline at end of file
sockopts_other.go
View file @
f8ae2583
...
...
@@ -5,3 +5,7 @@ package gost
func
setSocketMark
(
fd
int
,
value
int
)
(
e
error
)
{
return
nil
}
func
setSocketInterface
(
fd
int
,
value
string
)
(
e
error
)
{
return
nil
}
\ No newline at end of file
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