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