Skip to content

管理端命令

1. 直接运行后台管理

shell
./server

首次运行会自动配置文件,配置文件在server的所在目录下的data/config.yaml

config.yaml
# 后台管理监听的地址
address: 0.0.0.0:8080
auth-key: 44v7eu1y3afpmasf
auth-exp: 168h0m0s
auth-renew: 2h0m0s
# 数据库类型,默认sqlite
db-type: sqlite
sqlite:
    file: /usr/local/gostc-admin/data/data.db
    log-level: info
mysql:
    host: 127.0.0.1
    port: 3306
    db: table_name
    user: root
    pwd: root
    prefix: gostc_
    extend: ?timeout=3s&readTimeout=3s&writeTimeout=3s&parseTime=true&loc=Local&charset=utf8mb4,utf8
    log-level: info

2. 注册为系统服务

shell
./server service install

服务安装好后,可以使用以下命令启动/停止/卸载,系统服务会跟随随系统自启动

shell
# 启动服务
./server service start
# 停止服务
./server service stop
# 卸载服务
./server service uninstall

也可以使用systemctl进行管理

shell
# 启动服务
systemctl start gostc-admin
# 停止服务
systemctl stop gostc-admin

运行的参数在安装时配置,如果需要修改运行参数,需要先卸载服务,然后重新运行安装命令

节点命令

1. 直接运行命令

shell
./gostc -s -key {节点密钥}

2. 注册为系统服务

shell
./gostc install -s -key {节点密钥}

服务安装好后,可以使用以下命令启动/停止/卸载,系统服务会跟随随系统自启动

shell
# 启动服务
./gostc start
# 停止服务
./gostc stop
# 卸载服务
./gostc uninstall

也可以使用systemctl进行管理

shell
# 启动服务
systemctl start gostc
# 停止服务
systemctl stop gostc

运行的参数在安装时配置,如果需要修改运行参数,需要先卸载服务,然后重新运行安装命令

客户端命令

运行时,如果碰到权限问题,可以运行以下命令添加权限

shell
chmod +x gostc

1. 运行客户端

shell
./gostc -key {客户端密钥}

2. 运行私有隧道

shell
# 只运行一个私有隧道
./gostc -v -vts aaaaaa:8080

# 同时运行多个私有隧道
./gostc -v -vts aaaaaa:8080,bbbbbb:8081

命令说明: 将访问密钥为aaaaaa的私有隧道映射的内网服务,映射到本地的8080端口,访问本地的8080端口,就能访问到内网服务

3. 运行P2P隧道

shell
# 只运行一个P2P隧道
./gostc -p2p -vts aaaaaa:8080

# 同时运行多个P2P隧道
./gostc -p2p -vts aaaaaa:8080,bbbbbb:8081

命令说明: 将访问密钥为aaaaaa的P2P隧道映射的内网服务,映射到本地的8080端口,访问本地的8080端口,就能访问到内网服务

4. 运行WEB UI服务

使用WebUI需要在本地启动一个Web服务,使用WebUI可以方便的管理客户端、私有隧道、P2P隧道

shell
./gostc -web-addr 0.0.0.0:18080

命令说明: 在本地18080端口上,运行一个Web服务,访问127.0.0.1:18080进行管理

5. 从配置文件读取

cmd
./gostc -cfg /gostc/config.yaml
config.yaml
clients:
- key: 9f6c1103-2e2d-43ae-bf99-f99742adf11b # 客户端密钥
  remark: 客户端1 # 客户端备注
  tls: true # 后台管理地址,是否使用了SSL
  address: gost.sian.one # 后台管理地址
tunnels:
- key: 3aa6db10-e755-46d4-97f0-e65a9f2d61e6 # 私有隧道密钥
  bind: 127.0.0.1 # 本地绑定的地址
  port: 8080 # 本地监听端口
  remark: 私有隧道1
  tls: true
  address: gost.sian.one
p2ps:
- key: 76eed27a-3f34-45f5-94c7-8ef8a10ed63d # P2P隧道密钥
  bind: 0.0.0.0 127.0.0.1 # 本地绑定的地址
  port: 8081 # 本地监听端口
  remark: P2P隧道1
  tls: true
  address: gost.sian.one

6. 注册为系统服务,用来实现后台运行和开机自启

以上所有的命令都可以注册为系统服务

命令示例:

shell
# 将客户端安装为系统服务
./gostc install -key {客户端密钥}

# 将私有隧道安装为系统服务
./gostc install -v -vts aaaaaa:8080,bbbbbb:8081

# 将P2P隧道安装为系统服务
./gostc install -p2p -vts aaaaaa:8080,bbbbbb:8081

# 将WebUI服务安装为系统服务
./gostc install -web-addr 0.0.0.0:18080

# 读取配置文件的方式,注册为系统服务
./gostc install -cfg /gostc/config.yaml

服务安装好后,可以使用以下命令启动/停止/卸载,系统服务会跟随随系统自启动

shell
# 启动服务
./gostc start
# 停止服务
./gostc stop
# 卸载服务
./gostc uninstall

也可以使用systemctl进行管理

shell
# 启动服务
systemctl start gostc
# 停止服务
systemctl stop gostc

运行的参数在安装时配置,如果需要修改运行参数,需要先卸载服务,然后重新运行安装命令

注意事项

使用配置文件和webui时,不要同时运行客户端和该客户端的私有隧道,会冲突,导致无法正常使用