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
5f57bb1e
Commit
5f57bb1e
authored
Apr 19, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:ginuerzh/gost
parents
5fb4054f
45340b28
Pipeline
#11782
failed with stages
in 2 minutes and 17 seconds
Changes
15
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
219 additions
and
89 deletions
+219
-89
.github/workflows/buildx.yaml
.github/workflows/buildx.yaml
+2
-2
.gitignore
.gitignore
+1
-1
Makefile
Makefile
+5
-1
README.md
README.md
+21
-19
README_en.md
README_en.md
+18
-19
go.mod
go.mod
+15
-11
go.sum
go.sum
+67
-22
gost.go
gost.go
+1
-1
gost.png
gost.png
+0
-0
kcp.go
kcp.go
+35
-7
signal_unix.go
signal_unix.go
+2
-1
snap/snapcraft.yaml
snap/snapcraft.yaml
+33
-0
sockopts_linux.go
sockopts_linux.go
+7
-0
sockopts_other.go
sockopts_other.go
+7
-0
tuntap_windows.go
tuntap_windows.go
+5
-5
No files found.
.github/workflows/buildx.yaml
View file @
5f57bb1e
...
...
@@ -4,7 +4,7 @@ name: Docker
on
:
[
push
]
jobs
:
build
:
runs-on
:
ubuntu-
18.04
runs-on
:
ubuntu-
latest
steps
:
-
name
:
Prepare
id
:
prepare
...
...
@@ -19,7 +19,7 @@ jobs:
echo ::set-output name=version::snapshot
fi
echo ::set-output name=docker_platforms::linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/386
echo ::set-output name=docker_platforms::linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/386
,linux/s390x
echo ::set-output name=docker_image::${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}
# https://github.com/crazy-max/ghaction-docker-buildx
...
...
.gitignore
View file @
5f57bb1e
...
...
@@ -30,5 +30,5 @@ _testmain.go
*.bak
.vscode/
cmd/gost/gost
snap
Makefile
View file @
5f57bb1e
...
...
@@ -2,7 +2,7 @@ NAME=gost
BINDIR
=
bin
VERSION
=
$(
shell
cat
gost.go |
grep
'Version ='
|
sed
's/.*\"\(.*\)\".*/\1/g'
)
GOBUILD
=
CGO_ENABLED
=
0 go build
--ldflags
=
"-s -w"
-v
-x
-a
GOFILES
=
cmd/gost/
*
GOFILES
=
cmd/gost/
*
.go
PLATFORM_LIST
=
\
darwin-amd64
\
...
...
@@ -19,6 +19,7 @@ PLATFORM_LIST = \
linux-mipsle-hardfloat
\
linux-mips64
\
linux-mips64le
\
linux-s390x
\
freebsd-386
\
freebsd-amd64
...
...
@@ -70,6 +71,9 @@ linux-mips64:
linux-mips64le
:
GOARCH
=
mips64le
GOOS
=
linux
$(GOBUILD)
-o
$(BINDIR)
/
$(NAME)
-
$@
$(GOFILES)
linux-s390x
:
GOARCH
=
s390x
GOOS
=
linux
$(GOBUILD)
-o
$(BINDIR)
/
$(NAME)
-
$@
$(GOFILES)
freebsd-386
:
GOARCH
=
386
GOOS
=
freebsd
$(GOBUILD)
-o
$(BINDIR)
/
$(NAME)
-
$@
$(GOFILES)
...
...
README.md
View file @
5f57bb1e
gost -
GO Simple Tunnel
GO Simple Tunnel
======
### GO语言实现的安全隧道
[

](https://godoc.org/github.com/ginuerzh/gost)
[

](https://travis-ci.org/ginuerzh/gost)
[

](https://goreportcard.com/report/github.com/ginuerzh/gost)
[

](https://codecov.io/gh/ginuerzh/gost/branch/master)
[

](https://github.com/ginuerzh/gost/releases/latest)
[

](https://build.snapcraft.io/user/ginuerzh/gost
)
[

](https://hub.docker.com/r/ginuerzh/gost/
)
[

](https://hub.docker.com/r/ginuerzh/gost/
)
[

](https://snapcraft.io/gost
)
[
English README
](
README_en.md
)
### !!!!!
特性
------
*
多端口监听
*
可设置转发代理,支持多级转发(代理链)
*
支持标准HTTP/HTTPS/HTTP2/SOCKS4(A)/SOCKS5代理协议
*
Web代理支持
[
探测防御
](
https://
docs.ginuerzh.xyz/gost
/probe_resist/
)
*
[
支持多种隧道类型
](
https://
docs.ginuerzh.xyz/gost
/configuration/
)
*
[
SOCKS5代理支持TLS协商加密
](
https://
docs.ginuerzh.xyz/gost
/socks/
)
*
[
Tunnel UDP over TCP
](
https://
docs.ginuerzh.xyz/gost
/socks/
)
*
[
TCP/UDP透明代理
](
https://
docs.ginuerzh.xyz/gost
/redirect/
)
*
[
本地/远程TCP/UDP端口转发
](
https://
docs.ginuerzh.xyz/gost
/port-forwarding/
)
*
[
支持Shadowsocks(TCP/UDP)协议
](
https://
docs.ginuerzh.xyz/gost
/ss/
)
*
[
支持SNI代理
](
https://
docs.ginuerzh.xyz/gost
/sni/
)
*
[
权限控制
](
https://
docs.ginuerzh.xyz/gost
/permission/
)
*
[
负载均衡
](
https://
docs.ginuerzh.xyz/gost
/load-balancing/
)
*
[
路由控制
](
https://
docs.ginuerzh.xyz/gost
/bypass/
)
*
DNS
[
解析
](
https://
docs.ginuerzh.xyz/gost/resolver/
)
和
[
代理
](
https://docs.ginuerzh.xyz/gost
/dns/
)
*
[
TUN/TAP设备
](
https://
docs.ginuerzh.xyz/gost
/tuntap/
)
Wiki站点:
<https://docs.ginuerzh.xyz/gost/>
*
Web代理支持
[
探测防御
](
https://
v2.gost.run
/probe_resist/
)
*
[
支持多种隧道类型
](
https://
v2.gost.run
/configuration/
)
*
[
SOCKS5代理支持TLS协商加密
](
https://
v2.gost.run
/socks/
)
*
[
Tunnel UDP over TCP
](
https://
v2.gost.run
/socks/
)
*
[
TCP/UDP透明代理
](
https://
v2.gost.run
/redirect/
)
*
[
本地/远程TCP/UDP端口转发
](
https://
v2.gost.run
/port-forwarding/
)
*
[
支持Shadowsocks(TCP/UDP)协议
](
https://
v2.gost.run
/ss/
)
*
[
支持SNI代理
](
https://
v2.gost.run
/sni/
)
*
[
权限控制
](
https://
v2.gost.run
/permission/
)
*
[
负载均衡
](
https://
v2.gost.run
/load-balancing/
)
*
[
路由控制
](
https://
v2.gost.run
/bypass/
)
*
DNS
[
解析
](
https://
v2.gost.run/resolver/
)
和
[
代理
](
https://v2.gost.run
/dns/
)
*
[
TUN/TAP设备
](
https://
v2.gost.run
/tuntap/
)
Wiki站点:
[
v2.gost.run
](
https://v2.gost.run
)
Telegram讨论群:
<https://t.me/gogost>
...
...
@@ -68,6 +69,7 @@ brew install gost
#### Ubuntu商店
```
bash
sudo
snap
install
core
sudo
snap
install
gost
...
...
README_en.md
View file @
5f57bb1e
...
...
@@ -4,33 +4,32 @@ gost - GO Simple Tunnel
### A simple security tunnel written in Golang
[

](https://godoc.org/github.com/ginuerzh/gost)
[

](https://travis-ci.org/ginuerzh/gost)
[

](https://goreportcard.com/report/github.com/ginuerzh/gost)
[

](https://codecov.io/gh/ginuerzh/gost/branch/master)
[

](https://github.com/ginuerzh/gost/releases/latest)
[

](https://build.snapcraft.io/user/ginuerzh/gost
)
[

](https://hub.docker.com/r/ginuerzh/gost/
)
[

](https://hub.docker.com/r/ginuerzh/gost/
)
[

](https://snapcraft.io/gost
)
Features
------
*
Listening on multiple ports
*
Multi-level forward proxy - proxy chain
*
Standard HTTP/HTTPS/HTTP2/SOCKS4(A)/SOCKS5 proxy protocols support
*
[
Probing resistance
](
https://
docs.ginuerzh.xyz/gost
/en/probe_resist/
)
support for web proxy
*
[
Support multiple tunnel types
](
https://
docs.ginuerzh.xyz/gost
/en/configuration/
)
*
[
TLS encryption via negotiation support for SOCKS5 proxy
](
https://
docs.ginuerzh.xyz/gost
/en/socks/
)
*
[
Tunnel UDP over TCP
](
https://
docs.ginuerzh.xyz/gost
/en/socks/
)
*
[
TCP/UDP Transparent proxy
](
https://
docs.ginuerzh.xyz/gost
/en/redirect/
)
*
[
Local/remote TCP/UDP port forwarding
](
https://
docs.ginuerzh.xyz/gost
/en/port-forwarding/
)
*
[
Shadowsocks protocol
](
https://
docs.ginuerzh.xyz/gost
/en/ss/
)
*
[
SNI proxy
](
https://
docs.ginuerzh.xyz/gost
/en/sni/
)
*
[
Permission control
](
https://
docs.ginuerzh.xyz/gost
/en/permission/
)
*
[
Load balancing
](
https://
docs.ginuerzh.xyz/gost
/en/load-balancing/
)
*
[
Routing control
](
https://
docs.ginuerzh.xyz/gost
/en/bypass/
)
*
DNS
[
resolver
](
https://
docs.ginuerzh.xyz/gost/resolver/
)
and
[
proxy
](
https://docs.ginuerzh.xyz/gost
/dns/
)
*
[
TUN/TAP device
](
https://
docs.ginuerzh.xyz/gost
/en/tuntap/
)
Wiki:
<https://docs.ginuerzh.xyz/gost/en/>
*
[
Probing resistance
](
https://
v2.gost.run
/en/probe_resist/
)
support for web proxy
*
[
Support multiple tunnel types
](
https://
v2.gost.run
/en/configuration/
)
*
[
TLS encryption via negotiation support for SOCKS5 proxy
](
https://
v2.gost.run
/en/socks/
)
*
[
Tunnel UDP over TCP
](
https://
v2.gost.run
/en/socks/
)
*
[
TCP/UDP Transparent proxy
](
https://
v2.gost.run
/en/redirect/
)
*
[
Local/remote TCP/UDP port forwarding
](
https://
v2.gost.run
/en/port-forwarding/
)
*
[
Shadowsocks protocol
](
https://
v2.gost.run
/en/ss/
)
*
[
SNI proxy
](
https://
v2.gost.run
/en/sni/
)
*
[
Permission control
](
https://
v2.gost.run
/en/permission/
)
*
[
Load balancing
](
https://
v2.gost.run
/en/load-balancing/
)
*
[
Routing control
](
https://
v2.gost.run
/en/bypass/
)
*
DNS
[
resolver
](
https://
v2.gost.run/resolver/
)
and
[
proxy
](
https://v2.gost.run
/dns/
)
*
[
TUN/TAP device
](
https://
v2.gost.run
/en/tuntap/
)
Wiki:
[
v2.gost.run
](
https://v2.gost.run/en/
)
Telegram group:
<https://t.me/gogost>
...
...
go.mod
View file @
5f57bb1e
...
...
@@ -15,19 +15,22 @@ require (
github.com/gobwas/glob v0.2.3
github.com/gorilla/websocket v1.4.2
github.com/klauspost/compress v1.13.6
github.com/lucas-clemente/quic-go v0.2
4
.0
github.com/lucas-clemente/quic-go v0.2
6
.0
github.com/miekg/dns v1.1.43
github.com/milosgajdos/tenus v0.0.3
github.com/ryanuber/go-glob v1.0.0
github.com/shadowsocks/go-shadowsocks2 v0.1.5
github.com/shadowsocks/shadowsocks-go v0.0.0-20200409064450-3e585ff90601
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8
github.com/xtaci/kcp-go
v5.4.20+incompatible
github.com/xtaci/kcp-go
/v5 v5.6.1
github.com/xtaci/smux v1.5.16
github.com/xtaci/tcpraw v1.2.25
gitlab.com/yawning/obfs4.git v0.0.0-20210511220700-e330d1b7024b
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3
golang.org/x/net v0.0.0-20211215060638-4ddde0e984e9
golang.org/x/crypto v0.0.0-20220321153916-2c7772ba3064
golang.org/x/net v0.0.0-20220325170049-de3da57026de
)
require (
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect
github.com/cheekybits/genny v1.0.0 // indirect
github.com/coreos/go-iptables v0.6.0 // indirect
...
...
@@ -37,20 +40,21 @@ require (
github.com/google/gopacket v1.1.19 // indirect
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
github.com/klauspost/reedsolomon v1.9.15 // indirect
github.com/marten-seemann/qtls-go1-16 v0.1.4 // indirect
github.com/marten-seemann/qtls-go1-17 v0.1.0 // indirect
github.com/marten-seemann/qtls-go1-16 v0.1.5 // indirect
github.com/marten-seemann/qtls-go1-17 v0.1.1 // indirect
github.com/marten-seemann/qtls-go1-18 v0.1.1 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect
github.com/templexxx/cpu
feat v0.0.0-20180724012125-cef66df7f161
// indirect
github.com/templexxx/xor
v0.0.0-20191217153810-f85b25db303b
// indirect
github.com/templexxx/cpu
v0.0.7
// indirect
github.com/templexxx/xor
simd v0.4.1
// indirect
github.com/tjfoc/gmsm v1.4.1 // indirect
github.com/xtaci/lossyconn v0.0.0-20200209145036-adba10fffc37 // indirect
golang.org/x/mod v0.
5.1
// indirect
golang.org/x/sys v0.0.0-202
11216021012-1d35b9e2eb4e
// indirect
golang.org/x/mod v0.
6.0-dev.0.20220106191415-9b9b3d81d5e3
// indirect
golang.org/x/sys v0.0.0-202
20325203850-36772127a21f
// indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/tools v0.1.
8
// indirect
golang.org/x/tools v0.1.
10
// indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
)
go.sum
View file @
5f57bb1e
This diff is collapsed.
Click to expand it.
gost.go
View file @
5f57bb1e
...
...
@@ -20,7 +20,7 @@ import (
)
// Version is the gost version.
const
Version
=
"2.11.
1
"
const
Version
=
"2.11.
2
"
// Debug is a flag that enables the debug log.
var
Debug
bool
...
...
gost.png
0 → 100644
View file @
5f57bb1e
41.3 KB
kcp.go
View file @
5f57bb1e
...
...
@@ -15,9 +15,9 @@ import (
"github.com/go-log/log"
"github.com/klauspost/compress/snappy"
"github.com/xtaci/tcpraw"
"github.com/xtaci/kcp-go"
"github.com/xtaci/kcp-go/v5"
"github.com/xtaci/smux"
"github.com/xtaci/tcpraw"
)
var
(
...
...
@@ -43,6 +43,9 @@ type KCPConfig struct {
Resend
int
`json:"resend"`
NoCongestion
int
`json:"nc"`
SockBuf
int
`json:"sockbuf"`
SmuxBuf
int
`json:"smuxbuf"`
StreamBuf
int
`json:"streambuf"`
SmuxVer
int
`json:"smuxver"`
KeepAlive
int
`json:"keepalive"`
SnmpLog
string
`json:"snmplog"`
SnmpPeriod
int
`json:"snmpperiod"`
...
...
@@ -62,6 +65,16 @@ func (c *KCPConfig) Init() {
case
"fast3"
:
c
.
NoDelay
,
c
.
Interval
,
c
.
Resend
,
c
.
NoCongestion
=
1
,
10
,
2
,
1
}
if
c
.
SmuxVer
<=
0
{
c
.
SmuxVer
=
1
}
if
c
.
SmuxBuf
<=
0
{
c
.
SmuxBuf
=
c
.
SockBuf
}
if
c
.
StreamBuf
<=
0
{
c
.
StreamBuf
=
c
.
SockBuf
/
2
}
log
.
Logf
(
"%#v"
,
c
)
}
var
(
...
...
@@ -83,6 +96,9 @@ var (
Resend
:
0
,
NoCongestion
:
0
,
SockBuf
:
4194304
,
SmuxVer
:
1
,
SmuxBuf
:
4194304
,
StreamBuf
:
2097152
,
KeepAlive
:
10
,
SnmpLog
:
""
,
SnmpPeriod
:
60
,
...
...
@@ -231,8 +247,14 @@ func (tr *kcpTransporter) initSession(addr string, conn net.Conn, config *KCPCon
// stream multiplex
smuxConfig
:=
smux
.
DefaultConfig
()
smuxConfig
.
MaxReceiveBuffer
=
config
.
SockBuf
smuxConfig
.
Version
=
config
.
SmuxVer
smuxConfig
.
MaxReceiveBuffer
=
config
.
SmuxBuf
smuxConfig
.
MaxStreamBuffer
=
config
.
StreamBuf
smuxConfig
.
KeepAliveInterval
=
time
.
Duration
(
config
.
KeepAlive
)
*
time
.
Second
if
err
:=
smux
.
VerifyConfig
(
smuxConfig
);
err
!=
nil
{
return
nil
,
err
}
var
cc
net
.
Conn
=
kcpconn
if
!
config
.
NoComp
{
cc
=
newCompStreamConn
(
kcpconn
)
...
...
@@ -332,7 +354,9 @@ func (l *kcpListener) listenLoop() {
func
(
l
*
kcpListener
)
mux
(
conn
net
.
Conn
)
{
smuxConfig
:=
smux
.
DefaultConfig
()
smuxConfig
.
MaxReceiveBuffer
=
l
.
config
.
SockBuf
smuxConfig
.
Version
=
l
.
config
.
SmuxVer
smuxConfig
.
MaxReceiveBuffer
=
l
.
config
.
SmuxBuf
smuxConfig
.
MaxStreamBuffer
=
l
.
config
.
StreamBuf
smuxConfig
.
KeepAliveInterval
=
time
.
Duration
(
l
.
config
.
KeepAlive
)
*
time
.
Second
log
.
Logf
(
"[kcp] %s - %s"
,
conn
.
RemoteAddr
(),
l
.
Addr
())
...
...
@@ -473,9 +497,13 @@ func (c *compStreamConn) Read(b []byte) (n int, err error) {
}
func
(
c
*
compStreamConn
)
Write
(
b
[]
byte
)
(
n
int
,
err
error
)
{
n
,
err
=
c
.
w
.
Write
(
b
)
err
=
c
.
w
.
Flush
()
return
n
,
err
if
_
,
err
=
c
.
w
.
Write
(
b
);
err
!=
nil
{
return
0
,
err
}
if
err
=
c
.
w
.
Flush
();
err
!=
nil
{
return
0
,
err
}
return
len
(
b
),
err
}
func
(
c
*
compStreamConn
)
Close
()
error
{
...
...
signal_unix.go
View file @
5f57bb1e
//go:build !windows
// +build !windows
package
gost
...
...
@@ -8,7 +9,7 @@ import (
"syscall"
"github.com/go-log/log"
"github.com/xtaci/kcp-go"
"github.com/xtaci/kcp-go
/v5
"
)
func
kcpSigHandler
()
{
...
...
snapcraft.yaml
→
snap
/snap
craft.yaml
View file @
5f57bb1e
name
:
gost
type
:
app
version
:
'
2.11.1'
title
:
GO Simple Tunnel
base
:
core20
version
:
'
2.11.2'
summary
:
A simple security tunnel written in golang
description
:
|
https://github.com/ginuerzh/gost
Project: https://github.com/ginuerzh/gost
Wiki: https://v2.gost.run
icon
:
gost.png
website
:
https://v2.gost.run
confinement
:
strict
grade
:
stable
base
:
core18
license
:
MIT
parts
:
gost
:
plugin
:
nil
build-snaps
:
[
go/1.13/stable
]
source
:
https://github.com/ginuerzh/gost
.git
plugin
:
go
go-channel
:
latest/stable
source
:
https://github.com/ginuerzh/gost
source-subdir
:
cmd/gost
source-type
:
git
source-
branch
:
'
2'
source-
tag
:
v2.11.2
build-packages
:
-
build-essential
override-build
:
|
set -ex
echo "Starting override-build:"
pwd
cd $SNAPCRAFT_PART_BUILD
GO111MODULE=on CGO_ENABLED=0 go build --ldflags="-s -w"
./gost -V
echo "Installing to ${SNAPCRAFT_PART_INSTALL}..."
install -d $SNAPCRAFT_PART_INSTALL/bin
cp -v gost $SNAPCRAFT_PART_INSTALL/bin/
-
gcc
echo "Override-build done!"
apps
:
gost
:
command
:
bin/gost
...
...
sockopts_linux.go
0 → 100644
View file @
5f57bb1e
package
gost
import
"syscall"
func
setSocketMark
(
fd
int
,
value
int
)
(
e
error
)
{
return
syscall
.
SetsockoptInt
(
fd
,
syscall
.
SOL_SOCKET
,
syscall
.
SO_MARK
,
value
)
}
sockopts_other.go
0 → 100644
View file @
5f57bb1e
//go:build !linux
package
gost
func
setSocketMark
(
fd
int
,
value
int
)
(
e
error
)
{
return
nil
}
tuntap_windows.go
View file @
5f57bb1e
...
...
@@ -28,7 +28,7 @@ func createTun(cfg TunConfig) (conn net.Conn, itf *net.Interface, err error) {
return
}
cmd
:=
fmt
.
Sprintf
(
"netsh interface ip set address name=
%s
"
+
cmd
:=
fmt
.
Sprintf
(
"netsh interface ip set address name=
\"
%s
\"
"
+
"source=static addr=%s mask=%s gateway=none"
,
ifce
.
Name
(),
ip
.
String
(),
ipMask
(
ipNet
.
Mask
))
log
.
Log
(
"[tun]"
,
cmd
)
...
...
@@ -70,7 +70,7 @@ func createTap(cfg TapConfig) (conn net.Conn, itf *net.Interface, err error) {
}
if
ip
!=
nil
&&
ipNet
!=
nil
{
cmd
:=
fmt
.
Sprintf
(
"netsh interface ip set address name=
%s
"
+
cmd
:=
fmt
.
Sprintf
(
"netsh interface ip set address name=
\"
%s
\"
"
+
"source=static addr=%s mask=%s gateway=none"
,
ifce
.
Name
(),
ip
.
String
(),
ipMask
(
ipNet
.
Mask
))
log
.
Log
(
"[tap]"
,
cmd
)
...
...
@@ -105,7 +105,7 @@ func addTunRoutes(ifName string, gw string, routes ...IPRoute) error {
deleteRoute
(
ifName
,
route
.
Dest
.
String
())
cmd
:=
fmt
.
Sprintf
(
"netsh interface ip add route prefix=%s interface=
%s
store=active"
,
cmd
:=
fmt
.
Sprintf
(
"netsh interface ip add route prefix=%s interface=
\"
%s
\"
store=active"
,
route
.
Dest
.
String
(),
ifName
)
if
gw
!=
""
{
cmd
+=
" nexthop="
+
gw
...
...
@@ -127,7 +127,7 @@ func addTapRoutes(ifName string, gw string, routes ...string) error {
deleteRoute
(
ifName
,
route
)
cmd
:=
fmt
.
Sprintf
(
"netsh interface ip add route prefix=%s interface=
%s
store=active"
,
cmd
:=
fmt
.
Sprintf
(
"netsh interface ip add route prefix=%s interface=
\"
%s
\"
store=active"
,
route
,
ifName
)
if
gw
!=
""
{
cmd
+=
" nexthop="
+
gw
...
...
@@ -142,7 +142,7 @@ func addTapRoutes(ifName string, gw string, routes ...string) error {
}
func
deleteRoute
(
ifName
string
,
route
string
)
error
{
cmd
:=
fmt
.
Sprintf
(
"netsh interface ip delete route prefix=%s interface=
%s
store=active"
,
cmd
:=
fmt
.
Sprintf
(
"netsh interface ip delete route prefix=%s interface=
\"
%s
\"
store=active"
,
route
,
ifName
)
args
:=
strings
.
Split
(
cmd
,
" "
)
return
exec
.
Command
(
args
[
0
],
args
[
1
:
]
...
)
.
Run
()
...
...
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