mirror of
https://github.com/lwch/natpass
synced 2025-09-26 17:51:11 +08:00
客户端新增ssl的insecure支持
This commit is contained in:
@@ -133,4 +133,8 @@
|
||||
|
||||
1. go版本升级到1.18.4
|
||||
2. 新增code-server支持
|
||||
3. 优化disconnect处理逻辑
|
||||
3. 优化disconnect处理逻辑
|
||||
|
||||
# v0.10.1
|
||||
|
||||
修改客户端配置文件,新增ssl的insecure支持
|
2
build
2
build
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
VERSION=0.10.0
|
||||
VERSION=0.10.1
|
||||
|
||||
DOCKER_BUILDKIT=1 docker build -t natpass -f contrib/build/Dockerfile .
|
||||
docker run --rm \
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
VERSION=0.10.0
|
||||
VERSION=0.10.1
|
||||
|
||||
DOCKER_BUILDKIT=1 docker build -t natpass -f contrib/build/Dockerfile .
|
||||
docker run --rm \
|
||||
|
@@ -57,7 +57,22 @@ func (conn *Conn) connect() error {
|
||||
var dial net.Conn
|
||||
var err error
|
||||
if conn.cfg.UseSSL {
|
||||
dial, err = tls.Dial("tcp", conn.cfg.Server, nil)
|
||||
if conn.cfg.SSLInsecure {
|
||||
rawConn, err := net.Dial("tcp", conn.cfg.Server)
|
||||
if err != nil {
|
||||
logging.Error("raw dial: %v", err)
|
||||
return err
|
||||
}
|
||||
cfg := new(tls.Config)
|
||||
cfg.InsecureSkipVerify = true
|
||||
dial = tls.Client(rawConn, cfg)
|
||||
err = dial.(*tls.Conn).Handshake()
|
||||
if err != nil {
|
||||
rawConn.Close()
|
||||
}
|
||||
} else {
|
||||
dial, err = tls.Dial("tcp", conn.cfg.Server, nil)
|
||||
}
|
||||
} else {
|
||||
dial, err = net.Dial("tcp", conn.cfg.Server)
|
||||
}
|
||||
|
@@ -31,6 +31,7 @@ type Configure struct {
|
||||
ID string
|
||||
Server string
|
||||
UseSSL bool
|
||||
SSLInsecure bool
|
||||
Enc [md5.Size]byte
|
||||
Links int
|
||||
LogDir string
|
||||
@@ -51,8 +52,11 @@ func LoadConf(dir string) *Configure {
|
||||
ID string `yaml:"id"`
|
||||
Server string `yaml:"server"`
|
||||
Secret string `yaml:"secret"`
|
||||
SSL bool `yaml:"ssl"`
|
||||
Link struct {
|
||||
SSL struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
Insecure bool `yaml:"insecure"`
|
||||
} `yaml:"ssl"`
|
||||
Link struct {
|
||||
ReadTimeout time.Duration `yaml:"read_timeout"`
|
||||
WriteTimeout time.Duration `yaml:"write_timeout"`
|
||||
} `yaml:"link"`
|
||||
@@ -97,7 +101,8 @@ func LoadConf(dir string) *Configure {
|
||||
return &Configure{
|
||||
ID: cfg.ID,
|
||||
Server: cfg.Server,
|
||||
UseSSL: cfg.SSL,
|
||||
UseSSL: cfg.SSL.Enabled,
|
||||
SSLInsecure: cfg.SSL.Insecure,
|
||||
Enc: md5.Sum([]byte(cfg.Secret)),
|
||||
ReadTimeout: cfg.Link.ReadTimeout,
|
||||
WriteTimeout: cfg.Link.WriteTimeout,
|
||||
|
@@ -1,6 +1,8 @@
|
||||
id: local # 客户端ID
|
||||
server: 127.0.0.1:6154 # 服务器地址
|
||||
ssl: false # 是否使用tls加密连接
|
||||
ssl:
|
||||
enabled: false # 是否使用tls连接
|
||||
insecure: false # 是否关闭SNI,若使用自签证书可将其设置为true
|
||||
dashboard: # web面板
|
||||
enabled: true # 是否开放dashboard
|
||||
listen: 0.0.0.0 # 监听地址
|
||||
|
@@ -1,6 +1,8 @@
|
||||
id: remote # 客户端ID
|
||||
server: 127.0.0.1:6154 # 服务器地址
|
||||
ssl: false # 是否使用tls加密连接
|
||||
ssl:
|
||||
enabled: false # 是否使用tls连接
|
||||
insecure: false # 是否关闭SNI,若使用自签证书可将其设置为true
|
||||
dashboard: # web面板
|
||||
enabled: false # 是否开放dashboard
|
||||
#include common.yaml
|
||||
|
@@ -36,13 +36,13 @@
|
||||
1. 建议使用tls加密连接,使用方式如下
|
||||
|
||||
- 修改服务器端的server.yaml文件,配置tls相关文件路径,并重启服务
|
||||
- 修改受控端的remote.yaml配置,将ssl设置为true,并重启服务
|
||||
- 修改控制端的local.yaml配置,将ssl设置为true,并重启服务
|
||||
- 修改受控端的remote.yaml配置,配置ssl相关选项,并重启服务
|
||||
- 修改控制端的local.yaml配置,配置ssl相关选项,并重启服务
|
||||
|
||||
2. 修改默认连接密钥,修改方式如下
|
||||
|
||||
- 使用以下命令生成一个16位随机串
|
||||
tr -dc A-Za-z0-9 < /dev/urandom|dd bs=16 count=1 2>/dev/null
|
||||
tr -dc A-Za-z0-9 < /dev/urandom | dd bs=16 count=1 2>/dev/null && echo
|
||||
- 修改服务器端的common.yaml文件,将secret设置为新的密钥,并重启服务
|
||||
- 修改受控端的common.yaml文件,将secret设置为新的密钥,并重启服务
|
||||
- 修改控制端的common.yaml文件,将secret设置为新的密钥,并重启服务
|
||||
|
Reference in New Issue
Block a user