diff --git a/README.md b/README.md index 5cf61d9..800d156 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,15 @@ https://natnps.com/ ## 更新日志 +- 2025-04-11 v0.26.24 + 新增: + - TCP 隧道支持复制功能,在【TCP隧道】页面增加复制按钮,除了端口号为随机生成外,其他参数全部拷贝。[251](https://github.com/yisier/nps/issues/251) + + 修复: + - 私密代理连接时服务端会报错退出,[250](https://github.com/yisier/nps/issues/250) + + + - 2025-04-11 v0.26.23 新增: - TCP 隧道支持 Proxy Protocol 协议来传递经过请求的真实 IP。![img.png](image/new/protocol.png) diff --git a/build.sh b/build.sh index 6340331..4234f32 100755 --- a/build.sh +++ b/build.sh @@ -1,5 +1,5 @@ #/bash/sh -export VERSION=0.26.23 +export VERSION=0.26.24 export GOPROXY=direct sudo apt-get update diff --git a/lib/version/version.go b/lib/version/version.go index d69e929..423bdac 100644 --- a/lib/version/version.go +++ b/lib/version/version.go @@ -1,6 +1,6 @@ package version -const VERSION = "0.26.23" +const VERSION = "0.26.24" // Compulsory minimum version, Minimum downward compatibility to this version func GetVersion() string { diff --git a/server/proxy/base.go b/server/proxy/base.go index 27640f0..5f33f65 100644 --- a/server/proxy/base.go +++ b/server/proxy/base.go @@ -109,7 +109,12 @@ func (s *BaseServer) DealClient(c *conn.Conn, client *file.Client, addr string, return nil } - link := conn.NewLink(tp, addr, client.Cnf.Crypt, client.Cnf.Compress, c.Conn.RemoteAddr().String(), localProxy, task.ProtoVersion) + protoVersion := "" + if task != nil { + protoVersion = task.ProtoVersion + } + + link := conn.NewLink(tp, addr, client.Cnf.Crypt, client.Cnf.Compress, c.Conn.RemoteAddr().String(), localProxy, protoVersion) if target, err := s.bridge.SendLinkInfo(client.Id, link, s.task); err != nil { logs.Warn("get connection from client id %d error %s", client.Id, err.Error()) c.Close() diff --git a/web/controllers/index.go b/web/controllers/index.go index fdd9a3a..2c335ce 100755 --- a/web/controllers/index.go +++ b/web/controllers/index.go @@ -132,6 +132,53 @@ func (s *IndexController) Add() { } } } + +func (s *IndexController) Copy() { + oldId := s.GetIntNoErr("id") + if oldTask, err := file.GetDb().GetTask(oldId); err != nil { + s.error() + } else { + if client, err := file.GetDb().GetClient(oldTask.Client.Id); err != nil { + s.AjaxErr("modified error,the client is not exist") + return + } else { + oldTask.Client = client + } + + id := int(file.GetDb().JsonDb.GetTaskId()) + newTask := &file.Tunnel{ + Client: oldTask.Client, + Port: tool.GenerateServerPort(oldTask.Mode), + ServerIp: oldTask.ServerIp, + Mode: oldTask.Mode, + Target: oldTask.Target, + Id: id, + Status: true, + Remark: oldTask.Remark, + Password: oldTask.Password, + LocalPath: oldTask.LocalPath, + StripPre: oldTask.StripPre, + ProtoVersion: oldTask.ProtoVersion, + Flow: &file.Flow{}, + } + if !tool.TestServerPort(newTask.Port, newTask.Mode) { + s.AjaxErr("The port cannot be opened because it may has been occupied or is no longer allowed.") + } + + if newTask.Client.MaxTunnelNum != 0 && newTask.Client.GetTunnelNum() >= newTask.Client.MaxTunnelNum { + s.AjaxErr("The number of tunnels exceeds the limit") + } + if err := file.GetDb().NewTask(newTask); err != nil { + s.AjaxErr(err.Error()) + } + if err := server.AddTask(newTask); err != nil { + s.AjaxErr(err.Error()) + } else { + s.AjaxOkWithId("add success", id) + } + } +} + func (s *IndexController) GetOneTunnel() { id := s.GetIntNoErr("id") data := make(map[string]interface{}) diff --git a/web/static/js/language.js b/web/static/js/language.js index af5bd34..595bc73 100644 --- a/web/static/js/language.js +++ b/web/static/js/language.js @@ -144,6 +144,7 @@ function submitform(action, url, postdata) { case 'start': case 'stop': case 'delete': + case 'copy': var langobj = languages['content']['confirm'][action]; action = (langobj[languages['current']] || langobj[languages['default']] || 'Are you sure you want to ' + action + ' it?'); if (! confirm(action)) return; diff --git a/web/static/page/languages.xml b/web/static/page/languages.xml index d65cc24..6b3958b 100644 --- a/web/static/page/languages.xml +++ b/web/static/page/languages.xml @@ -189,6 +189,10 @@ 访问端命令 Access command + + Proxy Protocol Version + Proxy Protocol Version + 快捷启动命令 @@ -775,6 +779,10 @@ 你确定你要停止它吗? Are you sure you want to stop it? + + 你确定要复制它吗? + Are you sure you want to copy it? + diff --git a/web/views/index/add.html b/web/views/index/add.html index 044c53b..da15775 100644 --- a/web/views/index/add.html +++ b/web/views/index/add.html @@ -34,7 +34,7 @@
- @@ -187,7 +187,7 @@ var option = "