diff --git a/README.md b/README.md
index 75f3e2bb..b46c380a 100644
--- a/README.md
+++ b/README.md
@@ -20,6 +20,11 @@
## 更新日志
+- 2024-01-31 v0.26.18
+ ***新增***:nps.conf 新增 `tls_bridge_port=8025` 参数,当 `tls_enable=true` 时,nps 会监听8025端口,作为 tls 的连接端口。
+ 客户端可以选择连接 tls 端口或者非 tls 端口: `npc.exe -server=xxx:8024 -vkey=xxx` 或 `npc.exe -server=xxx:8025 -vkey=xxx -tls_enable=true`
+
+
- 2024-01-31 v0.26.17
***说明***:考虑到 npc 历史版本客户端众多,版本号不同旧版本客户端无法连接,为了兼容,仓库版本号将继续沿用 0.26.xx
diff --git a/bridge/bridge.go b/bridge/bridge.go
index ee9845e6..4f662d6a 100755
--- a/bridge/bridge.go
+++ b/bridge/bridge.go
@@ -80,21 +80,37 @@ func (s *Bridge) StartTunnel() error {
s.cliProcess(conn.NewConn(c))
})
} else {
- listener, err := connection.GetBridgeListener(s.tunnelType)
- if err != nil {
- logs.Error(err)
- os.Exit(0)
- return err
- }
- conn.Accept(listener, func(c net.Conn) {
- // tls
- if ServerTlsEnable {
- s.cliProcess(conn.NewConn(tls.Server(c, &tls.Config{Certificates: []tls.Certificate{crypt.GetCert()}})))
- } else {
- s.cliProcess(conn.NewConn(c))
+ go func() {
+ listener, err := connection.GetBridgeListener(s.tunnelType)
+ if err != nil {
+ logs.Error(err)
+ os.Exit(0)
+ return
}
- })
+ conn.Accept(listener, func(c net.Conn) {
+ s.cliProcess(conn.NewConn(c))
+ })
+ }()
+
+ // tls
+ if ServerTlsEnable {
+ go func() {
+ // 监听TLS 端口
+ tlsBridgePort := beego.AppConfig.DefaultInt("tls_bridge_port", 8025)
+
+ logs.Info("tls server start, the bridge type is %s, the tls bridge port is %d", "tcp", tlsBridgePort)
+ tlsListener, tlsErr := net.ListenTCP("tcp", &net.TCPAddr{net.ParseIP(beego.AppConfig.String("bridge_ip")), tlsBridgePort, ""})
+ if tlsErr != nil {
+ logs.Error(tlsErr)
+ os.Exit(0)
+ return
+ }
+ conn.Accept(tlsListener, func(c net.Conn) {
+ s.cliProcess(conn.NewConn(tls.Server(c, &tls.Config{Certificates: []tls.Certificate{crypt.GetCert()}})))
+ })
+ }()
+ }
}
return nil
}
diff --git a/build.sh b/build.sh
index 7a3e0784..24a78794 100755
--- a/build.sh
+++ b/build.sh
@@ -1,5 +1,5 @@
#/bash/sh
-export VERSION=0.26.17
+export VERSION=0.26.18
export GOPROXY=direct
sudo apt-get update
diff --git a/conf/nps.conf b/conf/nps.conf
index 195e0e0a..281d952f 100755
--- a/conf/nps.conf
+++ b/conf/nps.conf
@@ -98,4 +98,5 @@ open_captcha=false
# 是否开启tls
-tls_enable=true
\ No newline at end of file
+tls_enable=true
+tls_bridge_port=8025
\ No newline at end of file
diff --git a/lib/version/version.go b/lib/version/version.go
index b8d5cf66..fccb54ba 100644
--- a/lib/version/version.go
+++ b/lib/version/version.go
@@ -1,6 +1,6 @@
package version
-const VERSION = "0.26.17"
+const VERSION = "0.26.18"
// Compulsory minimum version, Minimum downward compatibility to this version
func GetVersion() string {
diff --git a/web/controllers/base.go b/web/controllers/base.go
index 00b42576..244838a0 100755
--- a/web/controllers/base.go
+++ b/web/controllers/base.go
@@ -1,6 +1,7 @@
package controllers
import (
+ "ehang.io/nps/bridge"
"html"
"math"
"strconv"
@@ -83,7 +84,17 @@ func (s *BaseController) display(tpl ...string) {
if common.IsWindows() {
s.Data["win"] = ".exe"
}
- s.Data["p"] = server.Bridge.TunnelPort
+
+ s.Data["p"] = strconv.Itoa(server.Bridge.TunnelPort)
+
+ if bridge.ServerTlsEnable {
+ tlsPort := strconv.Itoa(beego.AppConfig.DefaultInt("tls_bridge_port", 8025))
+ s.Data["tls_p"] = tlsPort
+ s.Data["p1"] = strconv.Itoa(server.Bridge.TunnelPort) + " / " + tlsPort
+ } else {
+ s.Data["p1"] = strconv.Itoa(server.Bridge.TunnelPort)
+ }
+
s.Data["proxyPort"] = beego.AppConfig.String("hostPort")
s.Layout = "public/layout.html"
s.TplName = tplname
diff --git a/web/static/js/language.js b/web/static/js/language.js
index 9f614bb3..c7bd88e5 100644
--- a/web/static/js/language.js
+++ b/web/static/js/language.js
@@ -59,7 +59,7 @@
$.fn.cloudLang = function () {
$.ajax({
type: 'GET',
- url: window.nps.web_base_url + '/static/page/languages.xml',
+ url: window.nps.web_base_url + '/static/page/languages.xml?v=20240227',
dataType: 'xml',
success: function (xml) {
languages['content'] = xml2json($(xml).children())['content'];
diff --git a/web/static/page/languages.xml b/web/static/page/languages.xml
index 8a5e8931..6c5d7598 100644
--- a/web/static/page/languages.xml
+++ b/web/static/page/languages.xml
@@ -193,6 +193,13 @@
客户端命令
Command
+
+ TLS 启动命令
+ TLS Command
+
+
+
+
压缩
Compress
diff --git a/web/views/client/list.html b/web/views/client/list.html
index 0c9e1416..1e263308 100644
--- a/web/views/client/list.html
+++ b/web/views/client/list.html
@@ -72,7 +72,8 @@
+ ':
'
+ ': ' + row.BlackIpList + '
'
+ ': ' + row.LastOnlineTime + '
'
- + ': ' + "./npc{{.win}} -server={{.ip}}:{{.p}} -vkey=" + row.VerifyKey + " -type=" +{{.bridgeType}} +"
"
+ + ': ' + "./npc{{.win}} -server={{.ip}}:{{.p}} -vkey=" + row.VerifyKey + " -type=" +{{.bridgeType}} +"
"
+ + ': ' + "./npc{{.win}} -server={{.ip}}:{{.tls_p}} -vkey=" + row.VerifyKey + " -tls_enable=true
"
},
//表格的列
columns: [
diff --git a/web/views/index/index.html b/web/views/index/index.html
index ebfbe4d9..8646472f 100644
--- a/web/views/index/index.html
+++ b/web/views/index/index.html
@@ -6,7 +6,7 @@
-
{{.p}}
+ {{.p1}}