Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de4111df21 | ||
|
|
a8817ede54 | ||
|
|
b86380e506 | ||
|
|
b2a6c66439 | ||
|
|
a48785b7aa | ||
|
|
b4362a68fc | ||
|
|
103b96eb19 | ||
|
|
e093e38c17 | ||
|
|
a3a801370b | ||
|
|
bb9b4501c2 | ||
|
|
492c259568 | ||
|
|
c5efa76623 | ||
|
|
b44cd17324 | ||
|
|
acf7f297f0 |
+1
-1
@@ -1,4 +1,4 @@
|
||||
FROM golang:1.22 as builder
|
||||
FROM golang:1.24 as builder
|
||||
ARG GOPROXY=direct
|
||||
WORKDIR /go/src/ehang.io/nps
|
||||
COPY . .
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
FROM golang:1.22 as builder
|
||||
FROM golang:1.24 as builder
|
||||
ARG GOPROXY=direct
|
||||
WORKDIR /go/src/ehang.io/nps
|
||||
COPY . .
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# NPS
|
||||
|
||||
[README](https://github.com/ehang-io/nps/blob/master/README.md)|[中文文档](https://github.com/ehang-io/nps/blob/master/README_zh.md)
|
||||
[新特性文档](https://dqg9t9eulqq.feishu.cn/wiki/FmVVwDcEGiTZxekYJl5ccuFanlg?from=from_copylink)
|
||||
|
||||
# 说明
|
||||
由于nps已经有二年多的时间没有更新了,存留了不少bug和未完善的功能。
|
||||
由于nps已经停更多年,存留了不少bug和未完善的功能。
|
||||
|
||||
此版本基于 nps 0.26.10的基础上二次开发而来。
|
||||
|
||||
@@ -27,6 +27,22 @@ https://natnps.com/
|
||||
|
||||
|
||||
# 更新日志
|
||||
- 2025-12-06 v0.26.28
|
||||
-【全局参数】页面新增`服务地址`配置项,用于客户端命令地址显示、隧道访问地址显示 [293](https://github.com/yisier/nps/issues/293)
|
||||
-【IP授权功能优化】,通过穿透的端口去提交 IP 认证,感谢 [Aqamoe](https://github.com/Aqamoe) 的建议 [291](https://github.com/yisier/nps/issues/291)
|
||||
-【重构限速器实现】提升性能和准确性
|
||||
|
||||
|
||||
- 2025-11-05 v0.26.27
|
||||
新增:
|
||||
- 1.客户端新增【IP白名单】,可通过两种方式添加IP:
|
||||
- 方式1️⃣:在【客户端】新建/修改页面,配置IP授权密码,不在IP白名单的外网访问将被跳转到 IP 授权页面,输入正确的授权密码,即可完成添加 IP。
|
||||
- 方式2️⃣:在【客户端】新建/修改页面,直接添加IP到白名单中。
|
||||

|
||||
- 2.客户端配置移除【压缩】和【加密】功能,此功能会显著提高内存和CPU占用率,"利大于弊"。
|
||||
- 3.客户端默认不再提供配置文件,***强烈推荐使用无配置文件模式启动客户端***
|
||||
|
||||
|
||||
- 2025-08-15 v0.26.26
|
||||
修复:
|
||||
- windows注册服务 使用tls无法连接 [269](https://github.com/yisier/nps/issues/269)
|
||||
|
||||
+17
-17
@@ -8,79 +8,79 @@ tar -czvf npc_sdk.tar.gz npc_sdk.dll npc_sdk.so npc_sdk.h
|
||||
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
|
||||
tar -czvf linux_amd64_client.tar.gz npc conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf linux_amd64_client.tar.gz npc
|
||||
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
|
||||
tar -czvf linux_386_client.tar.gz npc conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf linux_386_client.tar.gz npc
|
||||
|
||||
CGO_ENABLED=0 GOOS=freebsd GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
|
||||
tar -czvf freebsd_386_client.tar.gz npc conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf freebsd_386_client.tar.gz npc
|
||||
|
||||
CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
|
||||
tar -czvf freebsd_amd64_client.tar.gz npc conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf freebsd_amd64_client.tar.gz npc
|
||||
|
||||
CGO_ENABLED=0 GOOS=freebsd GOARCH=arm go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
|
||||
tar -czvf freebsd_arm_client.tar.gz npc conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf freebsd_arm_client.tar.gz npc
|
||||
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
|
||||
tar -czvf linux_arm_v7_client.tar.gz npc conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf linux_arm_v7_client.tar.gz npc
|
||||
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
|
||||
tar -czvf linux_arm_v6_client.tar.gz npc conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf linux_arm_v6_client.tar.gz npc
|
||||
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=5 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
|
||||
tar -czvf linux_arm_v5_client.tar.gz npc conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf linux_arm_v5_client.tar.gz npc
|
||||
|
||||
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
|
||||
tar -czvf linux_arm64_client.tar.gz npc conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf linux_arm64_client.tar.gz npc
|
||||
|
||||
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
|
||||
tar -czvf linux_mips64_client.tar.gz npc conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf linux_mips64_client.tar.gz npc
|
||||
|
||||
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=mips64le go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
|
||||
tar -czvf linux_mips64le_client.tar.gz npc conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf linux_mips64le_client.tar.gz npc
|
||||
|
||||
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=mipsle go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
|
||||
tar -czvf linux_mipsle_client.tar.gz npc conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf linux_mipsle_client.tar.gz npc
|
||||
|
||||
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=mips go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
|
||||
tar -czvf linux_mips_client.tar.gz npc conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf linux_mips_client.tar.gz npc
|
||||
|
||||
|
||||
CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
|
||||
tar -czvf windows_386_client.tar.gz npc.exe conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf windows_386_client.tar.gz npc.exe
|
||||
|
||||
|
||||
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
|
||||
tar -czvf windows_amd64_client.tar.gz npc.exe conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf windows_amd64_client.tar.gz npc.exe
|
||||
|
||||
|
||||
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
|
||||
tar -czvf darwin_amd64_client.tar.gz npc conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf darwin_amd64_client.tar.gz npc
|
||||
|
||||
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
|
||||
tar -czvf darwin_arm64_client.tar.gz npc conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf darwin_arm64_client.tar.gz npc
|
||||
|
||||
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#/bash/sh
|
||||
export VERSION=0.26.25
|
||||
export VERSION=0.26.28
|
||||
export GOPROXY=direct
|
||||
|
||||
sudo apt-get update
|
||||
@@ -13,71 +13,71 @@ tar -xvf upx-3.95-amd64_linux.tar.xz
|
||||
cp upx-3.95-amd64_linux/upx ./
|
||||
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
tar -czvf linux_amd64_client.tar.gz npc conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf linux_amd64_client.tar.gz npc
|
||||
|
||||
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
tar -czvf linux_386_client.tar.gz npc conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf linux_386_client.tar.gz npc
|
||||
|
||||
|
||||
CGO_ENABLED=0 GOOS=freebsd GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
tar -czvf freebsd_386_client.tar.gz npc conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf freebsd_386_client.tar.gz npc
|
||||
|
||||
|
||||
CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
tar -czvf freebsd_amd64_client.tar.gz npc conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf freebsd_amd64_client.tar.gz npc
|
||||
|
||||
|
||||
CGO_ENABLED=0 GOOS=freebsd GOARCH=arm go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
tar -czvf freebsd_arm_client.tar.gz npc conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf freebsd_arm_client.tar.gz npc
|
||||
|
||||
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
tar -czvf linux_arm_v7_client.tar.gz npc conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf linux_arm_v7_client.tar.gz npc
|
||||
|
||||
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
tar -czvf linux_arm_v6_client.tar.gz npc conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf linux_arm_v6_client.tar.gz npc
|
||||
|
||||
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=5 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
tar -czvf linux_arm_v5_client.tar.gz npc conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf linux_arm_v5_client.tar.gz npc
|
||||
|
||||
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
tar -czvf linux_arm64_client.tar.gz npc conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf linux_arm64_client.tar.gz npc
|
||||
|
||||
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
tar -czvf linux_mips64_client.tar.gz npc conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf linux_mips64_client.tar.gz npc
|
||||
|
||||
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=mips64le go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
tar -czvf linux_mips64le_client.tar.gz npc conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf linux_mips64le_client.tar.gz npc
|
||||
|
||||
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=mipsle go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
tar -czvf linux_mipsle_client.tar.gz npc conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf linux_mipsle_client.tar.gz npc
|
||||
|
||||
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=mips go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
tar -czvf linux_mips_client.tar.gz npc conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf linux_mips_client.tar.gz npc
|
||||
|
||||
|
||||
CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
tar -czvf windows_386_client.tar.gz npc.exe conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf windows_386_client.tar.gz npc.exe
|
||||
|
||||
|
||||
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
tar -czvf windows_amd64_client.tar.gz npc.exe conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf windows_amd64_client.tar.gz npc.exe
|
||||
|
||||
|
||||
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
tar -czvf darwin_amd64_client.tar.gz npc conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf darwin_amd64_client.tar.gz npc
|
||||
|
||||
|
||||
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
|
||||
tar -czvf darwin_arm64_client.tar.gz npc conf/npc.conf conf/multi_account.conf
|
||||
tar -czvf darwin_arm64_client.tar.gz npc
|
||||
|
||||
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go
|
||||
|
||||
+1
-1
@@ -430,7 +430,7 @@ func run() {
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
logs.Info("日志路径111:" + *npsLogPath)
|
||||
logs.Info("日志路径:" + *npsLogPath)
|
||||
logs.Info("the config path is:" + common.GetRunPath())
|
||||
logs.Info("the version of server is %s ,allow client core version to be %s,tls enable is %t", version.VERSION, version.GetVersion(), bridge.ServerTlsEnable)
|
||||
connection.InitConnectionService()
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
module ehang.io/nps
|
||||
|
||||
go 1.22
|
||||
go 1.24.0
|
||||
|
||||
toolchain go1.24.9
|
||||
|
||||
require (
|
||||
fyne.io/fyne/v2 v2.0.2
|
||||
@@ -17,6 +19,7 @@ require (
|
||||
github.com/shirou/gopsutil/v3 v3.23.10
|
||||
github.com/xtaci/kcp-go v5.4.20+incompatible
|
||||
golang.org/x/net v0.23.0
|
||||
golang.org/x/time v0.14.0
|
||||
)
|
||||
|
||||
require (
|
||||
|
||||
@@ -234,6 +234,8 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI=
|
||||
golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 42 KiB |
@@ -34,5 +34,8 @@ WWW-Authenticate: Basic realm="easyProxy"
|
||||
401 Unauthorized`
|
||||
ConnectionFailBytes = `HTTP/1.1 404 Not Found
|
||||
|
||||
`
|
||||
Unauthorized = `HTTP/1.1 401 Unauthorized
|
||||
|
||||
`
|
||||
)
|
||||
|
||||
@@ -310,6 +310,17 @@ func IsBlackIp(ipPort, vkey string, blackIpList []string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// 判断访问地址是否在白名单内
|
||||
func IsAuthIp(ipPort, vkey string, authIpList []string) bool {
|
||||
ip := GetIpByAddr(ipPort)
|
||||
|
||||
if in(ip, authIpList) {
|
||||
return false
|
||||
}
|
||||
logs.Error("IP地址[" + ip + "]不在隧道[" + vkey + "]白名单列表内")
|
||||
return true
|
||||
}
|
||||
|
||||
func CopyBuffer(dst io.Writer, src io.Reader, label ...string) (written int64, err error) {
|
||||
buf := CopyBuff.Get()
|
||||
defer CopyBuff.Put(buf)
|
||||
|
||||
+21
-2
@@ -1,6 +1,7 @@
|
||||
package file
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
@@ -221,7 +222,7 @@ reset:
|
||||
c.VerifyKey = crypt.GetVkey()
|
||||
}
|
||||
if c.RateLimit == 0 {
|
||||
c.Rate = rate.NewRate(int64(2 << 23))
|
||||
c.Rate = rate.NewRate((2 << 23) * 1024)
|
||||
} else if c.Rate == nil {
|
||||
c.Rate = rate.NewRate(int64(c.RateLimit * 1024))
|
||||
}
|
||||
@@ -272,7 +273,7 @@ func (s *DbUtils) VerifyUserName(username string, id int) (res bool) {
|
||||
func (s *DbUtils) UpdateClient(t *Client) error {
|
||||
s.JsonDb.Clients.Store(t.Id, t)
|
||||
if t.RateLimit == 0 {
|
||||
t.Rate = rate.NewRate(int64(2 << 23))
|
||||
t.Rate = rate.NewRate(0)
|
||||
t.Rate.Start()
|
||||
}
|
||||
return nil
|
||||
@@ -317,6 +318,24 @@ func (s *DbUtils) GetClientIdByVkey(vkey string) (id int, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (s *DbUtils) GetClientByVkey(vkey string) (c *Client, err error) {
|
||||
var exist bool
|
||||
s.JsonDb.Clients.Range(func(key, value interface{}) bool {
|
||||
v := value.(*Client)
|
||||
if fmt.Sprintf("%x", md5.Sum([]byte(v.VerifyKey))) == vkey {
|
||||
exist = true
|
||||
c = v
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
if exist {
|
||||
return
|
||||
}
|
||||
err = errors.New("未找到客户端")
|
||||
return
|
||||
}
|
||||
|
||||
func (s *DbUtils) GetHostById(id int) (h *Host, err error) {
|
||||
if v, ok := s.JsonDb.Hosts.Load(id); ok {
|
||||
h = v.(*Host)
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ func (s *JsonDb) LoadClientFromJsonFile() {
|
||||
if post.RateLimit > 0 {
|
||||
post.Rate = rate.NewRate(int64(post.RateLimit * 1024))
|
||||
} else {
|
||||
post.Rate = rate.NewRate(int64(2 << 23))
|
||||
post.Rate = rate.NewRate((2 << 23) * 1024)
|
||||
}
|
||||
post.Rate.Start()
|
||||
post.NowConn = 0
|
||||
|
||||
+4
-1
@@ -54,6 +54,9 @@ type Client struct {
|
||||
BlackIpList []string
|
||||
CreateTime string
|
||||
LastOnlineTime string
|
||||
IpWhite bool // 是否启用ip白名单
|
||||
IpWhitePass string // ip授权密码
|
||||
IpWhiteList []string // ip白名单
|
||||
sync.RWMutex
|
||||
}
|
||||
|
||||
@@ -149,7 +152,6 @@ type Tunnel struct {
|
||||
Remark string
|
||||
TargetAddr string
|
||||
NoStore bool
|
||||
IsHttp bool
|
||||
LocalPath string
|
||||
StripPre string
|
||||
ProtoVersion string
|
||||
@@ -225,5 +227,6 @@ func (s *Target) GetRandomTarget() (string, error) {
|
||||
|
||||
type Glob struct {
|
||||
BlackIpList []string
|
||||
ServerUrl string
|
||||
sync.RWMutex
|
||||
}
|
||||
|
||||
+64
-20
@@ -1,14 +1,18 @@
|
||||
package goroutine
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"ehang.io/nps/lib/common"
|
||||
"ehang.io/nps/lib/file"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/panjf2000/ants/v2"
|
||||
"io"
|
||||
"net"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type connGroup struct {
|
||||
@@ -51,24 +55,64 @@ func CopyBuffer(dst io.Writer, src io.Reader, flow *file.Flow, task *file.Tunnel
|
||||
}
|
||||
nr, er := src.Read(buf)
|
||||
|
||||
//if len(pr)>0 && pr[0] && nr > 50 {
|
||||
// logs.Warn(string(buf[:50]))
|
||||
//}
|
||||
|
||||
if task != nil {
|
||||
task.IsHttp = false
|
||||
firstLine := string(buf[0:nr])
|
||||
if len(firstLine) > 3 {
|
||||
method := firstLine[0:3]
|
||||
if method != "" && (method == "HTT" || method == "GET" || method == "POS" || method == "HEA" || method == "PUT" || method == "DEL") {
|
||||
if method != "HTT" {
|
||||
heads := strings.Split(firstLine, "\r\n")
|
||||
if len(heads) >= 2 {
|
||||
logs.Info("HTTP Request method %s, %s, remote address %s, target %s", heads[0], heads[1], remote, task.Target.TargetStr)
|
||||
if task.Client.IpWhite && task.Client.IpWhitePass != "" {
|
||||
|
||||
if common.IsAuthIp(remote, task.Client.VerifyKey, task.Client.IpWhiteList) {
|
||||
ip := common.GetIpByAddr(remote)
|
||||
var jsonBytes []byte
|
||||
|
||||
errorContent, _ := common.ReadAllFromFile(filepath.Join(common.GetRunPath(), "web", "static", "page", "auth.html"))
|
||||
authHtml := string(errorContent)
|
||||
authHtml = strings.ReplaceAll(authHtml, "${ip}", ip)
|
||||
|
||||
fullRequest := string(buf[0:nr])
|
||||
// 获取HTTP请求的第一行
|
||||
lines := strings.Split(fullRequest, "\r\n")
|
||||
if len(lines) == 0 {
|
||||
lines = strings.Split(fullRequest, "\n")
|
||||
}
|
||||
firstLine := lines[0]
|
||||
|
||||
// 优先处理客户端直接访问的 POST /authIp 请求,直接响应给客户端,不经隧道转发
|
||||
if strings.HasPrefix(firstLine, "POST /authIp") {
|
||||
pass := ""
|
||||
parts := strings.Split(firstLine, " ")
|
||||
if len(parts) > 1 {
|
||||
path := parts[1]
|
||||
if strings.Contains(path, "/authIp?pass=") {
|
||||
pass = strings.ReplaceAll(path, "/authIp?pass=", "")
|
||||
}
|
||||
}
|
||||
if pass == task.Client.IpWhitePass {
|
||||
task.Client.IpWhiteList = append(task.Client.IpWhiteList, ip)
|
||||
file.GetDb().UpdateClient(task.Client)
|
||||
logs.Info("客户端IP白名单认证授权成功:vkey [%s] ip [%s] password [%s]", task.Client.VerifyKey, ip, pass)
|
||||
jsonBytes, err = json.Marshal(map[string]interface{}{"success": true, "message": "授权成功"})
|
||||
} else {
|
||||
logs.Error("客户端IP白名单认证授权密码错误:vkey [%s] ip [%s] password [%s]", task.Client.VerifyKey, ip, pass)
|
||||
jsonBytes, err = json.Marshal(map[string]interface{}{"success": false, "message": "密码错误"})
|
||||
}
|
||||
response := fmt.Sprintf("HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: %d\r\nConnection: close\r\n\r\n%s", len(jsonBytes), jsonBytes)
|
||||
// 如果 src 是真实的客户端连接(net.Conn),直接写回客户端并关闭连接,避免走隧道转发
|
||||
if connSrc, ok := src.(net.Conn); ok {
|
||||
connSrc.Write([]byte(response))
|
||||
connSrc.Close()
|
||||
} else {
|
||||
dst.Write([]byte(response))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
task.IsHttp = true
|
||||
// 非授权IP,返回授权页面(同样优先返回给客户端)
|
||||
response := fmt.Sprintf("HTTP/1.1 401 Unauthorized\r\nContent-Type: text/html; charset=utf-8\r\nContent-Length: %d\r\nConnection: close\r\n\r\n%s", len(authHtml), authHtml)
|
||||
if connSrc, ok := src.(net.Conn); ok {
|
||||
connSrc.Write([]byte(response))
|
||||
connSrc.Close()
|
||||
} else {
|
||||
dst.Write([]byte(response))
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -81,7 +125,7 @@ func CopyBuffer(dst io.Writer, src io.Reader, flow *file.Flow, task *file.Tunnel
|
||||
flow.Add(int64(nw), int64(nw))
|
||||
// <<20 = 1024 * 1024
|
||||
if flow.FlowLimit > 0 && (flow.FlowLimit<<20) < (flow.ExportFlow+flow.InletFlow) {
|
||||
logs.Info("流量已经超出.........")
|
||||
logs.Error("隧道[%s]流量已经超出", task.Client.VerifyKey)
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -101,7 +145,6 @@ func CopyBuffer(dst io.Writer, src io.Reader, flow *file.Flow, task *file.Tunnel
|
||||
break
|
||||
}
|
||||
}
|
||||
//return written, err
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -111,6 +154,7 @@ func copyConnGroup(group interface{}) {
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
var err error
|
||||
err = CopyBuffer(cg.dst, cg.src, cg.flow, cg.task, cg.remote)
|
||||
if err != nil {
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ func NewRateConn(conn io.ReadWriteCloser, rate *Rate) io.ReadWriteCloser {
|
||||
|
||||
func (s *rateConn) Read(b []byte) (n int, err error) {
|
||||
n, err = s.conn.Read(b)
|
||||
if s.rate != nil {
|
||||
if s.rate != nil && s.rate.addSize > 0 {
|
||||
s.rate.Get(int64(n))
|
||||
}
|
||||
return
|
||||
@@ -26,7 +26,7 @@ func (s *rateConn) Read(b []byte) (n int, err error) {
|
||||
|
||||
func (s *rateConn) Write(b []byte) (n int, err error) {
|
||||
n, err = s.conn.Write(b)
|
||||
if s.rate != nil {
|
||||
if s.rate != nil && s.rate.addSize > 0 {
|
||||
s.rate.Get(int64(n))
|
||||
}
|
||||
return
|
||||
|
||||
+36
-58
@@ -1,81 +1,59 @@
|
||||
package rate
|
||||
|
||||
import (
|
||||
"sync/atomic"
|
||||
"context"
|
||||
"time"
|
||||
|
||||
xrate "golang.org/x/time/rate"
|
||||
)
|
||||
|
||||
type Rate struct {
|
||||
bucketSize int64
|
||||
bucketSurplusSize int64
|
||||
bucketAddSize int64
|
||||
stopChan chan bool
|
||||
NowRate int64
|
||||
limiter *xrate.Limiter
|
||||
addSize int64
|
||||
stopChan chan struct{}
|
||||
NowRate int64
|
||||
}
|
||||
|
||||
func NewRate(addSize int64) *Rate {
|
||||
return &Rate{
|
||||
bucketSize: addSize * 2,
|
||||
bucketSurplusSize: 0,
|
||||
bucketAddSize: addSize,
|
||||
stopChan: make(chan bool),
|
||||
limiter: xrate.NewLimiter(xrate.Limit(addSize), int(addSize)),
|
||||
addSize: addSize,
|
||||
stopChan: make(chan struct{}),
|
||||
NowRate: addSize,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Rate) Start() {
|
||||
go s.session()
|
||||
}
|
||||
|
||||
func (s *Rate) add(size int64) {
|
||||
if res := s.bucketSize - s.bucketSurplusSize; res < s.bucketAddSize {
|
||||
atomic.AddInt64(&s.bucketSurplusSize, res)
|
||||
return
|
||||
}
|
||||
atomic.AddInt64(&s.bucketSurplusSize, size)
|
||||
}
|
||||
|
||||
//回桶
|
||||
func (s *Rate) ReturnBucket(size int64) {
|
||||
s.add(size)
|
||||
}
|
||||
|
||||
//停止
|
||||
func (s *Rate) Stop() {
|
||||
s.stopChan <- true
|
||||
}
|
||||
|
||||
func (s *Rate) Get(size int64) {
|
||||
if s.bucketSurplusSize >= size {
|
||||
atomic.AddInt64(&s.bucketSurplusSize, -size)
|
||||
return
|
||||
}
|
||||
ticker := time.NewTicker(time.Millisecond * 100)
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
if s.bucketSurplusSize >= size {
|
||||
atomic.AddInt64(&s.bucketSurplusSize, -size)
|
||||
ticker.Stop()
|
||||
go func() {
|
||||
ticker := time.NewTicker(time.Second)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
s.NowRate = s.addSize - (int64(s.limiter.Tokens()))
|
||||
case <-s.stopChan:
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func (s *Rate) Stop() {
|
||||
select {
|
||||
case <-s.stopChan:
|
||||
default:
|
||||
close(s.stopChan)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Rate) session() {
|
||||
ticker := time.NewTicker(time.Second * 1)
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
if rs := s.bucketAddSize - s.bucketSurplusSize; rs > 0 {
|
||||
s.NowRate = rs
|
||||
} else {
|
||||
s.NowRate = s.bucketSize - s.bucketSurplusSize
|
||||
}
|
||||
s.add(s.bucketAddSize)
|
||||
case <-s.stopChan:
|
||||
ticker.Stop()
|
||||
return
|
||||
}
|
||||
func (s *Rate) Get(size int64) {
|
||||
if s.addSize <= 0 {
|
||||
return
|
||||
}
|
||||
if size <= 0 {
|
||||
return
|
||||
}
|
||||
ctx := context.Background()
|
||||
_ = s.limiter.WaitN(ctx, int(size))
|
||||
s.NowRate = s.addSize - (int64(s.limiter.Tokens()))
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package version
|
||||
|
||||
const VERSION = "0.26.25"
|
||||
const VERSION = "0.26.28"
|
||||
|
||||
// Compulsory minimum version, Minimum downward compatibility to this version
|
||||
func GetVersion() string {
|
||||
|
||||
@@ -29,6 +29,7 @@ type BaseServer struct {
|
||||
bridge NetBridge
|
||||
task *file.Tunnel
|
||||
errorContent []byte
|
||||
errorCode int
|
||||
sync.Mutex
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"ehang.io/nps/lib/file"
|
||||
"ehang.io/nps/lib/goroutine"
|
||||
"ehang.io/nps/server/connection"
|
||||
"encoding/json"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"io"
|
||||
"net"
|
||||
@@ -196,6 +197,45 @@ reset:
|
||||
return
|
||||
}
|
||||
|
||||
if host.Client.IpWhite && host.Client.IpWhitePass != "" {
|
||||
if common.IsAuthIp(c.RemoteAddr().String(), host.Client.VerifyKey, host.Client.IpWhiteList) {
|
||||
|
||||
if r.URL.Path == "/authIp" {
|
||||
rawQuery := r.URL.RawQuery
|
||||
|
||||
var jsonBytes []byte
|
||||
ip := common.GetIpByAddr(c.RemoteAddr().String())
|
||||
|
||||
if strings.Contains(rawQuery, "pass=") {
|
||||
// 截取 = 后面的值
|
||||
pass := strings.Split(rawQuery, "pass=")[1]
|
||||
if pass == host.Client.IpWhitePass {
|
||||
host.Client.IpWhiteList = append(host.Client.IpWhiteList, ip)
|
||||
file.GetDb().UpdateClient(host.Client)
|
||||
logs.Info("客户端IP白名单认证授权成功:vkey [%s] ip [%s] password [%s]", host.Client.VerifyKey, ip, pass)
|
||||
jsonBytes, err = json.Marshal(map[string]interface{}{"success": true, "message": "授权成功"})
|
||||
} else {
|
||||
logs.Error("客户端IP白名单认证授权密码错误:vkey [%s] ip [%s] password [%s]", host.Client.VerifyKey, ip, pass)
|
||||
jsonBytes, err = json.Marshal(map[string]interface{}{"success": false, "message": "密码错误"})
|
||||
}
|
||||
} else {
|
||||
logs.Error("客户端IP白名单认证授权密码错误:vkey [%s] ip [%s]", host.Client.VerifyKey, ip)
|
||||
jsonBytes, err = json.Marshal(map[string]interface{}{"success": false, "message": "参数错误"})
|
||||
}
|
||||
s.errorContent, err = jsonBytes, err
|
||||
s.errorCode = 200
|
||||
return
|
||||
}
|
||||
|
||||
errorContent, _ := common.ReadAllFromFile(filepath.Join(common.GetRunPath(), "web", "static", "page", "auth.html"))
|
||||
authHtml := string(errorContent)
|
||||
authHtml = strings.ReplaceAll(authHtml, "${ip}", common.GetIpByAddr(c.RemoteAddr().String()))
|
||||
s.errorContent, err = []byte(authHtml), err
|
||||
s.errorCode = 401
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 判断访问地址是否在黑名单内
|
||||
if common.IsBlackIp(c.RemoteAddr().String(), host.Client.VerifyKey, host.Client.BlackIpList) {
|
||||
c.Close()
|
||||
|
||||
@@ -159,14 +159,14 @@ func (https *HttpsServer) cert(host *file.Host, c net.Conn, rb []byte, certFileU
|
||||
}
|
||||
https.httpsListenerMap.Delete(value)
|
||||
https.hostIdCertMap.Delete(key)
|
||||
logs.Info("Listener 已释放")
|
||||
logs.Debug("Listener 已释放")
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
logs.Info("当前 Listener 连接数量", i)
|
||||
logs.Debug("当前 Listener 连接数量", i)
|
||||
|
||||
if cert, ok := https.hostIdCertMap.Load(host.Id); ok {
|
||||
if cert == certFileUrl {
|
||||
|
||||
+1
-29
@@ -329,7 +329,6 @@ func GetClientList(start, length int, search, sort, order string, clientId int)
|
||||
}
|
||||
|
||||
func dealClientData() {
|
||||
//logs.Info("dealClientData.........")
|
||||
|
||||
file.GetDb().JsonDb.Clients.Range(func(key, value interface{}) bool {
|
||||
v := value.(*file.Client)
|
||||
@@ -340,34 +339,7 @@ func dealClientData() {
|
||||
} else {
|
||||
v.IsConnect = false
|
||||
}
|
||||
//v.Flow.InletFlow = 0
|
||||
//v.Flow.ExportFlow = 0
|
||||
//if len(file.GetDb().JsonDb.Hosts) == 0 {
|
||||
//
|
||||
//}
|
||||
//var inflow int64 = 0
|
||||
//var outflow int64 = 0
|
||||
//file.GetDb().JsonDb.Hosts.Range(func(key, value interface{}) bool {
|
||||
// h := value.(*file.Host)
|
||||
// if h.Client.Id == v.Id {
|
||||
// inflow += h.Flow.InletFlow
|
||||
// outflow += h.Flow.ExportFlow
|
||||
// }
|
||||
// return true
|
||||
//})
|
||||
//file.GetDb().JsonDb.Tasks.Range(func(key, value interface{}) bool {
|
||||
// t := value.(*file.Tunnel)
|
||||
// if t.Client.Id == v.Id {
|
||||
// inflow += t.Flow.InletFlow
|
||||
// outflow += t.Flow.ExportFlow
|
||||
// }
|
||||
// return true
|
||||
//})
|
||||
//
|
||||
//if inflow >0 || outflow >0{
|
||||
// v.Flow.InletFlow = inflow
|
||||
// v.Flow.ExportFlow = outflow
|
||||
//}
|
||||
|
||||
return true
|
||||
})
|
||||
return
|
||||
|
||||
@@ -2,8 +2,12 @@ package controllers
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"html"
|
||||
"time"
|
||||
|
||||
"ehang.io/nps/lib/file"
|
||||
|
||||
"ehang.io/nps/lib/crypt"
|
||||
"github.com/astaxie/beego"
|
||||
)
|
||||
@@ -40,3 +44,63 @@ func (s *AuthController) GetTime() {
|
||||
s.Data["json"] = m
|
||||
s.ServeJSON()
|
||||
}
|
||||
|
||||
func (s *AuthController) IpWhiteAuth() {
|
||||
s.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
s.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Methods", "GET, POST, OPTIONS")
|
||||
s.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Headers", "Content-Type")
|
||||
|
||||
vkey := s.getEscapeString("vkey")
|
||||
ip := s.getEscapeString("ip")
|
||||
password := s.getEscapeString("pass")
|
||||
|
||||
if vkey == "" || password == "" {
|
||||
s.Data["json"] = map[string]interface{}{"success": false, "message": "参数错误"}
|
||||
s.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
// 如果未提供 ip,则使用请求中的客户端 IP(支持代理头)
|
||||
if ip == "" {
|
||||
ip = s.Ctx.Input.IP()
|
||||
ip = html.EscapeString(ip)
|
||||
}
|
||||
|
||||
c, err := file.GetDb().GetClientByVkey(vkey)
|
||||
if err != nil {
|
||||
s.Data["json"] = map[string]interface{}{"success": false, "message": "客户端密钥错误"}
|
||||
s.ServeJSON()
|
||||
logs.Error("客户端IP白名单认证失败,客户端密钥错误:vkey [%s] ip [%s] password [%s]", vkey, ip, password)
|
||||
return
|
||||
}
|
||||
|
||||
if c.IpWhitePass != password {
|
||||
s.Data["json"] = map[string]interface{}{"success": false, "message": "授权密码错误"}
|
||||
s.ServeJSON()
|
||||
logs.Error("客户端IP白名单认证失败,授权密码错误:vkey [%s] ip [%s] password [%s]", vkey, ip, password)
|
||||
return
|
||||
}
|
||||
|
||||
ipExists := false
|
||||
for _, existingIp := range c.IpWhiteList {
|
||||
if existingIp == ip {
|
||||
ipExists = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !ipExists {
|
||||
c.IpWhiteList = append(c.IpWhiteList, ip)
|
||||
file.GetDb().UpdateClient(c)
|
||||
}
|
||||
|
||||
s.Data["json"] = map[string]interface{}{"success": true, "message": "授权成功"}
|
||||
s.ServeJSON()
|
||||
|
||||
logs.Info("客户端IP白名单认证授权成功:vkey [%s] ip [%s] password [%s]", vkey, ip, password)
|
||||
|
||||
}
|
||||
|
||||
func (s *AuthController) getEscapeString(key string) string {
|
||||
return html.EscapeString(s.GetString(key))
|
||||
}
|
||||
|
||||
+25
-14
@@ -1,13 +1,14 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"ehang.io/nps/bridge"
|
||||
"html"
|
||||
"math"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"ehang.io/nps/bridge"
|
||||
|
||||
"ehang.io/nps/lib/common"
|
||||
"ehang.io/nps/lib/crypt"
|
||||
"ehang.io/nps/lib/file"
|
||||
@@ -21,7 +22,7 @@ type BaseController struct {
|
||||
actionName string
|
||||
}
|
||||
|
||||
//初始化参数
|
||||
// 初始化参数
|
||||
func (s *BaseController) Prepare() {
|
||||
s.Data["web_base_url"] = beego.AppConfig.String("web_base_url")
|
||||
controllerName, actionName := s.GetControllerAndAction()
|
||||
@@ -66,7 +67,7 @@ func (s *BaseController) Prepare() {
|
||||
s.Data["allow_user_change_username"], _ = beego.AppConfig.Bool("allow_user_change_username")
|
||||
}
|
||||
|
||||
//加载模板
|
||||
// 加载模板
|
||||
func (s *BaseController) display(tpl ...string) {
|
||||
s.Data["web_base_url"] = beego.AppConfig.String("web_base_url")
|
||||
var tplname string
|
||||
@@ -80,6 +81,16 @@ func (s *BaseController) display(tpl ...string) {
|
||||
}
|
||||
ip := s.Ctx.Request.Host
|
||||
s.Data["ip"] = common.GetIpByAddr(ip)
|
||||
|
||||
global := file.GetDb().GetGlobal()
|
||||
if global != nil && global.ServerUrl != "" && global.ServerUrl != ip {
|
||||
// 替换掉 http:// 或者 https://
|
||||
ip = global.ServerUrl
|
||||
ip = strings.ReplaceAll(ip, "http://", "")
|
||||
ip = strings.ReplaceAll(ip, "https://", "")
|
||||
s.Data["ip"] = ip
|
||||
}
|
||||
|
||||
s.Data["bridgeType"] = beego.AppConfig.String("bridge_type")
|
||||
if common.IsWindows() {
|
||||
s.Data["win"] = ".exe"
|
||||
@@ -100,19 +111,19 @@ func (s *BaseController) display(tpl ...string) {
|
||||
s.TplName = tplname
|
||||
}
|
||||
|
||||
//错误
|
||||
// 错误
|
||||
func (s *BaseController) error() {
|
||||
s.Data["web_base_url"] = beego.AppConfig.String("web_base_url")
|
||||
s.Layout = "public/layout.html"
|
||||
s.TplName = "public/error.html"
|
||||
}
|
||||
|
||||
//getEscapeString
|
||||
// getEscapeString
|
||||
func (s *BaseController) getEscapeString(key string) string {
|
||||
return html.EscapeString(s.GetString(key))
|
||||
}
|
||||
|
||||
//去掉没有err返回值的int
|
||||
// 去掉没有err返回值的int
|
||||
func (s *BaseController) GetIntNoErr(key string, def ...int) int {
|
||||
strv := s.Ctx.Input.Query(key)
|
||||
if len(strv) == 0 && len(def) > 0 {
|
||||
@@ -122,7 +133,7 @@ func (s *BaseController) GetIntNoErr(key string, def ...int) int {
|
||||
return val
|
||||
}
|
||||
|
||||
//获取去掉错误的bool值
|
||||
// 获取去掉错误的bool值
|
||||
func (s *BaseController) GetBoolNoErr(key string, def ...bool) bool {
|
||||
strv := s.Ctx.Input.Query(key)
|
||||
if len(strv) == 0 && len(def) > 0 {
|
||||
@@ -132,28 +143,28 @@ func (s *BaseController) GetBoolNoErr(key string, def ...bool) bool {
|
||||
return val
|
||||
}
|
||||
|
||||
//ajax正确返回
|
||||
// ajax正确返回
|
||||
func (s *BaseController) AjaxOk(str string) {
|
||||
s.Data["json"] = ajax(str, 1)
|
||||
s.ServeJSON()
|
||||
s.StopRun()
|
||||
}
|
||||
|
||||
//ajax正确返回
|
||||
// ajax正确返回
|
||||
func (s *BaseController) AjaxOkWithId(str string, id int) {
|
||||
s.Data["json"] = ajaxWithId(str, 1, id)
|
||||
s.ServeJSON()
|
||||
s.StopRun()
|
||||
}
|
||||
|
||||
//ajax错误返回
|
||||
// ajax错误返回
|
||||
func (s *BaseController) AjaxErr(str string) {
|
||||
s.Data["json"] = ajax(str, 0)
|
||||
s.ServeJSON()
|
||||
s.StopRun()
|
||||
}
|
||||
|
||||
//组装ajax
|
||||
// 组装ajax
|
||||
func ajax(str string, status int) map[string]interface{} {
|
||||
json := make(map[string]interface{})
|
||||
json["status"] = status
|
||||
@@ -161,7 +172,7 @@ func ajax(str string, status int) map[string]interface{} {
|
||||
return json
|
||||
}
|
||||
|
||||
//组装ajax
|
||||
// 组装ajax
|
||||
func ajaxWithId(str string, status int, id int) map[string]interface{} {
|
||||
json := make(map[string]interface{})
|
||||
json["status"] = status
|
||||
@@ -170,7 +181,7 @@ func ajaxWithId(str string, status int, id int) map[string]interface{} {
|
||||
return json
|
||||
}
|
||||
|
||||
//ajax table返回
|
||||
// ajax table返回
|
||||
func (s *BaseController) AjaxTable(list interface{}, cnt int, recordsTotal int, kwargs map[string]interface{}) {
|
||||
json := make(map[string]interface{})
|
||||
json["rows"] = list
|
||||
@@ -187,7 +198,7 @@ func (s *BaseController) AjaxTable(list interface{}, cnt int, recordsTotal int,
|
||||
s.StopRun()
|
||||
}
|
||||
|
||||
//ajax table参数
|
||||
// ajax table参数
|
||||
func (s *BaseController) GetAjaxParams() (start, limit int) {
|
||||
return s.GetIntNoErr("offset"), s.GetIntNoErr("limit")
|
||||
}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"ehang.io/nps/lib/common"
|
||||
"ehang.io/nps/lib/file"
|
||||
"ehang.io/nps/lib/rate"
|
||||
"ehang.io/nps/server"
|
||||
"github.com/astaxie/beego"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ClientController struct {
|
||||
@@ -69,6 +70,9 @@ func (s *ClientController) Add() {
|
||||
FlowLimit: int64(s.GetIntNoErr("flow_limit")),
|
||||
},
|
||||
BlackIpList: RemoveRepeatedElement(strings.Split(s.getEscapeString("blackiplist"), "\r\n")),
|
||||
IpWhite: s.GetBoolNoErr("ipwhite"),
|
||||
IpWhitePass: s.getEscapeString("ipwhitepass"),
|
||||
IpWhiteList: RemoveRepeatedElement(strings.Split(s.getEscapeString("ipwhitelist"), "\r\n")),
|
||||
CreateTime: time.Now().Format("2006-01-02 15:04:05"),
|
||||
}
|
||||
if err := file.GetDb().NewClient(t); err != nil {
|
||||
@@ -102,6 +106,7 @@ func (s *ClientController) Edit() {
|
||||
} else {
|
||||
s.Data["c"] = c
|
||||
s.Data["BlackIpList"] = strings.Join(c.BlackIpList, "\r\n")
|
||||
s.Data["IpWhiteList"] = strings.Join(c.IpWhiteList, "\r\n")
|
||||
}
|
||||
s.SetInfo("edit client")
|
||||
s.display()
|
||||
@@ -139,6 +144,9 @@ func (s *ClientController) Edit() {
|
||||
}
|
||||
c.WebPassword = s.getEscapeString("web_password")
|
||||
c.ConfigConnAllow = s.GetBoolNoErr("config_conn_allow")
|
||||
c.IpWhite = s.GetBoolNoErr("ipwhite")
|
||||
c.IpWhitePass = s.getEscapeString("ipwhitepass")
|
||||
c.IpWhiteList = RemoveRepeatedElement(strings.Split(s.getEscapeString("ipwhitelist"), "\r\n"))
|
||||
if c.Rate != nil {
|
||||
c.Rate.Stop()
|
||||
}
|
||||
@@ -146,7 +154,7 @@ func (s *ClientController) Edit() {
|
||||
c.Rate = rate.NewRate(int64(c.RateLimit * 1024))
|
||||
c.Rate.Start()
|
||||
} else {
|
||||
c.Rate = rate.NewRate(int64(2 << 23))
|
||||
c.Rate = rate.NewRate((2 << 23) * 1024)
|
||||
c.Rate.Start()
|
||||
}
|
||||
|
||||
@@ -160,6 +168,10 @@ func (s *ClientController) Edit() {
|
||||
func RemoveRepeatedElement(arr []string) (newArr []string) {
|
||||
newArr = make([]string, 0)
|
||||
for i := 0; i < len(arr); i++ {
|
||||
// 过滤空IP
|
||||
if strings.TrimSpace(arr[i]) == "" {
|
||||
continue
|
||||
}
|
||||
repeat := false
|
||||
for j := i + 1; j < len(arr); j++ {
|
||||
if arr[i] == arr[j] {
|
||||
|
||||
@@ -23,21 +23,20 @@ func (s *GlobalController) Index() {
|
||||
return
|
||||
}
|
||||
s.Data["globalBlackIpList"] = strings.Join(global.BlackIpList, "\r\n")
|
||||
s.Data["serverUrl"] = global.ServerUrl
|
||||
}
|
||||
|
||||
//添加全局黑名单IP
|
||||
// 添加全局参数
|
||||
func (s *GlobalController) Save() {
|
||||
//global, err := file.GetDb().GetGlobal()
|
||||
//if err != nil {
|
||||
// return
|
||||
//}
|
||||
if s.Ctx.Request.Method == "GET" {
|
||||
s.Data["menu"] = "global"
|
||||
s.SetInfo("save global")
|
||||
s.display()
|
||||
} else {
|
||||
|
||||
t := &file.Glob{BlackIpList: RemoveRepeatedElement(strings.Split(s.getEscapeString("globalBlackIpList"), "\r\n"))}
|
||||
t := &file.Glob{
|
||||
BlackIpList: RemoveRepeatedElement(strings.Split(s.getEscapeString("globalBlackIpList"), "\r\n")),
|
||||
ServerUrl: s.getEscapeString("serverUrl")}
|
||||
|
||||
if err := file.GetDb().SaveGlobal(t); err != nil {
|
||||
s.AjaxErr(err.Error())
|
||||
|
||||
@@ -14,6 +14,7 @@ func Init() {
|
||||
beego.NSAutoRouter(&controllers.LoginController{}),
|
||||
beego.NSAutoRouter(&controllers.ClientController{}),
|
||||
beego.NSAutoRouter(&controllers.AuthController{}),
|
||||
beego.NSRouter("/auth/ipwhiteauth", &controllers.AuthController{}, "*:IpWhiteAuth"),
|
||||
beego.NSAutoRouter(&controllers.GlobalController{}),
|
||||
)
|
||||
beego.AddNamespace(ns)
|
||||
@@ -23,6 +24,7 @@ func Init() {
|
||||
beego.AutoRouter(&controllers.LoginController{})
|
||||
beego.AutoRouter(&controllers.ClientController{})
|
||||
beego.AutoRouter(&controllers.AuthController{})
|
||||
beego.Router("/auth/ipwhiteauth", &controllers.AuthController{}, "*:IpWhiteAuth")
|
||||
beego.AutoRouter(&controllers.GlobalController{})
|
||||
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
$.fn.cloudLang = function () {
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: window.nps.web_base_url + '/static/page/languages.xml?v=20250107',
|
||||
url: window.nps.web_base_url + '/static/page/languages.xml?v=202512051',
|
||||
dataType: 'xml',
|
||||
success: function (xml) {
|
||||
languages['content'] = xml2json($(xml).children())['content'];
|
||||
|
||||
@@ -0,0 +1,227 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="initial-scale=1, user-scalable=0, minimal-ui">
|
||||
<title>NPS访问验证</title>
|
||||
<style>
|
||||
html {
|
||||
padding: 30px 10px;
|
||||
font-size: 20px;
|
||||
line-height: 1.4;
|
||||
color: #737373;
|
||||
background: #ddd;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
-ms-text-size-adjust: 100%;
|
||||
}
|
||||
|
||||
html,
|
||||
input {
|
||||
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
body {
|
||||
max-width: 500px;
|
||||
_width: 500px;
|
||||
padding: 30px 20px 50px;
|
||||
/* background-color: white; */
|
||||
margin: 40px auto;
|
||||
-webkit-border-radius: 6px;
|
||||
-moz-border-radius: 6px;
|
||||
border-radius: 6px;
|
||||
-webkit-box-shadow: 0 0px 2px rgba(0, 0, 0, 0.05);
|
||||
-moz-box-shadow: 0 0px 2px rgba(0, 0, 0, 0.1);
|
||||
box-shadow: 0 0px 2px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0 10px;
|
||||
font-size: 50px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
h1 span {
|
||||
color: #bbb;
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin: 1.5em 0 0.5em;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
ul {
|
||||
padding: 0 0 0 40px;
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 380px;
|
||||
_width: 380px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
|
||||
html .login-wrap {
|
||||
position: relative;
|
||||
/* margin: 180px auto; */
|
||||
background: #ecf0f1;
|
||||
/* width: 350px; */
|
||||
border-radius: 5px;
|
||||
box-shadow: 3px 3px 10px #333;
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
html .login-wrap h2 {
|
||||
text-align: center;
|
||||
/* font-weight: 200; */
|
||||
font-size: 1.6em;
|
||||
margin-top: 20px;
|
||||
color: #34495e;
|
||||
height: 50px;
|
||||
}
|
||||
|
||||
html .login-wrap .form {
|
||||
padding-top: 20px;
|
||||
}
|
||||
|
||||
|
||||
html .login-wrap .form input[type="text"],
|
||||
html .login-wrap .form input[type="password"],
|
||||
html .login-wrap .form button {
|
||||
width: 80%;
|
||||
margin-left: 10%;
|
||||
margin-bottom: 25px;
|
||||
height: 40px;
|
||||
border-radius: 5px;
|
||||
outline: 0;
|
||||
-moz-outline-style: none;
|
||||
}
|
||||
|
||||
|
||||
html .login-wrap .form input[type="text"],
|
||||
html .login-wrap .form input[type="password"] {
|
||||
border: 1px solid #bbb;
|
||||
padding: 0 0 0 10px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
html .login-wrap .form input[type="text"]:focus,
|
||||
html .login-wrap .form input[type="password"]:focus {
|
||||
border: 1px solid #3498db;
|
||||
}
|
||||
|
||||
|
||||
html .login-wrap .form a {
|
||||
text-align: center;
|
||||
font-size: 12px;
|
||||
color: #3498db;
|
||||
}
|
||||
|
||||
|
||||
html .login-wrap .form a {
|
||||
text-align: center;
|
||||
font-size: 12px;
|
||||
color: #3498db;
|
||||
}
|
||||
|
||||
html .login-wrap .form a p {
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
html .login-wrap .form button {
|
||||
background: #e74c3c;
|
||||
border: none;
|
||||
color: white;
|
||||
font-size: 18px;
|
||||
font-weight: 200;
|
||||
cursor: pointer;
|
||||
transition: box-shadow .4s ease;
|
||||
}
|
||||
|
||||
html .login-wrap .form button:hover {
|
||||
box-shadow: 1px 1px 5px #555;
|
||||
}
|
||||
|
||||
html .login-wrap .form button:active {
|
||||
box-shadow: 1px 1px 7px #222;
|
||||
}
|
||||
|
||||
|
||||
html .login-wrap:after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background: -webkit-linear-gradient(left, #27ae60 0%, #27ae60 20%, #8e44ad 20%, #8e44ad 40%, #3498db 40%, #3498db 60%, #e74c3c 60%, #e74c3c 80%, #f1c40f 80%, #f1c40f 100%);
|
||||
background: -moz-linear-gradient(left, #27ae60 0%, #27ae60 20%, #8e44ad 20%, #8e44ad 40%, #3498db 40%, #3498db 60%, #e74c3c 60%, #e74c3c 80%, #f1c40f 80%, #f1c40f 100%);
|
||||
height: 5px;
|
||||
border-radius: 5px 5px 0 0;
|
||||
}
|
||||
|
||||
.tips {
|
||||
text-align: center;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.ip-addr {
|
||||
font-weight: bolder;
|
||||
}
|
||||
|
||||
.error {
|
||||
text-align: center;
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div hidden id="port">${port}</div>
|
||||
|
||||
<div class="container">
|
||||
<div class="login-wrap">
|
||||
<h2>访问验证</h2>
|
||||
<div class="tips">当前 IP (<span class="ip-addr" id="ip_addr">${ip}</span>) 未经授权, 已禁止访问</div>
|
||||
<div class="form">
|
||||
<input type="text" id="pwd" placeholder="请输入访问密码" name="pw">
|
||||
<button onclick="submitAuth()"> 提交验证</button>
|
||||
<div hidden id="error" class="error"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
<script>
|
||||
function submitAuth() {
|
||||
var pwd = document.getElementById("pwd").value
|
||||
|
||||
if (pwd === '' || pwd == null) {
|
||||
document.getElementById("error").hidden = false;
|
||||
document.getElementById("error").innerHTML = "请输入授权秘钥"
|
||||
}
|
||||
const xhr = new XMLHttpRequest()
|
||||
xhr.addEventListener("readystatechange", function () {
|
||||
// debugger
|
||||
if (xhr.response != null && xhr.response !== '') {
|
||||
var resp = JSON.parse(xhr.response);
|
||||
console.log(resp)
|
||||
if (resp.success !== true) {
|
||||
document.getElementById("error").hidden = false;
|
||||
document.getElementById("error").innerHTML = resp.message
|
||||
} else {
|
||||
location.reload();
|
||||
}
|
||||
|
||||
}
|
||||
console.log(xhr.response)
|
||||
})
|
||||
xhr.open("post", "/authIp?pass=" + pwd)
|
||||
xhr.send()
|
||||
}
|
||||
</script>
|
||||
|
||||
</html>
|
||||
@@ -599,6 +599,12 @@
|
||||
<zh-CN>唯一值,不填将自动生成</zh-CN>
|
||||
<en-US>Unique, non-filling will be generated automatically</en-US>
|
||||
</lang>
|
||||
|
||||
<lang id="info-ipwhitepass">
|
||||
<zh-CN>IP授权密码,不在IP白名单的访问将被跳转到IP授权页面,输入正确的授权密码,即可完成添加IP。</zh-CN>
|
||||
<en-US>IP White Password, access that is not in the IP white list will be redirected to the IP authorization page, enter the correct authorization password, and you can complete the addition of IP.</en-US>
|
||||
</lang>
|
||||
|
||||
<lang id="info-casefile">
|
||||
<zh-CN>通提供一个公网可访问的本地文件服务,此模式仅客户端使用配置文件模式方可启动。</zh-CN>
|
||||
<en-US>Provide a local file service accessible to the public network, which can only be started by the client using the profile mode.</en-US>
|
||||
@@ -732,6 +738,12 @@
|
||||
<en-US>Empty means to be unrestricted</en-US>
|
||||
</lang>
|
||||
|
||||
<lang id="info-input-whitepass">
|
||||
<zh-CN>留空表示不跳转IP授权页面</zh-CN>
|
||||
<en-US>Empty means not to jump to the IP authorization page</en-US>
|
||||
</lang>
|
||||
|
||||
|
||||
|
||||
<lang id="word-blackiplist">
|
||||
<zh-CN>IP黑名单(防暴力破解)</zh-CN>
|
||||
@@ -744,6 +756,16 @@
|
||||
<en-US>Global IP Black List</en-US>
|
||||
</lang>
|
||||
|
||||
<lang id="word-serverurl">
|
||||
<zh-CN>服务地址</zh-CN>
|
||||
<en-US>Server</en-US>
|
||||
</lang>
|
||||
|
||||
<lang id="info-servertips">
|
||||
<zh-CN>客户端命令地址显示、隧道访问显示</zh-CN>
|
||||
<en-US>Server URL, Tunnel Access</en-US>
|
||||
</lang>
|
||||
|
||||
<lang id="info-suchasblackiplist">
|
||||
<zh-CN>例如 10.1.50.203 10.1.50.202</zh-CN>
|
||||
<en-US>such as 10.1.50.203 10.1.50.202</en-US>
|
||||
@@ -770,6 +792,21 @@
|
||||
<en-US>Last Online Time</en-US>
|
||||
</lang>
|
||||
|
||||
<lang id="word-ipwhite">
|
||||
<zh-CN>启用IP白名单</zh-CN>
|
||||
<en-US> Enable IP White </en-US>
|
||||
</lang>
|
||||
|
||||
<lang id="word-ipwhitepass">
|
||||
<zh-CN>IP白名单授权密码</zh-CN>
|
||||
<en-US>IP White Password </en-US>
|
||||
</lang>
|
||||
|
||||
<lang id="word-ipwhitelist">
|
||||
<zh-CN>IP白名单</zh-CN>
|
||||
<en-US>IP White List </en-US>
|
||||
</lang>
|
||||
|
||||
<confirm>
|
||||
<lang id="delete">
|
||||
<zh-CN>你确定你要删除它吗?</zh-CN>
|
||||
|
||||
@@ -88,22 +88,49 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" id="compress">
|
||||
<label class="control-label font-bold" langtag="word-compress"></label>
|
||||
<!-- <div class="form-group" id="compress">-->
|
||||
<!-- <label class="control-label font-bold" langtag="word-compress"></label>-->
|
||||
<!-- <div class="col-sm-10">-->
|
||||
<!-- <select class="form-control" name="compress">-->
|
||||
<!-- <option value="0" langtag="word-no"></option>-->
|
||||
<!-- <option value="1" langtag="word-yes"></option>-->
|
||||
<!-- </select>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="form-group" id="compress">-->
|
||||
<!-- <label class="control-label font-bold" langtag="word-crypt"></label>-->
|
||||
<!-- <div class="col-sm-10">-->
|
||||
<!-- <select class="form-control" name="crypt">-->
|
||||
<!-- <option value="0" langtag="word-no"></option>-->
|
||||
<!-- <option value="1" langtag="word-yes"></option>-->
|
||||
<!-- </select>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
|
||||
<div class="form-group" id="ip_white">
|
||||
<label class="control-label font-bold" langtag="word-ipwhite"></label>
|
||||
<div class="col-sm-10">
|
||||
<select class="form-control" name="compress">
|
||||
<select class="form-control" name="ipwhite">
|
||||
<option value="0" langtag="word-no"></option>
|
||||
<option value="1" langtag="word-yes"></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" id="compress">
|
||||
<label class="control-label font-bold" langtag="word-crypt"></label>
|
||||
|
||||
|
||||
<div class="form-group" id="Ip_white_pass" style="display: none;">
|
||||
<label class="control-label font-bold" langtag="word-ipwhitepass"></label>
|
||||
<div class="col-sm-10">
|
||||
<select class="form-control" name="crypt">
|
||||
<option value="0" langtag="word-no"></option>
|
||||
<option value="1" langtag="word-yes"></option>
|
||||
</select>
|
||||
<input class="form-control" type="text" name="ipwhitepass" placeholder="" langtag="info-input-whitepass">
|
||||
<span class="help-block m-b-none" langtag="info-ipwhitepass"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group" id="ip_white_list" style="display: none;">
|
||||
<label class="control-label font-bold" langtag="word-ipwhitelist"></label>
|
||||
<div class="col-sm-10">
|
||||
<textarea class="form-control" rows="4" type="text" name="ipwhitelist" placeholder="" langtag="info-suchasblackiplist">{{.BlackIpList}}</textarea>
|
||||
<span class="help-block m-b-none" langtag="info-descblackiplist"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -128,3 +155,20 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
// IP白名单选择change事件
|
||||
$('select[name="ipwhite"]').change(function() {
|
||||
if ($(this).val() == '1') {
|
||||
$('#Ip_white_pass').show();
|
||||
$('#ip_white_list').show();
|
||||
$('#black_ip_list').hide();
|
||||
} else {
|
||||
$('#Ip_white_pass').hide();
|
||||
$('#ip_white_list').hide();
|
||||
$('#black_ip_list').show();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
+96
-32
@@ -8,96 +8,108 @@
|
||||
<div class="form-group" id="remark">
|
||||
<label class="control-label font-bold" langtag="word-remark"></label>
|
||||
<div class="col-sm-10">
|
||||
<input class="form-control" value="{{.c.Remark}}" type="text" name="remark" placeholder="" langtag="word-remark">
|
||||
<input class="form-control" value="{{.c.Remark}}" type="text" name="remark" placeholder=""
|
||||
langtag="word-remark">
|
||||
</div>
|
||||
</div>
|
||||
{{if eq true .isAdmin}}
|
||||
{{if eq true .allow_flow_limit}}
|
||||
{{if eq true .isAdmin}}
|
||||
{{if eq true .allow_flow_limit}}
|
||||
<div class="form-group" id="flow_limit">
|
||||
<label class="control-label font-bold" langtag="word-flowlimit"></label>
|
||||
<div class="col-sm-10">
|
||||
<input class="form-control" value="{{.c.Flow.FlowLimit}}" type="text" name="flow_limit" placeholder="" langtag="info-unrestricted">
|
||||
<input class="form-control" value="{{.c.Flow.FlowLimit}}" type="text" name="flow_limit"
|
||||
placeholder="" langtag="info-unrestricted">
|
||||
<span class="help-block m-b-none" langtag="word-unit"></span>: M
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
{{if eq true .allow_rate_limit}}
|
||||
{{end}}
|
||||
{{if eq true .allow_rate_limit}}
|
||||
|
||||
<div class="form-group" id="rate_limit">
|
||||
<label class="control-label font-bold" langtag="word-ratelimit"></label>
|
||||
<div class="col-sm-10">
|
||||
<input class="form-control" value="{{.c.RateLimit}}" type="text" name="rate_limit" placeholder="" langtag="info-unrestricted">
|
||||
<input class="form-control" value="{{.c.RateLimit}}" type="text" name="rate_limit"
|
||||
placeholder="" langtag="info-unrestricted">
|
||||
<span class="help-block m-b-none" langtag="word-unit"></span>: KB/S
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
{{if eq true .allow_connection_num_limit}}
|
||||
{{end}}
|
||||
{{if eq true .allow_connection_num_limit}}
|
||||
|
||||
<div class="form-group" id="max_conn">
|
||||
<label class="control-label font-bold" langtag="word-maxconnections"></label>
|
||||
<div class="col-sm-10">
|
||||
<input class="form-control" value="{{.c.MaxConn}}" type="text" name="max_conn" placeholder="" langtag="info-unrestricted">
|
||||
<input class="form-control" value="{{.c.MaxConn}}" type="text" name="max_conn"
|
||||
placeholder="" langtag="info-unrestricted">
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
{{if eq true .allow_tunnel_num_limit}}
|
||||
{{end}}
|
||||
{{if eq true .allow_tunnel_num_limit}}
|
||||
<div class="form-group" id="max_tunnel">
|
||||
<label class="control-label font-bold" langtag="word-maxtunnels"></label>
|
||||
<div class="col-sm-10">
|
||||
<input class="form-control" value="{{.c.MaxTunnelNum}}" type="text" name="max_tunnel" placeholder="" langtag="info-unrestricted">
|
||||
<input class="form-control" value="{{.c.MaxTunnelNum}}" type="text" name="max_tunnel"
|
||||
placeholder="" langtag="info-unrestricted">
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
<div class="form-group" id="u">
|
||||
<label class="control-label font-bold" langtag="word-basicusername"></label>
|
||||
<div class="col-sm-10">
|
||||
<input class="form-control" value="{{.c.Cnf.U}}" type="text" name="u" placeholder="" langtag="info-unrestricted">
|
||||
<input class="form-control" value="{{.c.Cnf.U}}" type="text" name="u" placeholder=""
|
||||
langtag="info-unrestricted">
|
||||
<span class="help-block m-b-none" langtag="info-onlyproxy"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" id="p">
|
||||
<label class="control-label font-bold" langtag="word-basicpassword"></label>
|
||||
<div class="col-sm-10">
|
||||
<input class="form-control" value="{{.c.Cnf.P}}" type="text" name="p" placeholder="" langtag="info-unrestricted">
|
||||
<input class="form-control" value="{{.c.Cnf.P}}" type="text" name="p" placeholder=""
|
||||
langtag="info-unrestricted">
|
||||
<span class="help-block m-b-none" langtag="info-onlyproxy"></span>
|
||||
</div>
|
||||
</div>
|
||||
{{if eq true .isAdmin}}
|
||||
{{if eq true .isAdmin}}
|
||||
<div class="form-group" id="vkey">
|
||||
<label class="control-label font-bold" langtag="word-verifyKey"></label>
|
||||
<div class="col-sm-10">
|
||||
<input class="form-control" value="{{.c.VerifyKey}}" type="text" name="vkey" placeholder="" langtag="info-unrestricted">
|
||||
<input class="form-control" value="{{.c.VerifyKey}}" type="text" name="vkey" placeholder=""
|
||||
langtag="info-unrestricted">
|
||||
<span class="help-block m-b-none" langtag="info-autogenerated"></span>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
{{if eq true .allow_user_login}}
|
||||
{{if or (eq true .allow_user_change_username) (eq true .isAdmin)}}
|
||||
{{end}}
|
||||
{{if eq true .allow_user_login}}
|
||||
{{if or (eq true .allow_user_change_username) (eq true .isAdmin)}}
|
||||
<div class="form-group" id="web_username">
|
||||
<label class="control-label font-bold" langtag="word-webusername"></label>
|
||||
<div class="col-sm-10">
|
||||
<input class="form-control" value="{{.c.WebUserName}}" type="text" name="web_username" placeholder="" langtag="info-unrestricted">
|
||||
<input class="form-control" value="{{.c.WebUserName}}" type="text" name="web_username"
|
||||
placeholder="" langtag="info-unrestricted">
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
<div class="form-group" id="web_password">
|
||||
<label class="control-label font-bold" langtag="word-webpassword"></label>
|
||||
<div class="col-sm-10">
|
||||
<input class="form-control" value="{{.c.WebPassword}}" type="text" name="web_password" placeholder="" langtag="info-unrestricted">
|
||||
<input class="form-control" value="{{.c.WebPassword}}" type="text" name="web_password"
|
||||
placeholder="" langtag="info-unrestricted">
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
<div class="form-group" id="config_conn_allow">
|
||||
<label class="control-label font-bold" langtag="word-connectbyconfig"></label>
|
||||
<div class="col-sm-10">
|
||||
<select class="form-control" name="config_conn_allow">
|
||||
<option {{if eq true .c.ConfigConnAllow}}selected{{end}} value="1" langtag="word-yes"></option>
|
||||
<option {{if eq false .c.ConfigConnAllow}}selected{{end}} value="0" langtag="word-no"></option>
|
||||
<option {{if eq true .c.ConfigConnAllow}}selected{{end}} value="1" langtag="word-yes">
|
||||
</option>
|
||||
<option {{if eq false .c.ConfigConnAllow}}selected{{end}} value="0" langtag="word-no">
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" id="compress">
|
||||
<!-- <div class="form-group" id="compress">
|
||||
<label class="control-label font-bold" langtag="word-compress"></label>
|
||||
<div class="col-sm-10">
|
||||
<select class="form-control" name="compress">
|
||||
@@ -114,12 +126,42 @@
|
||||
<option {{if eq true .c.Cnf.Crypt}}selected{{end}} value="1" langtag="word-yes"></option>
|
||||
</select>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class="form-group" id="ip_white">
|
||||
<label class="control-label font-bold" langtag="word-ipwhite"></label>
|
||||
<div class="col-sm-10">
|
||||
<select class="form-control" name="ipwhite" onchange="changeIpWhite()">
|
||||
<option {{if eq false .c.IpWhite}}selected{{end}} value="0" langtag="word-no"></option>
|
||||
<option {{if eq true .c.IpWhite}}selected{{end}} value="1" langtag="word-yes"></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group" id="ip_white_pass" style="display: none;">
|
||||
<label class="control-label font-bold" langtag="word-ipwhitepass"></label>
|
||||
<div class="col-sm-10">
|
||||
<input class="form-control" type="text" name="ipwhitepass" placeholder=""
|
||||
langtag="info-input-whitepass" value="{{.c.IpWhitePass}}">
|
||||
<span class="help-block m-b-none" langtag="info-ipwhitepass"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group" id="ip_white_list" style="display: none;">
|
||||
<label class="control-label font-bold" langtag="word-ipwhitelist"></label>
|
||||
<div class="col-sm-10">
|
||||
<textarea class="form-control" rows="4" type="text" name="ipwhitelist" placeholder=""
|
||||
langtag="info-suchasblackiplist">{{.IpWhiteList}}</textarea>
|
||||
<span class="help-block m-b-none" langtag="info-descblackiplist"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group" id="black_ip_list">
|
||||
<label class="control-label font-bold" langtag="word-blackiplist"></label>
|
||||
<div class="col-sm-10">
|
||||
<textarea class="form-control" rows="4" type="text" name="blackiplist" placeholder="" langtag="info-suchasblackiplist">{{.BlackIpList}}</textarea>
|
||||
<textarea class="form-control" rows="4" type="text" name="blackiplist" placeholder=""
|
||||
langtag="info-suchasblackiplist">{{.BlackIpList}}</textarea>
|
||||
<span class="help-block m-b-none" langtag="info-descblackiplist"></span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -127,8 +169,9 @@
|
||||
<div class="hr-line-dashed"></div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-4 col-sm-offset-2">
|
||||
<button class="btn btn-success" type="button" onclick="submitform('add', '{{.web_base_url}}/client/edit', $('form').serializeArray())"> <i
|
||||
class="fa fa-fw fa-lg fa-save"></i><span langtag="word-save"></span>
|
||||
<button class="btn btn-success" type="button"
|
||||
onclick="submitform('add', '{{.web_base_url}}/client/edit', $('form').serializeArray())">
|
||||
<i class="fa fa-fw fa-lg fa-save"></i><span langtag="word-save"></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -137,3 +180,24 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
function changeIpWhite() {
|
||||
var ipWhite = $('select[name="ipwhite"]').val();
|
||||
if (ipWhite == '1') {
|
||||
$('#ip_white_pass').show();
|
||||
$('#ip_white_list').show();
|
||||
$('#black_ip_list').hide();
|
||||
} else {
|
||||
$('#ip_white_pass').hide();
|
||||
$('#ip_white_list').hide();
|
||||
$('#black_ip_list').show();
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
// 页面加载时初始化显示状态
|
||||
changeIpWhite();
|
||||
});
|
||||
</script>
|
||||
@@ -67,11 +67,12 @@
|
||||
+ '<b langtag="word-webpassword"></b>: ' + row.WebPassword + ' '
|
||||
+ '<b langtag="word-basicusername"></b>: ' + row.Cnf.U + ' '
|
||||
+ '<b langtag="word-basicpassword"></b>: ' + row.Cnf.P + ' <br/><br/>'
|
||||
+ '<b langtag="word-crypt"></b>: <span langtag="word-' + row.Cnf.Crypt + '"></span> '
|
||||
+ '<b langtag="word-compress"></b>: <span langtag="word-' + row.Cnf.Compress + '"></span> '
|
||||
+ '<b langtag="word-connectbyconfig"></b>: <span langtag="word-' + row.ConfigConnAllow + '"></span> <br/><br/>'
|
||||
+ '<b langtag="word-ipwhite"></b>: ' + row.IpWhite + ' '
|
||||
+ '<b langtag="word-ipwhitepass"></b>: ' + row.IpWhitePass + ' <br/>'
|
||||
+ '<b langtag="word-ipwhitelist"></b>: ' + row.IpWhiteList + ' <br/>'
|
||||
+ '<b langtag="word-blackip"></b>: ' + row.BlackIpList + ' <br/><br/>'
|
||||
+ '<b langtag="word-createtime"></b>: ' + row.CreateTime + ' <br/><br/>'
|
||||
+ '<b langtag="word-createtime"></b>: ' + row.CreateTime + ' <br/>'
|
||||
+ '<b langtag="word-lastonlinetime"></b>: ' + row.LastOnlineTime + ' <br/><br/>'
|
||||
+ '<b langtag="word-quicklycommand"></b>: <span>' + encodeToBase64('{{.ip}}:{{.p}} ' + row.VerifyKey) + '</span> <button class="copy btn btn-info btn-xs" onclick="copyCommand(this)" data-clipboard-text="">复制</button><br/>'
|
||||
+ '<b langtag="word-tlsquicklycommand"></b>: <span>' + encodeToBase64('{{.ip}}:{{.tls_p}} ' + row.VerifyKey + ' true') + '</span> <button class="copy btn btn-info btn-xs" onclick="copyCommand(this)" data-clipboard-text="">复制</button><br/>'
|
||||
|
||||
@@ -18,6 +18,14 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group" id="server_url">
|
||||
<label class="control-label font-bold" langtag="word-serverurl"></label>
|
||||
<div class="col-sm-10">
|
||||
<input class="form-control" value="{{.serverUrl}}" type="text" name="serverUrl"
|
||||
placeholder="" langtag="info-servertips">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-4 col-sm-offset-2">
|
||||
<button class="btn btn-success" type="button"
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<script src="{{.web_base_url}}/static/js/jquery-3.4.1.min.js"></script>
|
||||
<script src="{{.web_base_url}}/static/js/bootstrap.min.js"></script>
|
||||
<!-- Latest compiled and minified Locales -->
|
||||
<script src="{{.web_base_url}}/static/js/language.js?v=20250528" type="text/javascript"></script>
|
||||
<script src="{{.web_base_url}}/static/js/language.js?v=202512054" type="text/javascript"></script>
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<script src="{{.web_base_url}}/static/js/jquery-3.4.1.min.js"></script>
|
||||
<script src="{{.web_base_url}}/static/js/bootstrap.min.js"></script>
|
||||
<!-- Latest compiled and minified Locales -->
|
||||
<script src="{{.web_base_url}}/static/js/language.js?v=20250528" type="text/javascript"></script>
|
||||
<script src="{{.web_base_url}}/static/js/language.js?v=202512054" type="text/javascript"></script>
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<script src="{{.web_base_url}}/static/js/echarts.min.js"></script>
|
||||
<script src="{{.web_base_url}}/static/js/inspinia.js"></script>
|
||||
<!-- Latest compiled and minified Locales -->
|
||||
<script src="{{.web_base_url}}/static/js/language.js?v=20250528" type="text/javascript"></script>
|
||||
<script src="{{.web_base_url}}/static/js/language.js?v=202512054" type="text/javascript"></script>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
Reference in New Issue
Block a user