From f05e053bfc738c4d90bfb325a514b5e201981d1e Mon Sep 17 00:00:00 2001 From: lwch Date: Sat, 9 Oct 2021 15:33:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=86=E5=88=86=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build_all.go | 13 ++++++++++--- conf/client.yaml | 31 ++++--------------------------- conf/conf.d/conn.yaml | 5 +++++ conf/conf.d/log.yaml | 4 ++++ conf/server.yaml | 10 +--------- conf/tunnel.d/shell.yaml | 10 ++++++++++ conf/tunnel.d/tcp.yaml | 7 +++++++ 7 files changed, 41 insertions(+), 39 deletions(-) create mode 100644 conf/conf.d/conn.yaml create mode 100644 conf/conf.d/log.yaml create mode 100644 conf/tunnel.d/shell.yaml create mode 100644 conf/tunnel.d/tcp.yaml diff --git a/build_all.go b/build_all.go index cb40bc8..2daf602 100644 --- a/build_all.go +++ b/build_all.go @@ -88,9 +88,16 @@ func build(t target) { os.RemoveAll(buildDir) runtime.Assert(os.MkdirAll(buildDir, 0755)) - err := copyFile(path.Join("conf", "client.yaml"), path.Join(buildDir, "client.yaml")) - runtime.Assert(err) - err = copyFile(path.Join("conf", "server.yaml"), path.Join(buildDir, "server.yaml")) + err := filepath.Walk("conf", func(path string, info fs.FileInfo, err error) error { + if err != nil { + return err + } + path = strings.TrimPrefix(path, "conf") + if info.IsDir() { + return os.MkdirAll(filepath.Join(buildDir, path), 0755) + } + return copyFile("conf"+path, filepath.Join(buildDir, path)) + }) runtime.Assert(err) err = copyFile("CHANGELOG.md", path.Join(buildDir, "CHANGELOG.md")) runtime.Assert(err) diff --git a/conf/client.yaml b/conf/client.yaml index e6db24f..52090ec 100644 --- a/conf/client.yaml +++ b/conf/client.yaml @@ -1,29 +1,6 @@ id: this # 客户端ID server: 127.0.0.1:6154 # 服务器地址 -secret: 0123456789 # 预共享密钥,必须与server端相同,否则握手失败 -link: - connections: 3 # 与server的连接数 - read_timeout: 1s # 读取数据包超时时间 - write_timeout: 1s # 发送数据包超时时间 -log: - dir: ./logs # 路径 - size: 50M # 单个文件大小 - rotate: 7 # 保留数量 -tunnel: # 远端tunnel列表可为空 - - name: rdp # 链路名称 - target: that # 目标客户端ID - type: tcp # 连接类型tcp或udp - local_addr: 0.0.0.0 # 本地监听地址 - local_port: 3389 # 本地监听端口号 - remote_addr: 127.0.0.1 # 目标客户端连接地址 - remote_port: 3389 # 目标客户端连接端口号 - - name: shell # 链路名称 - target: that # 目标客户端ID - type: shell # web shell - local_addr: 0.0.0.0 # 本地监听地址 - local_port: 8080 # 本地监听端口号 - #exec: /bin/bash # 运行命令 - # windows默认powershell或cmd - # 其他系统bash或sh - env: # 环境变量设置 - - TERM=xterm \ No newline at end of file +#include conf.d/connection.yaml +#include conf.d/log.yaml +tunnel: # tunnel列表 + #include tunnel.d/*.yaml \ No newline at end of file diff --git a/conf/conf.d/conn.yaml b/conf/conf.d/conn.yaml new file mode 100644 index 0000000..c1eb316 --- /dev/null +++ b/conf/conf.d/conn.yaml @@ -0,0 +1,5 @@ +secret: 0123456789 # 预共享密钥,否则握手失败 +link: + connections: 3 # 连接数,仅client有效 + read_timeout: 1s # 读取数据包超时时间 + write_timeout: 1s # 发送数据包超时时间 \ No newline at end of file diff --git a/conf/conf.d/log.yaml b/conf/conf.d/log.yaml new file mode 100644 index 0000000..836bfd7 --- /dev/null +++ b/conf/conf.d/log.yaml @@ -0,0 +1,4 @@ +log: + dir: ./logs # 路径 + size: 50M # 单个文件大小 + rotate: 7 # 保留数量 \ No newline at end of file diff --git a/conf/server.yaml b/conf/server.yaml index 88c4fd0..c27a2f0 100644 --- a/conf/server.yaml +++ b/conf/server.yaml @@ -1,12 +1,4 @@ -listen: 6154 # 监听端口号 -secret: 0123456789 # 预共享密钥 -link: - read_timeout: 5s # 读取数据包超时时间 - write_timeout: 5s # 发送数据包超时时间 -log: - dir: ./logs # 路径 - size: 50M # 单个文件大小 - rotate: 7 # 保留数量 +listen: 6154 # 监听端口号 tls: key: /dir/to/tls/key/file # tls密钥 crt: /dir/to/tls/crt/file # tls证书 \ No newline at end of file diff --git a/conf/tunnel.d/shell.yaml b/conf/tunnel.d/shell.yaml new file mode 100644 index 0000000..12b4b09 --- /dev/null +++ b/conf/tunnel.d/shell.yaml @@ -0,0 +1,10 @@ +- name: shell # 链路名称 + target: that # 目标客户端ID + type: shell # web shell + local_addr: 0.0.0.0 # 本地监听地址 + local_port: 8080 # 本地监听端口号 + #exec: /bin/bash # 运行命令 + # windows默认powershell或cmd + # 其他系统bash或sh + env: # 环境变量设置 + - TERM=xterm \ No newline at end of file diff --git a/conf/tunnel.d/tcp.yaml b/conf/tunnel.d/tcp.yaml new file mode 100644 index 0000000..12663a3 --- /dev/null +++ b/conf/tunnel.d/tcp.yaml @@ -0,0 +1,7 @@ +- name: rdp # 链路名称 + target: that # 目标客户端ID + type: tcp # 连接类型tcp或udp + local_addr: 0.0.0.0 # 本地监听地址 + local_port: 3389 # 本地监听端口号 + remote_addr: 127.0.0.1 # 目标客户端连接地址 + remote_port: 3389 # 目标客户端连接端口号 \ No newline at end of file