你的位置:首页 > 互联网IT
gost,gost3,gost-v3,gost3配置文件教材,http代理,socks5代理,转发端口,shadowsocks代理,SS代理,负载均衡,中转服务,端口映射,gost3命令教材,DTLS
gost,gost3,gost-v3,gost3配置文件教材,http代理,socks5代理,转发端口,shadowsocks代理,SS代理,负载均衡,中转服务,端口映射,gost3命令教材,DTLS,Websocket(ws),gRPC,QUIC
系统:Windows/linux
软件:gost v3.0
功能:http代理,socks5代理,转发端口,shadowsocks代理,SS代理,负载均衡,中转服务,端口映射
项目地址:https://github.com/go-gost/gost
gost-v3-beta.6(使用很久,稳定版本)
本地下载1-Windows-32位:gost-windows-386-3.0.0-beta.6.zip
本地下载2-Windows-64位:gost-windows-amd64-3.0.0-beta.6.zip
本地下载3-linux-32位:gost-linux-386-3.0.0-beta.6.gz
本地下载4-linux-64位:gost-linux-amd64-3.0.0-beta.6.gz
gost-v3.0.0-rc8
本地下载5-Windows-32位:gost_3.0.0-rc8_windows_386.zip
本地下载6-Windows-64位:gost_3.0.0-rc8_windows_amd64.zip
本地下载7-linux-32位:gost_3.0.0-rc8_linux_386.tar.gz
本地下载8-linux-64位:gost_3.0.0-rc8_linux_amd64.tar.gz
项目地址下载地址:https://github.com/go-gost/gost/releases
本文内容:DTLS,Websocket(ws),gRPC,QUIC,Plain HTTP Tunnel(PHT),HTTP3,KCP,SSH,MTCP
gost,gost3,gost-v3版本-配置文件文章
https://www.zhuguodong.com/?id=771
gost,gost3,gost-v3版本-命令文章
https://www.zhuguodong.com/?id=767
同类型gost-v2.0(gost2)版本
https://www.zhuguodong.com/?id=700
-----------------------------------------------------------
Windows隐藏运行软件,cmd隐藏运行,bat隐藏运行,命令窗口隐藏运行
https://www.zhuguodong.com/?id=520
linux隐藏运行软件
nohup /root/gost -L ss://aes-256-cfb:123456@:23333 >/dev/null 2>&1 &
nohup 《内容替换》 >/dev/null 2>&1 &
-----------------------------------------------------------
简单配置运行:
Windows:新建 gost.bat 文件
linux:命令窗口隐藏运行,gost要加入权限:chmod +x gost
启动参数:-c
Windows:start "" "gost.exe" -C gost.yaml
linux:gost -C gost.yaml
说明:.yaml配置文件不能有空行,或者不必要的空格,不然会运行不成功
启动参数:-c
Windows:start "" "gost.exe" -C gost.json
linux:gost -C gost.json
程序gost与文件同一目录下,说明:.json与.yaml配置文件格式(这个文件格式配置不能出现空格),教材就用.json格式演示
配置.json与.yaml格式可相互转换的
输出yaml格式配置
gost -L http://:8080 -O yaml
输出json格式配置
gost -L http://:8080 -O json
将json格式配置转成yaml格式
gost -C gost.json -O yaml
gost -C gost.yaml -O json
-----------------------------------------------------------
DTLS¶
DTLS是GOST中的一种数据通道类型。DTLS的实现依赖于pion/dtls库。
TLS证书配置
TLS配置请参考TLS配置说明。
DTLS服务¶
命令行
gost -L dtls://:8443
配置文件
services:
- name: service-0
addr: :
handler:
type: auto
listener:
type: dtls
代理协议¶
DTLS数据通道可以与各种代理协议组合使用。
HTTP Over DTLS¶
命令行
gost -L http+dtls://:8443
配置文件
services:
- name: service-0
addr: :8443
handler:
type: http
listener:
type: dtls
SOCKS5 Over DTLS¶
命令行
gost -L socks5+dtls://:8443
配置文件
services:
- name: service-0
addr: :8443
handler:
type: socks5
listener:
type: dtls
Relay Over DTLS¶
命令行
gost -L relay+dtls://:8443
配置文件
services:
- name: service-0
addr: :8443
handler:
type: relay
listener:
type: dtls
端口转发¶
DTLS通道也可以用作端口转发,相当于在UDP端口转发服务基础上增加TLS加密。
服务端¶
命令行
gost -L dtls://:8443/:8080 -L http://:8080
等同于
gost -L forward+dtls://:8443/:8080 -L http://:8080
配置文件
services:
- name: service-0
addr: :8443
handler:
type: forward
listener:
type: dtls
forwarder:
nodes:
- name: target-0
addr: :8080
- name: service-1
addr: :8080
handler:
type: http
listener:
type: tcp
通过使用DTLS数据通道的端口转发,给8080端口的HTTP代理服务增加了DTLS加密数据通道。
此时8443端口等同于:
gost -L http+dtls://:8443
-----------------------------------------------------------
Websocket¶
Websocket是GOST中的一种数据通道类型。
TLS证书配置
TLS配置请参考TLS配置说明。
Websocket¶
未加密的Websocket数据通道。
命令行
gost -L ws://:8080
配置文件
services:
- name: service-0
addr: :
handler:
type: auto
listener:
type: ws
Websocket Secure¶
基于TLS加密的Websocket数据通道。
命令行
gost -L wss://:8080
配置文件
services:
- name: service-0
addr: :
handler:
type: auto
listener:
type: wss
多路复用¶
GOST在Websocket基础之上扩展出具有多路复用(Multiplex)特性的传输类型mws和mwss。多路复用基于xtaci/smux库。
命令行
gost -L mws://:8443
gost -L mwss://:8443
配置文件
services:
- name: service-0
addr: :
handler:
type: auto
listener:
type: mws
# type: mwss
metadata:
mux.version: 1
参数选项¶
多路复用¶
mux.version (int, default=1)
SMUX协议版本
mux.keepaliveDisabled (bool, default=false)
是否禁用心跳
mux.keepaliveInterval (duration, default=10s)
心跳间隔时长
mux.keepaliveTimeout (duration, default=30s)
心跳超时时长
mux.maxFrameSize (int, default=32768)
帧最大长度
mux.maxReceiveBuffer (int, default=4194304)
接收缓冲区大小
mux.maxStreamBuffer (int, default=65536)
Steam缓冲区大小
自定义请求路径¶
可以通过path选项自定义请求路径,默认值为/ws。
路径匹配验证
仅当客户端和服务端设定的path参数相同时,连接才能成功建立。
服务端¶
命令行
gost -L wss://:8443?path=/ws
配置文件
services:
- name: service-0
addr: :8443
handler:
type: auto
listener:
type: wss
metadata:
path: /ws
客户端¶
命令行
gost -L http://:8080 -F wss://:8443?path=/ws
配置文件
services:
- name: service-0
addr: :8080
handler:
type: http
chain: chain-0
listener:
type: tcp
chains:
- name: chain-0
hops:
- name: hop-0
nodes:
- name: node-0
addr: :8443
connector:
type: http
dialer:
type: wss
metadata:
path: /ws
自定义请求主机名¶
客户端默认使用节点地址(-F参数或nodes.addr中指定的地址)作为请求主机名(Host头部信息),可以通过host参数自定义请求主机名。
命令行
gost -L http://:8080 -F wss://:8443?host=example.com
配置文件
services:
- name: service-0
addr: :8080
handler:
type: http
chain: chain-0
listener:
type: tcp
chains:
- name: chain-0
hops:
- name: hop-0
nodes:
- name: node-0
addr: :8443
connector:
type: http
dialer:
type: wss
metadata:
host: example.com
自定义HTTP头¶
通过header选项可以自定义请求和响应头部信息。
services:
- name: service-0
addr: :8080
handler:
type: http
chain: chain-0
listener:
type: tcp
chains:
- name: chain-0
hops:
- name: hop-0
nodes:
- name: node-0
addr: :8443
connector:
type: http
dialer:
type: wss
metadata:
header:
User-Agent: "gost/3.0"
foo: bar
心跳¶
客户端可以通过keepalive选项开启心跳,并通过ttl选项设置心跳包发送的间隔时长。
命令行
gost -L http://:8080 -F "wss://:8443?keepalive=true&ttl=15s"
配置文件
services:
- name: service-0
addr: :8080
handler:
type: http
chain: chain-0
listener:
type: tcp
chains:
- name: chain-0
hops:
- name: hop-0
nodes:
- name: node-0
addr: :8443
connector:
type: http
dialer:
type: wss
metadata:
keepalive: true
ttl: 15s
组合使用¶
Websocket数据通道可以与各种代理协议组合使用。
HTTP Over Websocket¶
命令行
gost -L http+wss://:8443
配置文件
services:
- name: service-0
addr: :8443
handler:
type: http
listener:
type: wss
# type: mwss
SOCKS5 Over Websocket¶
命令行
gost -L socks5+wss://:8443
配置文件
services:
- name: service-0
addr: :8443
handler:
type: socks5
listener:
type: wss
# type: mwss
Relay Over Websocket¶
命令行
配置文件
services:
- name: service-0
addr: :8443
handler:
type: relay
listener:
type: wss
# type: mwss
端口转发¶
Websocket通道也可以用作端口转发。
服务端¶
命令行
gost -L wss://:8443/:1080 -L socks5://:1080
等同于
gost -L forward+wss://:8443/:1080 -L socks5://:1080
配置文件
services:
- name: service-0
addr: :8443
handler:
type: forward
listener:
type: wss
forwarder:
nodes:
- name: target-0
addr: :1080
- name: service-1
addr: :1080
handler:
type: socks5
listener:
type: tcp
通过使用Websocket数据通道的端口转发,给1080端口的SOCKS5代理服务增加了Websocket数据通道。
此时8443端口等同于:
gost -L socks5+wss://:8443
-----------------------------------------------------------
gRPC¶
gRPC是GOST中的一种数据通道类型。
TLS证书配置
TLS配置请参考TLS配置说明。
使用TLS¶
gRPC通道默认采用TLS加密。
命令行
gost -L http+grpc://:8443
配置文件
services:
- name: service-0
addr: ":8443"
handler:
type: http
listener:
type: grpc
不使用TLS¶
通过grpcInsecure选项开启明文gRPC传输,不是TLS。
命令行
gost -L http+grpc://:8443?grpcInsecure=true
配置文件
services:
- name: service-0
addr: ":8443"
handler:
type: http
listener:
type: grpc
metadata:
grpcInsecure: true
自定义请求主机名¶
客户端默认使用节点地址(-F参数或nodes.addr中指定的地址)作为请求主机名(:authority头部信息),可以通过host参数自定义请求主机名。
命令行
gost -L http://:8080 -F grpc://:8443?host=example.com
配置文件
services:
- name: service-0
addr: :8080
handler:
type: http
chain: chain-0
listener:
type: tcp
chains:
- name: chain-0
hops:
- name: hop-0
nodes:
- name: node-0
addr: :8443
connector:
type: http
dialer:
type: grpc
metadata:
host: example.com
自定义请求路径¶
可以通过path选项自定义请求路径,默认值为/GostTunel/Tunnel。
路径匹配验证
仅当客户端和服务端设定的path参数相同时,连接才能成功建立。
服务端¶
命令行
gost -L grpc://:8443?path=/GostTunel/Tunnel
配置文件
services:
- name: service-0
addr: :8443
handler:
type: auto
listener:
type: grpc
metadata:
path: /GostTunel/Tunnel
客户端¶
命令行
gost -L http://:8080 -F grpc://:8443?path=/GostTunel/Tunnel
配置文件
services:
- name: service-0
addr: :8080
handler:
type: http
chain: chain-0
listener:
type: tcp
chains:
- name: chain-0
hops:
- name: hop-0
nodes:
- name: node-0
addr: :8443
connector:
type: http
dialer:
type: grpc
metadata:
path: /GostTunel/Tunnel
心跳¶
客户端和服务端可以分别通过若干选项来控制心跳的发送。
客户端¶
命令行
gost -L http://:8080 -F "grpc://:8443?keepalive=true&keepalive.time=30s&keepalive.timeout=30s&keepalive.permitWithoutStream=true"
配置文件
services:
- name: service-0
addr: :8080
handler:
type: http
chain: chain-0
listener:
type: tcp
chains:
- name: chain-0
hops:
- name: hop-0
nodes:
- name: node-0
addr: :8443
connector:
type: http
dialer:
type: grpc
metadata:
keepalive: true
keepalive.time: 30s
keepalive.timeout: 30s
keepalive.permitWithoutStream: true
服务端¶
命令行
gost -L "grpc://:8443?keepalive=true&keepalive.minTime=30s&keepalive.time=60s&keepalive.timeout=30s&keepalive.permitWithoutStream=true&keepalive.maxConnectionIdle=5m"
配置文件
services:
- name: service-0
addr: :8443
handler:
type: auto
listener:
type: grpc
metadata:
keepalive: true
keepalive.time: 60s
keepalive.timeout: 30s
keepalive.permitWithoutStream: true
keepalive.minTime: 30s
keepalive.maxConnectionIdle: 5m
keepalive (bool, default=false)
是否开启心跳,只有当此选项开启后,其他相关参数才有效。
keepalive.time (duration, default=30s)
当空闲时长超过此设定值后,发送心跳包。
keepalive.timeout (duration, default=30s)
等待心跳响应时长。
keepalive.permitWithoutStream (bool, default=false)
是否允许在空闲状态下也发送心跳包。注意:当客户端开启此选项后,服务端也应同时开启,否则服务端会强行关闭当前连接。
keepalive.minTime (duration, default=30s)
客户端在发送心跳包之前最小等待时长。仅服务端有效。
keepalive.maxConnectionIdle (duration, default=5m)
当连接空闲超过此设定时长后,连接将被关闭。仅服务端有效。
谨慎使用
gRPC的心跳机制需要客户端和服务端相互配合,如果参数设置有误可能会导致连接异常,建议在使用心跳之前先阅读官方文档。
代理协议¶
gRPC数据通道可以与各种代理协议组合使用。
HTTP Over gRPC¶
命令行
gost -L http+grpc://:8443
配置文件
services:
- name: service-0
addr: :8443
handler:
type: http
listener:
type: grpc
SOCKS5 Over gRPC¶
命令行
gost -L socks5+grpc://:8443
配置文件
services:
- name: service-0
addr: :8443
handler:
type: socks5
listener:
type: grpc
Relay Over gRPC¶
命令行
gost -L relay+grpc://:8443
配置文件
services:
- name: service-0
addr: :8443
handler:
type: relay
listener:
type: grpc
端口转发¶
gRPC通道也可以用作端口转发。
服务端¶
命令行
gost -L grpc://:8443/:1080 -L socks5://:1080
等同于
gost -L forward+grpc://:8443/:1080 -L socks5://:1080
配置文件
services:
- name: service-0
addr: :8443
handler:
type: forward
listener:
type: grpc
forwarder:
nodes:
- name: target-0
addr: :1080
- name: service-1
addr: :1080
handler:
type: socks5
listener:
type: tcp
通过使用gRPC数据通道的端口转发,给1080端口的SOCKS5代理服务增加了gRPC数据通道。
此时8443端口等同于:
gost -L socks5+grpc://:8443
-----------------------------------------------------------
QUIC¶
QUIC是GOST中的一种数据通道类型。QUIC的实现依赖于lucas-clemente/quic-go库。
TLS证书配置
TLS配置请参考TLS配置说明。
示例¶
命令行
gost -L http+quic://:8443
配置文件
services:
- name: service-0
addr: ":8443"
handler:
type: http
listener:
type: quic
心跳¶
客户端或服务端可以通过keepalive选项开启心跳,并通过ttl选项设置心跳包发送的间隔时长。
命令行
gost -L http://:8080 -F "quic://:8443?keepalive=true&ttl=10s"
配置文件
services:
- name: service-0
addr: :8080
handler:
type: http
chain: chain-0
listener:
type: tcp
chains:
- name: chain-0
hops:
- name: hop-0
nodes:
- name: node-0
addr: :8443
connector:
type: http
dialer:
type: quic
metadata:
keepalive: true
ttl: 10s
代理协议¶
QUIC数据通道可以与各种代理协议组合使用。
HTTP Over QUIC¶
命令行
gost -L http+quic://:8443
配置文件
services:
- name: service-0
addr: :8443
handler:
type: http
listener:
type: quic
QUIC与HTTP3
HTTP-over-QUIC并不是HTTP3,因此不能将一个HTTP-over-QUIC服务当作HTTP3服务使用。
SOCKS5 Over QUIC¶
命令行
gost -L socks5+quic://:8443
配置文件
services:
- name: service-0
addr: :8443
handler:
type: socks5
listener:
type: quic
Relay Over QUIC¶
命令行
gost -L relay+quic://:8443
配置文件
services:
- name: service-0
addr: :8443
handler:
type: relay
listener:
type: quic
端口转发¶
QUIC通道也可以用作端口转发。
服务端¶
命令行
gost -L quic://:8443/:1080 -L socks5://:1080
等同于
gost -L forward+quic://:8443/:1080 -L socks5://:1080
配置文件
services:
- name: service-0
addr: :8443
handler:
type: forward
listener:
type: quic
forwarder:
nodes:
- name: target-0
addr: :1080
- name: service-1
addr: :1080
handler:
type: socks5
listener:
type: tcp
通过使用QUIC数据通道的端口转发,给1080端口的SOCKS5代理服务增加了QUIC数据通道。
此时8443端口等同于:
gost -L socks5+quic://:8443
-----------------------------------------------------------
Plain HTTP Tunnel¶
PHT是GOST中的一种数据通道类型。
CONNECT方法并不是所有HTTP服务都支持,为了更加通用,GOST利用HTTP协议中更加常用的GET和POST方法来实现数据通道,包括加密的phts和明文的pht两种模式。
TLS证书配置
TLS配置请参考TLS配置说明。
不使用TLS¶
命令行
gost -L "http+pht://:8443?authorizePath=/authorize&pushPath=/push&pullPath=/pull"
配置文件
services:
- name: service-0
addr: ":8443"
handler:
type: http
listener:
type: pht
metadata:
authorizePath: /authorize
pushPath: /push
pullPath: /pull
使用TLS¶
PHT over LTS。
命令行
gost -L "http+phts://:8443?authorizePath=/authorize&pushPath=/push&pullPath=/pull"
配置文件
services:
- name: service-0
addr: ":8443"
handler:
type: http
listener:
type: phts
metadata:
authorizePath: /authorize
pushPath: /push
pullPath: /pull
自定义请求路径¶
PHT通道由三部分组成:
授权 - 客户端在与服务端进行数据传输前需要获取服务端的授权码,通过authorizePath选项设置请求的URI,默认值为/authorize。
接收数据 - 客户端从服务端获取数据,通过pullPath选项设置请求的URI,默认值为/pull。
发送数据 - 客户端发送数据到服务端,通过pushPath选项设置请求的URI,默认值为/push。
路径匹配验证
仅当客户端和服务端设定的path参数相同时,连接才能成功建立。
代理协议¶
PHT数据通道可以与各种代理协议组合使用。
HTTP Over PHT¶
命令行
gost -L http+pht://:8443
配置文件
services:
- name: service-0
addr: :8443
handler:
type: http
listener:
type: pht
# type: phts
SOCKS5 Over PHT¶
命令行
gost -L socks5+pht://:8443
配置文件
services:
- name: service-0
addr: :8443
handler:
type: socks5
listener:
type: pht
# type: phts
Relay Over PHT¶
命令行
gost -L relay+pht://:8443
配置文件
services:
- name: service-0
addr: :8443
handler:
type: relay
listener:
type: pht
# type: phts
端口转发¶
PHT通道也可以用作端口转发。
服务端¶
命令行
gost -L pht://:8443/:1080 -L socks5://:1080
等同于
gost -L forward+pht://:8443/:1080 -L socks5://:1080
配置文件
services:
- name: service-0
addr: :8443
handler:
type: forward
listener:
type: pht
# type: phts
forwarder:
nodes:
- name: target-0
addr: :1080
- name: service-1
addr: :1080
handler:
type: socks5
listener:
type: tcp
通过使用PHT数据通道的端口转发,给1080端口的SOCKS5代理服务增加了PHT数据通道。
此时8443端口等同于:
gost -L socks5+pht://:8443
-----------------------------------------------------------
KCP¶
KCP是GOST中的一种数据通道类型。KCP的实现依赖于xtaci/kcp-go库。
示例¶
命令行
gost -L kcp://:8443?c=/path/to/config/file
配置文件
services:
- name: service-0
addr: ":8443"
handler:
type: auto
listener:
type: kcp
metadata:
c: /path/to/config/file
配置¶
GOST中内置了一套默认的KCP配置项,默认值与xtaci/kcptun中的一致。可以通过参数c指定外部配置文件,配置文件为JSON格式:
{
"key": "it's a secrect",
"crypt": "aes",
"mode": "fast",
"mtu" : 1350,
"sndwnd": 1024,
"rcvwnd": 1024,
"datashard": 10,
"parityshard": 3,
"dscp": 0,
"nocomp": false,
"acknodelay": false,
"nodelay": 0,
"interval": 40,
"resend": 0,
"nc": 0,
"sockbuf": 4194304,
"keepalive": 10,
"snmplog": "",
"snmpperiod": 60,
"tcp": false
}
配置文件中的参数说明请参考kcptun。
代理协议¶
KCP数据通道可以与各种代理协议组合使用。
HTTP Over KCP¶
命令行
gost -L http+kcp://:8443
配置文件
services:
- name: service-0
addr: :8443
handler:
type: http
listener:
type: kcp
SOCKS5 Over KCP¶
命令行
gost -L socks5+kcp://:8443
配置文件
services:
- name: service-0
addr: :8443
handler:
type: socks5
listener:
type: kcp
Relay Over KCP¶
命令行
gost -L relay+kcp://:8443
配置文件
services:
- name: service-0
addr: :8443
handler:
type: relay
listener:
type: kcp
端口转发¶
KCP通道也可以用作端口转发,相当于在UDP端口转发服务基础上增加KCP传输协议。
服务端¶
命令行
gost -L kcp://:8443/:8080 -L ss://:8080
等同于
gost -L forward+kcp://:8443/:8080 -L ss://:8080
配置文件
services:
- name: service-0
addr: :8443
handler:
type: forward
listener:
type: kcp
forwarder:
nodes:
- name: target-0
addr: :8080
- name: service-1
addr: :8080
handler:
type: http
listener:
type: tcp
通过使用KCP数据通道的端口转发,给8080端口的Shadowsocks代理服务增加了KCP数据通道。
此时8443端口等同于:
gost -L ss+kcp://:8443
-----------------------------------------------------------
SSH¶
SSH是GOST中的一种数据通道类型。
SSH有两种模式:隧道模式和转发模式。
隧道模式¶
服务端
命令行
gost -L relay+ssh://:2222
配置文件
services:
- name: service-0
addr: :2222
handler:
type: relay
listener:
type: ssh
客户端
命令行
gost -L :8080 -F relay+ssh://:2222
配置文件(YAML)
services:
- name: service-0
addr: :8080
handler:
type: auto
chain: chain-0
listener:
type: tcp
chains:
- name: chain-0
hops:
- name: hop-0
nodes:
- name: node-0
addr: :2222
connector:
type: relay
dialer:
type: ssh
转发模式¶
采用标准SSH协议的端口转发功能,仅支持TCP。
服务端
命令行
gost -L sshd://:2222
配置文件(YAML)
services:
- name: service-0
addr: :
handler:
type: sshd
listener:
type: sshd
客户端
命令行
gost -L tcp://:8080/:80 -F sshd://:2222
配置文件(YAML)
services:
- name: service-0
addr: :8080
handler:
type: tcp
chain: chain-0
listener:
type: tcp
forwarder:
nodes:
- name: target-0
addr: :80
chains:
- name: chain-0
hops:
- name: hop-0
nodes:
- name: node-0
addr: :2222
connector:
type: sshd
dialer:
type: sshd
使用系统本身的SSH服务
在转发模式下服务端可以直接使用系统本身的SSH服务,例如Linux中的OpenSSH(sshd)服务。
认证¶
SSH支持用户名/密码认证和PubKey认证两种认证方式。
用户名/密码认证¶
认证信息作用对象
在命令行模式下,认证信息(user:pass)设置的是SSH通道的认证(Listener和Dialer),而非Handler和Connector。 此行为仅在使用ssh和sshd通道时有效。
服务端
命令行
gost -L relay+ssh://user:pass@:2222
或
gost -L sshd://user:pass@:2222
配置文件(YAML)
services:
- name: service-0
addr: :2222
handler:
type: relay
listener:
type: ssh
auth:
username: user
password: pass
客户端
命令行
gost -L :8080 -F relay+ssh://user:pass@:2222
或
gost -L tcp://:8080/:80 -F sshd://user:pass@:2222
配置文件(YAML)
services:
- name: service-0
addr: :8080
handler:
type: auto
chain: chain-0
listener:
type: tcp
chains:
- name: chain-0
hops:
- name: hop-0
nodes:
- name: node-0
addr: :2222
connector:
type: relay
dialer:
type: ssh
auth:
username: user
password: pass
PubKey认证¶
服务端
服务端通过authorizedKeys选项设置已授权客户端公钥列表。
命令行
gost -L "relay+ssh://:2222?authorizedKeys=/path/to/authorizedKeys"
或
gost -L "sshd://:2222?authorizedKeys=/path/to/authorizedKeys"
配置文件
services:
- name: service-0
addr: :2222
handler:
type: relay
listener:
type: ssh
metadata:
authorizedKeys: /path/to/authorizedKeys
客户端
客户端通过privateKeyFile和passphrase选项设置证书私钥和私钥密码。
命令行
gost -L :8080 -F "relay+ssh://:2222?privateKeyFile=/path/to/privateKeyFile&passphrase=123456"
或
gost -L tcp://:8080/:80 -F "sshd://:2222?privateKeyFile=/path/to/privateKeyFile&passphrase=123456"
配置文件(YAML)
services:
- name: service-0
addr: :8080
handler:
type: auto
chain: chain-0
listener:
type: tcp
chains:
- name: chain-0
hops:
- name: hop-0
nodes:
- name: node-0
addr: :2222
connector:
type: relay
dialer:
type: ssh
metadata:
privateKeyFile: /path/to/privateKeyFile
passphrase: "123456"
心跳¶
客户端通过keepalive选项开启心跳,并通过ttl选项设置心跳包发送的间隔时长(默认30s)。
也可以通过keepalive.timeout选项设置心跳超时时长(默认15s),keepalive.retries选项设置心跳发送重试次数(默认1次)
命令行
gost -L :8080 -F "relay+ssh://:2222?keepalive=true&ttl=30s"
或
gost -L tcp://:8080/:80 -F "sshd://:2222?keepalive=true&ttl=30s"
配置文件(YAML)
services:
- name: service-0
addr: :8080
handler:
type: auto
chain: chain-0
listener:
type: tcp
chains:
- name: chain-0
hops:
- name: hop-0
nodes:
- name: node-0
addr: :2222
connector:
type: relay
dialer:
type: ssh
metadata:
keepalive: true
ttl: 30s
keepalive.timeout: 15s
keepalive.retries: 1
组合使用¶
SSH数据通道的隧道模式可以与各种代理协议组合使用。
HTTP Over SSH¶
命令行
gost -L http+ssh://:2222
配置文件(YAML)
services:
- name: service-0
addr: :2222
handler:
type: http
listener:
type: ssh
SOCKS5 Over SSH¶
命令行
gost -L socks5+ssh://:2222
配置文件(YAML)
services:
- name: service-0
addr: :2222
handler:
type: socks5
listener:
type: ssh
Relay Over SSH¶
命令行
gost -L relay+ssh://:2222
配置文件(YAML)
services:
- name: service-0
addr: :8443
handler:
type: relay
listener:
type: ssh
端口转发¶
SSH通道的隧道模式也可以用作端口转发。
服务端
命令行
gost -L ssh://:2222/:1080 -L socks5://:1080
等同于
gost -L forward+ssh://:2222/:1080 -L socks5://:1080
配置文件
services:
- name: service-0
addr: :2222
handler:
type: forward
listener:
type: ssh
forwarder:
nodes:
- name: target-0
addr: :1080
- name: service-1
addr: :1080
handler:
type: socks5
listener:
type: tcp
通过使用SSH数据通道的端口转发,给1080端口的SOCKS5代理服务增加了SSH数据通道。
此时2222端口等同于:
gost -L socks5+ssh://:2222
-----------------------------------------------------------
MTCP¶
具有多路复用功能的TCP数据通道。多路复用基于xtaci/smux库。
用法¶
命令行
gost -L mtcp://:8000
配置文件
services:
- name: service-0
addr: :
handler:
type: auto
listener:
type: mtcp
metadata:
mux.version: 2
mux.keepaliveDisabled: false
mux.keepaliveInterval: 10s
mux.keepaliveTimeout: 30s
mux.maxFrameSize: 32768
mux.maxReceiveBuffer: 4194304
mux.maxStreamBuffer: 65536
参数说明
mux.version (int, default=1)
SMUX协议版本
mux.keepaliveDisabled (bool, default=false)
是否禁用心跳
mux.keepaliveInterval (duration, default=10s)
心跳间隔时长
mux.keepaliveTimeout (duration, default=30s)
心跳超时时长
mux.maxFrameSize (int, default=32768)
帧最大长度
mux.maxReceiveBuffer (int, default=4194304)
接收缓冲区大小
mux.maxStreamBuffer (int, default=65536)
Steam缓冲区大小
代理协议¶
MTCP数据通道可以与各种代理协议组合使用。
HTTP Over MTCP¶
命令行
gost -L http+mtcp://:8443
配置文件
services:
- name: service-0
addr: :8443
handler:
type: http
listener:
type: mtcp
SOCKS5 Over MTCP¶
命令行
gost -L socks5+mtcp://:8443
配置文件
services:
- name: service-0
addr: :8443
handler:
type: socks5
listener:
type: mtcp
Relay Over MTCP¶
命令行
gost -L relay+mtcp://:8443
配置文件
services:
- name: service-0
addr: :8443
handler:
type: relay
listener:
type: mtcp
端口转发¶
MTCP通道也可以用作端口转发。
服务端¶
命令行
gost -L mtcp://:8443/:8080 -L http://:8080
等同于
gost -L forward+mtcp://:8443/:8080 -L http://:8080
配置文件
services:
- name: service-0
addr: :8443
handler:
type: forward
listener:
type: mtcp
forwarder:
nodes:
- name: target-0
addr: :8080
- name: service-1
addr: :8080
handler:
type: http
listener:
type: tcp
-----------------------------------------------------------
GO Simple Tunnel
GO语言实现的安全隧道
功能特性
多端口监听
多级转发链
多协议支持
TCP/UDP端口转发
TCP/UDP透明代理
DNS解析和代理
TUN/TAP设备
反向代理
负载均衡
路由控制
限速限流
准入控制
动态配置
插件系统
Prometheus监控指标
Web API
Web UI
Telegram讨论群:https://t.me/gogost
Google讨论组:https://groups.google.com/d/forum/go-gost
提交Issue:https://github.com/go-gost/gost/issues
旧版入口:v2.gost.run
下载安装
二进制文件
https://github.com/go-gost/gost/releases
源码编译
git clone https://github.com/go-gost/gost.git
cd gost/cmd/gost
go build
Docker
docker run --rm gogost/gost -V
Shadowsocks Android插件
xausky/ShadowsocksGostPlugin
https://github.com/xausky/ShadowsocksGostPlugin
发表评论: