From 3e9cccb86ec8f4b0d8a69bcc15e152f4ee786195 Mon Sep 17 00:00:00 2001 From: yisier <1340976576@qq.com> Date: Sat, 8 Aug 2026 20:13:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=AB=AF=E3=80=81=E9=9A=A7?= =?UTF-8?q?=E9=81=93=E3=80=81=E5=9F=9F=E5=90=8D=E8=A7=A3=E6=9E=90=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=8E=A5=E5=8F=A3=E6=94=AF=E6=8C=81=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=B5=81=E9=87=8F=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/changelog/index.md | 2 ++ docs/extend/webapi.md | 10 ++++++---- web/controllers/client.go | 6 ++++++ web/controllers/index.go | 12 ++++++++++++ 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/docs/changelog/index.md b/docs/changelog/index.md index f3902fd..1176341 100644 --- a/docs/changelog/index.md +++ b/docs/changelog/index.md @@ -2,6 +2,8 @@ - 2026-08-08 v0.26.37 - 修复: - NPC 安装到系统服务失败 BUG [#338](https://github.com/yisier/nps/issues/338) + - 新增: + - 客户端、隧道、域名解析修改接口支持修改流量数据 [#341](https://github.com/yisier/nps/issues/341) - 2026-07-12 v0.26.36 - 新增: diff --git a/docs/extend/webapi.md b/docs/extend/webapi.md index 5f63f83..00d4be2 100644 --- a/docs/extend/webapi.md +++ b/docs/extend/webapi.md @@ -103,6 +103,8 @@ POST /client/edit/ | ipwhitepass | IP 白名单授权密码 | | ipwhitelist | 白名单 IP 列表,`\r\n` 分隔 | | expire_time | 到期时间,格式同新增接口 | +| flow_inlet | 入口流量,单位字节,传入则覆盖原值(留空不修改) | +| flow_export | 出口流量,单位字节,传入则覆盖原值(留空不修改) | --- @@ -219,6 +221,8 @@ POST /index/edit/ | local_path | 本地文件路径 | | strip_pre | URL 前缀去除 | | proto_version | 协议版本 | +| flow_inlet | 入口流量,单位字节,传入则覆盖原值(留空不修改) | +| flow_export | 出口流量,单位字节,传入则覆盖原值(留空不修改) | --- @@ -331,10 +335,8 @@ POST /index/edithost/ | key_file_path | HTTPS 证书私钥文本或路径 | | cert_file_path | HTTPS 证书文件文本或路径 | | AutoHttps | 是否自动 HTTPS | - ---- - -### 停止域名解析 +| flow_inlet | 入口流量,单位字节,传入则覆盖原值(留空不修改) | +| flow_export | 出口流量,单位字节,传入则覆盖原值(留空不修改) | ``` POST /index/hoststop/ diff --git a/web/controllers/client.go b/web/controllers/client.go index dd13b9f..adc1dea 100644 --- a/web/controllers/client.go +++ b/web/controllers/client.go @@ -134,6 +134,12 @@ func (s *ClientController) Edit() { c.MaxConn = s.GetIntNoErr("max_conn") c.MaxTunnelNum = s.GetIntNoErr("max_tunnel") } + if s.GetString("flow_inlet") != "" { + c.Flow.InletFlow = int64(s.GetIntNoErr("flow_inlet")) + } + if s.GetString("flow_export") != "" { + c.Flow.ExportFlow = int64(s.GetIntNoErr("flow_export")) + } c.Remark = s.getEscapeString("remark") c.Cnf.U = s.getEscapeString("u") c.Cnf.P = s.getEscapeString("p") diff --git a/web/controllers/index.go b/web/controllers/index.go index 4032481..93488a0 100755 --- a/web/controllers/index.go +++ b/web/controllers/index.go @@ -233,6 +233,12 @@ func (s *IndexController) Edit() { t.StripPre = s.getEscapeString("strip_pre") t.Remark = s.getEscapeString("remark") t.Target.LocalProxy = s.GetBoolNoErr("local_proxy") + if s.GetString("flow_inlet") != "" { + t.Flow.InletFlow = int64(s.GetIntNoErr("flow_inlet")) + } + if s.GetString("flow_export") != "" { + t.Flow.ExportFlow = int64(s.GetIntNoErr("flow_export")) + } file.GetDb().UpdateTask(t) server.StopServer(t.Id) server.StartTask(t.Id) @@ -409,6 +415,12 @@ func (s *IndexController) EditHost() { h.AutoHttps = false } + if s.GetString("flow_inlet") != "" { + h.Flow.InletFlow = int64(s.GetIntNoErr("flow_inlet")) + } + if s.GetString("flow_export") != "" { + h.Flow.ExportFlow = int64(s.GetIntNoErr("flow_export")) + } file.GetDb().JsonDb.StoreHostToJsonFile() } s.AjaxOk("modified success")