Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a3a801370b | ||
|
|
bb9b4501c2 | ||
|
|
492c259568 | ||
|
|
c5efa76623 | ||
|
|
b44cd17324 | ||
|
|
acf7f297f0 | ||
|
|
fdb24b115b | ||
|
|
1cd77f877d | ||
|
|
f3ad499273 | ||
|
|
8fca98bdf8 | ||
|
|
7123027287 | ||
|
|
90a85b1b88 | ||
|
|
745b056be9 | ||
|
|
831fe8e32e | ||
|
|
50e2da3fcb | ||
|
|
7db25b9c3a | ||
|
|
be3358b744 | ||
|
|
965fa40429 | ||
|
|
944181c79b | ||
|
|
6332cfbf9b | ||
|
|
7cd1a0ade9 | ||
|
|
57ca48f127 | ||
|
|
08e1811dc8 | ||
|
|
d02c2b70a4 | ||
|
|
a7d23e6ff3 | ||
|
|
db954f8071 | ||
|
|
ce08f966d2 | ||
|
|
87cdc8634f | ||
|
|
3068d972ae | ||
|
|
e2e5c0dd75 | ||
|
|
ed1a361fd0 | ||
|
|
23c26f13c0 | ||
|
|
fdb674282c |
@@ -0,0 +1,27 @@
|
||||
name: Android
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
release:
|
||||
types: [published]
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
|
||||
build_android:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
- name: Build
|
||||
run: |
|
||||
chmod +x build.android.sh
|
||||
docker run --rm -i -w /app -v $(pwd):/app -e ANDROID_HOME=/usr/local/android_sdk -e GOPROXY=direct fyneio/fyne-cross:android-latest /app/build.android.sh
|
||||
- name: Upload
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
files: |
|
||||
android_client.apk
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -22,7 +22,7 @@ jobs:
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
- name: Cache Docker layers
|
||||
uses: actions/cache@v2
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||
|
||||
+61
-61
@@ -9,67 +9,67 @@ on:
|
||||
jobs:
|
||||
|
||||
build_assets:
|
||||
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
- name: Set up Go 1.x
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.22
|
||||
id: go
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
- name: Get dependencies
|
||||
run: |
|
||||
go get -v -t -d ./...
|
||||
if [ -f Gopkg.toml ]; then
|
||||
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
|
||||
dep ensure
|
||||
fi
|
||||
- name: Build
|
||||
run: |
|
||||
chmod +x build.assets.sh
|
||||
./build.assets.sh
|
||||
- name: Upload
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
files: |
|
||||
freebsd_386_client.tar.gz
|
||||
freebsd_386_server.tar.gz
|
||||
freebsd_amd64_client.tar.gz
|
||||
freebsd_amd64_server.tar.gz
|
||||
freebsd_arm_client.tar.gz
|
||||
freebsd_arm_server.tar.gz
|
||||
linux_386_client.tar.gz
|
||||
linux_386_server.tar.gz
|
||||
linux_amd64_client.tar.gz
|
||||
linux_amd64_server.tar.gz
|
||||
linux_arm64_client.tar.gz
|
||||
linux_arm64_server.tar.gz
|
||||
linux_arm_v5_client.tar.gz
|
||||
linux_arm_v6_client.tar.gz
|
||||
linux_arm_v7_client.tar.gz
|
||||
linux_arm_v5_server.tar.gz
|
||||
linux_arm_v6_server.tar.gz
|
||||
linux_arm_v7_server.tar.gz
|
||||
linux_mips64le_client.tar.gz
|
||||
linux_mips64le_server.tar.gz
|
||||
linux_mips64_client.tar.gz
|
||||
linux_mips64_server.tar.gz
|
||||
linux_mipsle_client.tar.gz
|
||||
linux_mipsle_server.tar.gz
|
||||
linux_mips_client.tar.gz
|
||||
linux_mips_server.tar.gz
|
||||
darwin_amd64_client.tar.gz
|
||||
darwin_amd64_server.tar.gz
|
||||
darwin_arm64_client.tar.gz
|
||||
darwin_arm64_server.tar.gz
|
||||
windows_386_client.tar.gz
|
||||
windows_386_server.tar.gz
|
||||
windows_amd64_client.tar.gz
|
||||
windows_amd64_server.tar.gz
|
||||
npc_sdk.tar.gz
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Set up Go 1.x
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.22
|
||||
id: go
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
- name: Get dependencies
|
||||
run: |
|
||||
go get -v -t -d ./...
|
||||
if [ -f Gopkg.toml ]; then
|
||||
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
|
||||
dep ensure
|
||||
fi
|
||||
- name: Build
|
||||
run: |
|
||||
chmod +x build.assets.sh
|
||||
./build.assets.sh
|
||||
- name: Upload
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
files: |
|
||||
freebsd_386_client.tar.gz
|
||||
freebsd_386_server.tar.gz
|
||||
freebsd_amd64_client.tar.gz
|
||||
freebsd_amd64_server.tar.gz
|
||||
freebsd_arm_client.tar.gz
|
||||
freebsd_arm_server.tar.gz
|
||||
linux_386_client.tar.gz
|
||||
linux_386_server.tar.gz
|
||||
linux_amd64_client.tar.gz
|
||||
linux_amd64_server.tar.gz
|
||||
linux_arm64_client.tar.gz
|
||||
linux_arm64_server.tar.gz
|
||||
linux_arm_v5_client.tar.gz
|
||||
linux_arm_v6_client.tar.gz
|
||||
linux_arm_v7_client.tar.gz
|
||||
linux_arm_v5_server.tar.gz
|
||||
linux_arm_v6_server.tar.gz
|
||||
linux_arm_v7_server.tar.gz
|
||||
linux_mips64le_client.tar.gz
|
||||
linux_mips64le_server.tar.gz
|
||||
linux_mips64_client.tar.gz
|
||||
linux_mips64_server.tar.gz
|
||||
linux_mipsle_client.tar.gz
|
||||
linux_mipsle_server.tar.gz
|
||||
linux_mips_client.tar.gz
|
||||
linux_mips_server.tar.gz
|
||||
darwin_amd64_client.tar.gz
|
||||
darwin_amd64_server.tar.gz
|
||||
darwin_arm64_client.tar.gz
|
||||
darwin_arm64_server.tar.gz
|
||||
windows_386_client.tar.gz
|
||||
windows_386_server.tar.gz
|
||||
windows_amd64_client.tar.gz
|
||||
windows_amd64_server.tar.gz
|
||||
npc_sdk.tar.gz
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
@@ -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的基础上二次开发而来。
|
||||
|
||||
@@ -12,22 +12,70 @@
|
||||
***宝塔面板***:[宝塔面板 Docker](docs/bt.md)
|
||||
|
||||
# 交流群
|
||||
聊天灌水QQ群:770569342,619833483(已满)
|
||||
聊天灌水QQ群:619833483(2000人群),770569342
|
||||
|
||||
# 公益云内网穿透
|
||||
# 免费NPS节点
|
||||
https://natnps.com/
|
||||
公益NPS内网穿透服务,长期免费,6M带宽,3条隧道,不限流量,欢迎来嫖,自行注册账号。
|
||||
免费NPS内网穿透节点,长期免费,6M带宽,3条隧道,欢迎来嫖,自行注册账号。
|
||||
|
||||
# 特价云服务器
|
||||
国内BGP,游戏开服,2核 2G 15M上行 25元/月,[专属连接,首月5折](https://www.rainyun.com/MjY0MzY1_)
|
||||
|
||||
# 提示
|
||||
强烈推荐使用无配置文件模式启动客户端(删除掉npc.exe 目录下的`conf`文件夹即可),所有数据应该在服务端保存和配置,而客户端只做连接转发。客户端配置文件对小白极不友好,配置繁琐,容易出错。
|
||||
0.26.21 版本后的客户端,无需再通过命令行方式启动、安装、卸载客户端,直接双击运行,按照提示输入指令即可完成,非常方便。
|
||||
|
||||
|
||||
# 更新日志
|
||||
- 2025-11-051 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)
|
||||
- 域名解析自动HTTPS逻辑bug [273](https://github.com/yisier/nps/issues/273)
|
||||
|
||||
|
||||
- 2025-05-28 v0.26.25
|
||||
新增:
|
||||
- nps增加`nps(.exe) -server` 命令,用于管理NPS服务,安装和卸载服务在 Linux 下需要有 sudo 权限,Windows 下需要有管理员权限。
|
||||

|
||||
- 增加【TLS快捷启动命令】,可用于在tls模式下,快速启动客户端。 [257](https://github.com/yisier/nps/issues/257)
|
||||
|
||||
|
||||
- 2025-04-16 v0.26.24
|
||||
新增:
|
||||
- 隧道支持复制功能,在隧道页面增加复制按钮,除了端口号为随机生成外,其他参数全部拷贝。[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。
|
||||
|
||||
# 捐赠
|
||||

|
||||
修复:
|
||||
- 客户端较多时,协程增长过快,感谢 [@huanglei288766](https://github.com/yisier/nps/pull/244) 的PR
|
||||
|
||||
|
||||
- 2025-01-23 v0.26.22
|
||||
优化:
|
||||
- 客户端注册系统服务时,(新版客户端注册方式,非 install 命令) 将按照 `npc-[vkey].log` 格式保存日志,每个客户端VKEY单独一个日志文件,windows 日志位于 `npc.exe` 同级目录下,linux 位于 `/var/log/`目录。
|
||||
- 域名模式,HTTPS证书支持上传文件和文件路径,系统将自动识别路径还是证书内容。 [#175](https://github.com/yisier/nps/issues/175)
|
||||
|
||||
修复:
|
||||
- ipv6地址显示不全 [#237](https://github.com/yisier/nps/issues/237)
|
||||
|
||||
|
||||
## 更新日志
|
||||
- 2025-01-07 v0.26.21
|
||||
新增:
|
||||
- 客户端列表页面新增【快捷启动命令】,此命令为连接地址+链接秘钥的base64编码,方便一键启动、一键安装客户端。
|
||||
@@ -35,7 +83,7 @@ https://natnps.com/
|
||||
|
||||
优化:
|
||||
- 修改vkey生成方式,由16位缩短至10位,截取uuid前10位,避免重复。
|
||||
- 优化客户端启动方式,当npc文件目录下无配置文件时,可直接双击运行客户端,输入命令完成启动、安装、卸载客户端,直接启动和安装服务时需要输入【快捷启动命令】,卸载服务、启动服务、停止服务时,只需输入隧道秘钥【vkey】即可。
|
||||
- 优化客户端启动方式,当npc文件目录下无配置文件时,可直接双击运行客户端,输入命令完成启动、安装、卸载客户端,直接启动和安装服务时需要输入【快捷启动命令】,卸载服务、启动服务、停止服务时,只需输入隧道秘钥【vkey】即可。安装服务以 nps-client-vkey 方式命名 ,实现注册多个服务。
|
||||

|
||||
|
||||
|
||||
@@ -138,3 +186,8 @@ https://natnps.com/
|
||||
- 2022-09-14:
|
||||
修改NPS工作目录为当前可执行文件目录(即配置文件和nps可执行文件放在同一目录下,直接执行nps文件即可),去除注册系统服务,启动、停止、升级等命令
|
||||
|
||||
|
||||
|
||||
|
||||
# 捐赠
|
||||

|
||||
|
||||
+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.21
|
||||
export VERSION=0.26.27
|
||||
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
|
||||
|
||||
+46
-4
@@ -4,6 +4,7 @@ import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"ehang.io/nps/lib/nps_mux"
|
||||
"github.com/pires/go-proxyproto"
|
||||
"net"
|
||||
"net/http"
|
||||
"strconv"
|
||||
@@ -34,7 +35,7 @@ type TRPClient struct {
|
||||
once sync.Once
|
||||
}
|
||||
|
||||
//new client
|
||||
// new client
|
||||
func NewRPClient(svraddr string, vKey string, bridgeConnType string, proxyUrl string, cnf *config.Config, disconnectTime int) *TRPClient {
|
||||
return &TRPClient{
|
||||
svrAddr: svraddr,
|
||||
@@ -51,7 +52,7 @@ func NewRPClient(svraddr string, vKey string, bridgeConnType string, proxyUrl st
|
||||
var NowStatus int
|
||||
var CloseClient bool
|
||||
|
||||
//start
|
||||
// start
|
||||
func (s *TRPClient) Start() {
|
||||
CloseClient = false
|
||||
retry:
|
||||
@@ -85,7 +86,7 @@ retry:
|
||||
s.handleMain()
|
||||
}
|
||||
|
||||
//handle main connection
|
||||
// handle main connection
|
||||
func (s *TRPClient) handleMain() {
|
||||
for {
|
||||
flags, err := s.signal.ReadFlag()
|
||||
@@ -152,7 +153,7 @@ func (s *TRPClient) newUdpConn(localAddr, rAddr string, md5Password string) {
|
||||
}
|
||||
}
|
||||
|
||||
//pmux tunnel
|
||||
// pmux tunnel
|
||||
func (s *TRPClient) newChan() {
|
||||
tunnel, err := NewConn(s.bridgeConnType, s.vKey, s.svrAddr, common.WORK_CHAN, s.proxyUrl)
|
||||
if err != nil {
|
||||
@@ -219,6 +220,47 @@ func (s *TRPClient) handleChan(src net.Conn) {
|
||||
src.Close()
|
||||
} else {
|
||||
logs.Trace("new %s connection with the goal of %s, remote address:%s", lk.ConnType, lk.Host, lk.RemoteAddr)
|
||||
|
||||
if lk.ProtoVersion == "V1" || lk.ProtoVersion == "V2" {
|
||||
var addr = targetConn.RemoteAddr()
|
||||
if lk.RemoteAddr != "" {
|
||||
s := strings.Split(lk.RemoteAddr, ":")[1]
|
||||
port, _ := strconv.Atoi(s)
|
||||
addr = &net.TCPAddr{
|
||||
IP: net.ParseIP(strings.Split(lk.RemoteAddr, ":")[0]),
|
||||
Port: port,
|
||||
}
|
||||
}
|
||||
|
||||
var version byte
|
||||
|
||||
if lk.ProtoVersion == "V1" {
|
||||
version = 1
|
||||
} else if lk.ProtoVersion == "V2" {
|
||||
version = 2
|
||||
}
|
||||
|
||||
transportProtocol := proxyproto.TCPv4
|
||||
if strings.Contains(addr.String(), ".") {
|
||||
transportProtocol = proxyproto.TCPv4
|
||||
} else {
|
||||
transportProtocol = proxyproto.TCPv6
|
||||
}
|
||||
|
||||
header := &proxyproto.Header{
|
||||
Command: proxyproto.PROXY,
|
||||
SourceAddr: addr,
|
||||
DestinationAddr: targetConn.RemoteAddr(),
|
||||
Version: version,
|
||||
TransportProtocol: transportProtocol,
|
||||
}
|
||||
|
||||
_, err2 := header.WriteTo(targetConn)
|
||||
if err2 != nil {
|
||||
logs.Error(err2)
|
||||
}
|
||||
}
|
||||
|
||||
conn.CopyWaitGroup(src, targetConn, lk.Crypt, lk.Compress, nil, nil, false, nil, nil)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -172,7 +172,7 @@ func handleP2PVisitor(localTcpConn net.Conn, config *config.CommonConfig, l *con
|
||||
}
|
||||
logs.Trace("start trying to connect with the server")
|
||||
//TODO just support compress now because there is not tls file in client packages
|
||||
link := conn.NewLink(common.CONN_TCP, l.Target, false, config.Client.Cnf.Compress, localTcpConn.LocalAddr().String(), false)
|
||||
link := conn.NewLink(common.CONN_TCP, l.Target, false, config.Client.Cnf.Compress, localTcpConn.LocalAddr().String(), false, "")
|
||||
if target, err := p2pNetBridge.SendLinkInfo(0, link, nil); err != nil {
|
||||
logs.Error(err)
|
||||
udpConnStatus = false
|
||||
|
||||
+40
-6
@@ -344,14 +344,25 @@ func inputCmd() {
|
||||
func startNpcServer(startCmd string) {
|
||||
var serAddr string
|
||||
var vkey string
|
||||
var tls string
|
||||
array := strings.Fields(startCmd)
|
||||
serAddr = array[0]
|
||||
vkey = array[1]
|
||||
|
||||
if len(array) > 2 {
|
||||
tls = array[2]
|
||||
}
|
||||
go func() {
|
||||
for {
|
||||
logs.Info("start cmd:-server=" + serAddr + " -vkey=" + vkey)
|
||||
logs.Info("the version of client is %s, the core version of client is %s", version.VERSION, version.GetVersion())
|
||||
if tls == "-tls_enable=true" || len(array) > 2 {
|
||||
client.SetTlsEnable(true)
|
||||
logs.Info("start cmd:-server=" + serAddr + " -vkey=" + vkey + " " + tls)
|
||||
logs.Info("the version of client is %s, the core version of client is %s,tls enable is %t", version.VERSION, version.GetVersion(), client.GetTlsEnable())
|
||||
} else {
|
||||
client.SetTlsEnable(false)
|
||||
logs.Info("start cmd:-server=" + serAddr + " -vkey=" + vkey)
|
||||
logs.Info("the version of client is %s, the core version of client is %s", version.VERSION, version.GetVersion())
|
||||
}
|
||||
|
||||
client.NewRPClient(serAddr, vkey, *connType, *proxyUrl, nil, *disconnectTime).Start()
|
||||
logs.Info("Client closed! It will be reconnected in five seconds")
|
||||
time.Sleep(time.Second * 5)
|
||||
@@ -399,11 +410,16 @@ func systemService(flag string) {
|
||||
|
||||
for _, item := range cmdArray {
|
||||
array := strings.Fields(item)
|
||||
systemPro(flag, array[0], array[1])
|
||||
// tls
|
||||
if len(array) > 2 {
|
||||
systemPro(flag, array[0], array[1], true)
|
||||
} else {
|
||||
systemPro(flag, array[0], array[1], false)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for _, key := range vkeys {
|
||||
systemPro(flag, "", key)
|
||||
systemPro(flag, "", key, false)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -412,7 +428,7 @@ func systemService(flag string) {
|
||||
return
|
||||
}
|
||||
|
||||
func systemPro(flag string, serAddr string, vkey string) {
|
||||
func systemPro(flag string, serAddr string, vkey string, tls bool) {
|
||||
// init service
|
||||
prg := &npc{
|
||||
exit: make(chan struct{}),
|
||||
@@ -430,7 +446,25 @@ func systemPro(flag string, serAddr string, vkey string) {
|
||||
case "1":
|
||||
svcConfig.Arguments = append(svcConfig.Arguments, "-server="+serAddr)
|
||||
svcConfig.Arguments = append(svcConfig.Arguments, "-vkey="+vkey)
|
||||
if tls {
|
||||
svcConfig.Arguments = append(svcConfig.Arguments, "-tls_enable=true")
|
||||
}
|
||||
svcConfig.Arguments = append(svcConfig.Arguments, "-debug=false")
|
||||
|
||||
*logPath = common.GetNpcLogPath()
|
||||
if common.IsWindows() {
|
||||
*logPath = strings.Replace(*logPath, "\\", "\\\\", -1)
|
||||
}
|
||||
|
||||
*logPath = strings.Replace(*logPath, "npc.log", "npc-"+vkey+".log", -1)
|
||||
svcConfig.Arguments = append(svcConfig.Arguments, "-log_path="+*logPath)
|
||||
|
||||
logs.NewLogger()
|
||||
logs.Reset()
|
||||
logs.EnableFuncCallDepth(true)
|
||||
logs.SetLogFuncCallDepth(3)
|
||||
logs.SetLogger(logs.AdapterFile, `{"level":`+*logLevel+`,"filename":"`+*logPath+`","daily":false,"maxlines":100000,"color":true}`)
|
||||
|
||||
install.InstallNpc()
|
||||
err := service.Control(s, "install")
|
||||
if err != nil {
|
||||
|
||||
+211
-9
@@ -1,21 +1,25 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"ehang.io/nps/bridge"
|
||||
"ehang.io/nps/lib/daemon"
|
||||
"ehang.io/nps/server"
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/fatih/color"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"ehang.io/nps/lib/file"
|
||||
"ehang.io/nps/lib/install"
|
||||
"ehang.io/nps/lib/version"
|
||||
"ehang.io/nps/server"
|
||||
"ehang.io/nps/server/connection"
|
||||
"ehang.io/nps/server/tool"
|
||||
"ehang.io/nps/web/routers"
|
||||
@@ -29,20 +33,30 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
level string
|
||||
ver = flag.Bool("version", false, "show current version")
|
||||
confPath = flag.String("conf_path", "", "set current confPath")
|
||||
level string
|
||||
ver = flag.Bool("version", false, "show current version")
|
||||
confPath = flag.String("conf_path", "", "set current confPath")
|
||||
serverCmd = flag.Bool("server", false, "NPS管理脚本")
|
||||
npsLogPath = flag.String("log_path", "", "nps log path")
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
debug.SetMaxThreads(1000000)
|
||||
|
||||
flag.Parse()
|
||||
// init log
|
||||
if *ver {
|
||||
common.PrintVersion()
|
||||
return
|
||||
}
|
||||
if *serverCmd {
|
||||
printSlogan()
|
||||
inputCmd()
|
||||
return
|
||||
}
|
||||
|
||||
var logPath string
|
||||
// *confPath why get null value ?
|
||||
for _, v := range os.Args[1:] {
|
||||
switch v {
|
||||
@@ -52,6 +66,10 @@ func main() {
|
||||
if strings.Contains(v, "-conf_path=") {
|
||||
common.ConfPath = strings.Replace(v, "-conf_path=", "", -1)
|
||||
}
|
||||
|
||||
if strings.Contains(v, "-log_path=") {
|
||||
logPath = strings.Replace(v, "-log_path=", "", -1)
|
||||
}
|
||||
}
|
||||
|
||||
if err := beego.LoadAppConfig("ini", filepath.Join(common.GetRunPath(), "conf", "nps.conf")); err != nil {
|
||||
@@ -65,13 +83,17 @@ func main() {
|
||||
logs.Reset()
|
||||
logs.EnableFuncCallDepth(true)
|
||||
logs.SetLogFuncCallDepth(3)
|
||||
logPath := beego.AppConfig.String("log_path")
|
||||
|
||||
if logPath == "" {
|
||||
logPath = common.GetLogPath()
|
||||
}
|
||||
if common.IsWindows() {
|
||||
logPath = strings.Replace(logPath, "\\", "\\\\", -1)
|
||||
logPath := beego.AppConfig.String("log_path")
|
||||
if logPath == "" {
|
||||
logPath = common.GetLogPath()
|
||||
}
|
||||
if common.IsWindows() {
|
||||
logPath = strings.Replace(logPath, "\\", "\\\\", -1)
|
||||
}
|
||||
}
|
||||
|
||||
// init service
|
||||
options := make(service.KeyValue)
|
||||
svcConfig := &service.Config{
|
||||
@@ -183,6 +205,185 @@ func main() {
|
||||
_ = s.Run()
|
||||
}
|
||||
|
||||
func printSlogan() {
|
||||
green := color.New(color.FgGreen).SprintFunc()
|
||||
// 第一次输入,如果输入 1,2,3,4 则需要输入秘钥,否则
|
||||
|
||||
fmt.Printf("%s", green(""))
|
||||
|
||||
fmt.Printf("\033[32;0m欢迎使用 NPS 管理脚本 \n")
|
||||
fmt.Printf("\033[0m") // 重置颜色
|
||||
|
||||
fmt.Printf("\n")
|
||||
|
||||
fmt.Printf("\u001B[32m输入[1]\u001B[0m - 安装 NPS\n")
|
||||
fmt.Printf("\u001B[32m输入[2]\u001B[0m - 卸载 NPS\n")
|
||||
fmt.Printf("\u001B[32m输入[3]\u001B[0m - 更新 NPS\n")
|
||||
fmt.Printf("---------------------\n")
|
||||
fmt.Printf("\u001B[32m输入[4]\u001B[0m - 查看状态\n")
|
||||
fmt.Printf("---------------------\n")
|
||||
fmt.Printf("\u001B[32m输入[5]\u001B[0m - 启动 NPS\n")
|
||||
fmt.Printf("\u001B[32m输入[6]\u001B[0m - 停止 NPS\n")
|
||||
fmt.Printf("\u001B[32m输入[7]\u001B[0m - 重启 NPS\n")
|
||||
fmt.Printf("---------------------\n")
|
||||
fmt.Printf("\u001B[32m输入[0]\u001B[0m - 退出脚本\n")
|
||||
fmt.Printf("---------------------\n")
|
||||
fmt.Printf("\n")
|
||||
|
||||
}
|
||||
|
||||
func inputCmd() {
|
||||
var flag string
|
||||
fmt.Printf("请输入[0-7]:")
|
||||
|
||||
stdin := bufio.NewReader(os.Stdin)
|
||||
_, err := fmt.Fscanln(stdin, &flag)
|
||||
if err != nil {
|
||||
fmt.Println("输入有误")
|
||||
} else {
|
||||
if flag == "0" {
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// init service
|
||||
|
||||
prg := &nps{
|
||||
exit: make(chan struct{}),
|
||||
}
|
||||
options := make(service.KeyValue)
|
||||
svcConfig := &service.Config{
|
||||
Name: "Nps",
|
||||
DisplayName: "nps内网穿透代理服务器",
|
||||
Description: "一款轻量级、功能强大的内网穿透代理服务器。支持tcp、udp流量转发,支持内网http代理、内网socks5代理,同时支持snappy压缩、站点保护、加密传输、多路复用、header修改等。支持web图形化管理,集成多用户模式。",
|
||||
Option: options,
|
||||
}
|
||||
s, _ := service.New(prg, svcConfig)
|
||||
|
||||
switch flag {
|
||||
case "1":
|
||||
// uninstall before
|
||||
_ = service.Control(s, "stop")
|
||||
_ = service.Control(s, "uninstall")
|
||||
binPath := install.InstallNpsToCurrentDir()
|
||||
|
||||
beego.LoadAppConfig("ini", filepath.Join(common.GetAppPath(), "conf", "nps.conf"))
|
||||
|
||||
logPath := filepath.Join(common.GetAppPath(), "nps.log")
|
||||
if common.IsWindows() {
|
||||
logPath = strings.Replace(logPath, "\\", "\\\\", -1)
|
||||
}
|
||||
svcConfig.Arguments = append(svcConfig.Arguments, "service")
|
||||
svcConfig.Arguments = append(svcConfig.Arguments, "-conf_path="+common.GetAppPath())
|
||||
svcConfig.Arguments = append(svcConfig.Arguments, "-log_path="+logPath)
|
||||
|
||||
fmt.Println("日志文件路径为:", logPath)
|
||||
|
||||
svcConfig.Executable = binPath
|
||||
s, err := service.New(prg, svcConfig)
|
||||
|
||||
if service.Platform() == "unix-systemv" {
|
||||
logs.Info("unix-systemv service")
|
||||
confPath := "/etc/init.d/" + svcConfig.Name
|
||||
os.Symlink(confPath, "/etc/rc.d/S90"+svcConfig.Name)
|
||||
os.Symlink(confPath, "/etc/rc.d/K02"+svcConfig.Name)
|
||||
}
|
||||
|
||||
err = service.Control(s, "install")
|
||||
if err != nil {
|
||||
logs.Error("Valid actions: %q\n%s", service.ControlAction, err.Error())
|
||||
} else {
|
||||
fmt.Println("NPS服务安装成功")
|
||||
}
|
||||
|
||||
err = service.Control(s, "start")
|
||||
if err != nil {
|
||||
fmt.Println("启动NPS服务失败", err)
|
||||
} else {
|
||||
fmt.Println("NPS服务已启动,管理面板访问地址:127.0.0.1:" + beego.AppConfig.String("web_port"))
|
||||
}
|
||||
|
||||
break
|
||||
case "2":
|
||||
// 卸载系统服务
|
||||
err := service.Control(s, "stop")
|
||||
if err != nil {
|
||||
fmt.Println("NPS服务停止失败", err)
|
||||
} else {
|
||||
fmt.Println("NPS服务已停止")
|
||||
}
|
||||
|
||||
err = service.Control(s, "uninstall")
|
||||
if err != nil {
|
||||
logs.Error("NPS服务卸载失败")
|
||||
}
|
||||
if service.Platform() == "unix-systemv" {
|
||||
logs.Info("unix-systemv service")
|
||||
os.Remove("/etc/rc.d/S90" + svcConfig.Name)
|
||||
os.Remove("/etc/rc.d/K02" + svcConfig.Name)
|
||||
}
|
||||
|
||||
if err == nil {
|
||||
fmt.Println("NPS服务已卸载成功")
|
||||
}
|
||||
break
|
||||
case "3":
|
||||
install.UpdateNpsNew()
|
||||
return
|
||||
case "4":
|
||||
// 查看状态
|
||||
var statusMsg = ""
|
||||
status, err := s.Status()
|
||||
if err != nil {
|
||||
statusMsg = "\u001B[31m未运行\u001B[0m"
|
||||
} else {
|
||||
if status == 1 {
|
||||
statusMsg = "\u001B[32m运行中\u001B[0m"
|
||||
} else {
|
||||
statusMsg = "\u001B[31m未运行\u001B[0m"
|
||||
}
|
||||
}
|
||||
fmt.Println("NPS服务状态:" + statusMsg)
|
||||
break
|
||||
case "5":
|
||||
// 启动 NPS
|
||||
err := service.Control(s, "start")
|
||||
if err != nil {
|
||||
fmt.Println("NPS服务启动失败", err)
|
||||
} else {
|
||||
fmt.Println("NPS服务启动成功")
|
||||
}
|
||||
|
||||
break
|
||||
case "6":
|
||||
// 停止 NPS
|
||||
err := service.Control(s, "stop")
|
||||
if err != nil {
|
||||
fmt.Println("NPS服务停止失败", err)
|
||||
} else {
|
||||
fmt.Println("NPS服务停止成功")
|
||||
}
|
||||
|
||||
break
|
||||
case "7":
|
||||
// 重启 NPS
|
||||
err := service.Control(s, "restart")
|
||||
if err != nil {
|
||||
fmt.Println("NPS服务重启失败", err)
|
||||
} else {
|
||||
fmt.Println("NPS服务重启成功")
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
inputCmd()
|
||||
}
|
||||
|
||||
func installNps() {
|
||||
|
||||
}
|
||||
|
||||
type nps struct {
|
||||
exit chan struct{}
|
||||
}
|
||||
@@ -229,6 +430,7 @@ func run() {
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
logs.Info("日志路径111:" + *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()
|
||||
|
||||
@@ -12,10 +12,11 @@ require (
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/kardianos/service v1.2.0
|
||||
github.com/panjf2000/ants/v2 v2.4.2
|
||||
github.com/pires/go-proxyproto v0.8.0
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/shirou/gopsutil/v3 v3.23.10
|
||||
github.com/xtaci/kcp-go v5.4.20+incompatible
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4
|
||||
golang.org/x/net v0.23.0
|
||||
)
|
||||
|
||||
require (
|
||||
@@ -54,10 +55,10 @@ require (
|
||||
github.com/ulikunitz/xz v0.5.6 // indirect
|
||||
github.com/xtaci/lossyconn v0.0.0-20190602105132-8df528c0c9ae // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.3 // indirect
|
||||
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 // indirect
|
||||
golang.org/x/crypto v0.21.0 // indirect
|
||||
golang.org/x/image v0.0.0-20200430140353-33d19683fad8 // indirect
|
||||
golang.org/x/sys v0.25.0 // indirect
|
||||
golang.org/x/text v0.3.3 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.2.8 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
@@ -121,6 +121,8 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLA
|
||||
github.com/panjf2000/ants/v2 v2.4.2 h1:kesjjo8JipN3vNNg1XaiXaeSs6xJweBTgenkBtsrHf8=
|
||||
github.com/panjf2000/ants/v2 v2.4.2/go.mod h1:f6F0NZVFsGCp5A7QW/Zj/m92atWwOkY0OIhFxRNFr4A=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pires/go-proxyproto v0.8.0 h1:5unRmEAPbHXHuLjDg01CxJWf91cw3lKHc/0xzKpXEe0=
|
||||
github.com/pires/go-proxyproto v0.8.0/go.mod h1:iknsfgnH8EkjrMeMyvfKByp9TiBZCKZM0jx2xmKqnVY=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
@@ -183,8 +185,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 h1:It14KIkyBFYkHkwZ7k45minvA9aorojkyjGk9KJ5B/w=
|
||||
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||
golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
|
||||
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.0.0-20200430140353-33d19683fad8 h1:6WW6V3x1P/jokJBpRQYUJnMHRP6isStQwCozxnU7XQw=
|
||||
@@ -203,9 +205,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0=
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
|
||||
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@@ -220,9 +221,7 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20200720211630-cb9d2d5c5666/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
@@ -230,11 +229,11 @@ golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
|
||||
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
|
||||
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/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 |
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 26 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
|
||||
|
||||
`
|
||||
)
|
||||
|
||||
+20
-10
@@ -8,10 +8,14 @@ import (
|
||||
|
||||
var ConfPath string
|
||||
|
||||
//Get the currently selected configuration file directory
|
||||
//For non-Windows systems, select the /etc/nps as config directory if exist, or select ./
|
||||
//windows system, select the C:\Program Files\nps as config directory if exist, or select ./
|
||||
// Get the currently selected configuration file directory
|
||||
// For non-Windows systems, select the /etc/nps as config directory if exist, or select ./
|
||||
// windows system, select the C:\Program Files\nps as config directory if exist, or select ./
|
||||
func GetRunPath() string {
|
||||
if ConfPath != "" {
|
||||
return ConfPath
|
||||
}
|
||||
|
||||
var path string
|
||||
if len(os.Args) == 1 {
|
||||
if !IsWindows() {
|
||||
@@ -28,7 +32,7 @@ func GetRunPath() string {
|
||||
return path
|
||||
}
|
||||
|
||||
//Different systems get different installation paths
|
||||
// Different systems get different installation paths
|
||||
func GetInstallPath() string {
|
||||
var path string
|
||||
|
||||
@@ -45,7 +49,7 @@ func GetInstallPath() string {
|
||||
return path
|
||||
}
|
||||
|
||||
//Get the absolute path to the running directory
|
||||
// Get the absolute path to the running directory
|
||||
func GetAppPath() string {
|
||||
if path, err := filepath.Abs(filepath.Dir(os.Args[0])); err == nil {
|
||||
return path
|
||||
@@ -53,7 +57,7 @@ func GetAppPath() string {
|
||||
return os.Args[0]
|
||||
}
|
||||
|
||||
//Determine whether the current system is a Windows system?
|
||||
// Determine whether the current system is a Windows system?
|
||||
func IsWindows() bool {
|
||||
if runtime.GOOS == "windows" {
|
||||
return true
|
||||
@@ -61,7 +65,7 @@ func IsWindows() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
//interface log file path
|
||||
// interface log file path
|
||||
func GetLogPath() string {
|
||||
var path string
|
||||
if IsWindows() {
|
||||
@@ -72,7 +76,13 @@ func GetLogPath() string {
|
||||
return path
|
||||
}
|
||||
|
||||
//interface npc log file path
|
||||
func GetLogPathCurrentPath() string {
|
||||
var path string
|
||||
path = filepath.Join(GetAppPath(), "nps.log")
|
||||
return path
|
||||
}
|
||||
|
||||
// interface npc log file path
|
||||
func GetNpcLogPath() string {
|
||||
var path string
|
||||
if IsWindows() {
|
||||
@@ -83,7 +93,7 @@ func GetNpcLogPath() string {
|
||||
return path
|
||||
}
|
||||
|
||||
//interface pid file path
|
||||
// interface pid file path
|
||||
func GetTmpPath() string {
|
||||
var path string
|
||||
if IsWindows() {
|
||||
@@ -94,7 +104,7 @@ func GetTmpPath() string {
|
||||
return path
|
||||
}
|
||||
|
||||
//config file path
|
||||
// config file path
|
||||
func GetConfigPath() string {
|
||||
var path string
|
||||
if IsWindows() {
|
||||
|
||||
+21
-2
@@ -265,8 +265,16 @@ func FormatAddress(s string) string {
|
||||
|
||||
// get address from the complete address
|
||||
func GetIpByAddr(addr string) string {
|
||||
arr := strings.Split(addr, ":")
|
||||
return arr[0]
|
||||
// 如果是 IPv6 地址,可能的格式为[2001:0db8:85a3:0000:0000:8a2e:0370:7334]:8080或[2001:0db8:85a3:0000:0000:8a2e:0370:7334]
|
||||
// IPv4 地址,可能的格式为192.168.1.1:80或192.168.1.1
|
||||
// 截取地址
|
||||
if strings.Contains(addr, "[") {
|
||||
addr = strings.Split(addr, "[")[1]
|
||||
addr = strings.Split(addr, "]")[0]
|
||||
} else {
|
||||
addr = strings.Split(addr, ":")[0]
|
||||
}
|
||||
return addr
|
||||
}
|
||||
|
||||
// get port from the complete address
|
||||
@@ -302,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)
|
||||
|
||||
+17
-15
@@ -15,13 +15,14 @@ func NewSecret(p string, conn *Conn) *Secret {
|
||||
}
|
||||
|
||||
type Link struct {
|
||||
ConnType string //连接类型
|
||||
Host string //目标
|
||||
Crypt bool //加密
|
||||
Compress bool
|
||||
LocalProxy bool
|
||||
RemoteAddr string
|
||||
Option Options
|
||||
ConnType string //连接类型
|
||||
Host string //目标
|
||||
Crypt bool //加密
|
||||
Compress bool
|
||||
LocalProxy bool
|
||||
RemoteAddr string
|
||||
ProtoVersion string
|
||||
Option Options
|
||||
}
|
||||
|
||||
type Option func(*Options)
|
||||
@@ -32,17 +33,18 @@ type Options struct {
|
||||
|
||||
var defaultTimeOut = time.Second * 5
|
||||
|
||||
func NewLink(connType string, host string, crypt bool, compress bool, remoteAddr string, localProxy bool, opts ...Option) *Link {
|
||||
func NewLink(connType string, host string, crypt bool, compress bool, remoteAddr string, localProxy bool, protoVersion string, opts ...Option) *Link {
|
||||
options := newOptions(opts...)
|
||||
|
||||
return &Link{
|
||||
RemoteAddr: remoteAddr,
|
||||
ConnType: connType,
|
||||
Host: host,
|
||||
Crypt: crypt,
|
||||
Compress: compress,
|
||||
LocalProxy: localProxy,
|
||||
Option: options,
|
||||
RemoteAddr: remoteAddr,
|
||||
ConnType: connType,
|
||||
Host: host,
|
||||
Crypt: crypt,
|
||||
Compress: compress,
|
||||
LocalProxy: localProxy,
|
||||
ProtoVersion: protoVersion,
|
||||
Option: options,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -317,6 +317,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 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)
|
||||
|
||||
+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,9 +152,9 @@ type Tunnel struct {
|
||||
Remark string
|
||||
TargetAddr string
|
||||
NoStore bool
|
||||
IsHttp bool
|
||||
LocalPath string
|
||||
StripPre string
|
||||
ProtoVersion string
|
||||
Target *Target
|
||||
MultiAccount *MultiAccount
|
||||
Health
|
||||
|
||||
+13
-16
@@ -3,10 +3,13 @@ package goroutine
|
||||
import (
|
||||
"ehang.io/nps/lib/common"
|
||||
"ehang.io/nps/lib/file"
|
||||
"fmt"
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/panjf2000/ants/v2"
|
||||
"io"
|
||||
"net"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
@@ -51,24 +54,18 @@ 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) {
|
||||
errorContent, _ := common.ReadAllFromFile(filepath.Join(common.GetRunPath(), "web", "static", "page", "auth.html"))
|
||||
authHtml := string(errorContent)
|
||||
authHtml = strings.ReplaceAll(authHtml, "${ip}", common.GetIpByAddr(remote))
|
||||
authHtml = strings.ReplaceAll(authHtml, "${vkey}", task.Client.VerifyKey)
|
||||
authHtml = strings.ReplaceAll(authHtml, "${port}", beego.AppConfig.String("web_port"))
|
||||
|
||||
task.IsHttp = true
|
||||
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)
|
||||
dst.Write([]byte(response))
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+77
-2
@@ -141,6 +141,13 @@ func UpdateNps() {
|
||||
fmt.Println("Update completed, please restart")
|
||||
}
|
||||
|
||||
func UpdateNpsNew() {
|
||||
destPath := downloadLatest2("server", filepath.Join(common.GetAppPath(), "temp"))
|
||||
//复制文件到对应目录
|
||||
copyStaticFileReplaceNps(destPath, common.GetAppPath())
|
||||
fmt.Println("更新成功,请重启服务")
|
||||
}
|
||||
|
||||
func UpdateNpc() {
|
||||
destPath := downloadLatest("client")
|
||||
//复制文件到对应目录
|
||||
@@ -190,6 +197,43 @@ func downloadLatest(bin string) string {
|
||||
return destPath
|
||||
}
|
||||
|
||||
func downloadLatest2(bin string, path string) string {
|
||||
// get version
|
||||
data, err := http.Get("https://api.github.com/repos/yisier/nps/releases/latest")
|
||||
if err != nil {
|
||||
log.Fatal(err.Error())
|
||||
}
|
||||
b, err := ioutil.ReadAll(data.Body)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
rl := new(release)
|
||||
json.Unmarshal(b, &rl)
|
||||
version := rl.TagName
|
||||
fmt.Println("the latest version is", version)
|
||||
filename := runtime.GOOS + "_" + runtime.GOARCH + "_" + bin + ".tar.gz"
|
||||
// download latest package
|
||||
downloadUrl := fmt.Sprintf("https://github.com/yisier/nps/releases/download/%s/%s", version, filename)
|
||||
fmt.Println("download package from ", downloadUrl)
|
||||
resp, err := http.Get(downloadUrl)
|
||||
if err != nil {
|
||||
log.Fatal(err.Error())
|
||||
}
|
||||
destPath, err := unpackit.Unpack(resp.Body, path)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if bin == "server" {
|
||||
destPath = strings.Replace(destPath, "/web", "", -1)
|
||||
destPath = strings.Replace(destPath, `\web`, "", -1)
|
||||
destPath = strings.Replace(destPath, "/views", "", -1)
|
||||
destPath = strings.Replace(destPath, `\views`, "", -1)
|
||||
} else {
|
||||
destPath = strings.Replace(destPath, `\conf`, "", -1)
|
||||
destPath = strings.Replace(destPath, "/conf", "", -1)
|
||||
}
|
||||
return destPath
|
||||
}
|
||||
func copyStaticFile(srcPath, bin string) string {
|
||||
path := common.GetInstallPath()
|
||||
if bin == "nps" {
|
||||
@@ -226,6 +270,22 @@ func copyStaticFile(srcPath, bin string) string {
|
||||
return binPath
|
||||
}
|
||||
|
||||
func copyStaticFileReplaceNps(srcPath, descPath string) string {
|
||||
//复制文件到对应目录
|
||||
os.Rename(filepath.Join(srcPath, "web"), filepath.Join(descPath, "web"))
|
||||
chMod(filepath.Join(descPath, "web"), 0766)
|
||||
|
||||
binPath, _ := filepath.Abs(os.Args[0])
|
||||
if !common.IsWindows() {
|
||||
os.Rename(filepath.Join(srcPath, "nps"), filepath.Join(descPath, "nps"))
|
||||
} else {
|
||||
os.Rename(filepath.Join(srcPath, "nps.exe"), filepath.Join(descPath, "nps.exe"))
|
||||
}
|
||||
chMod(binPath, 0755)
|
||||
os.RemoveAll(srcPath)
|
||||
return binPath
|
||||
}
|
||||
|
||||
func InstallNpc() {
|
||||
path := common.GetInstallPath()
|
||||
if !common.FileExists(path) {
|
||||
@@ -266,6 +326,21 @@ now!`)
|
||||
chMod(common.GetLogPath(), 0777)
|
||||
return binPath
|
||||
}
|
||||
|
||||
func InstallNpsToCurrentDir() string {
|
||||
path := common.GetAppPath()
|
||||
log.Println("install path:" + path)
|
||||
log.Println("install ok!")
|
||||
chMod(filepath.Join(path, "nps.log"), 0777)
|
||||
|
||||
if !common.IsWindows() {
|
||||
path = filepath.Join(path, "nps")
|
||||
} else {
|
||||
path = filepath.Join(path, "nps.exe")
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
func MkidrDirAll(path string, v ...string) {
|
||||
for _, item := range v {
|
||||
if err := os.MkdirAll(filepath.Join(path, item), 0755); err != nil {
|
||||
@@ -310,7 +385,7 @@ func CopyDir(srcPath string, destPath string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
//生成目录并拷贝文件
|
||||
// 生成目录并拷贝文件
|
||||
func copyFile(src, dest string) (w int64, err error) {
|
||||
srcFile, err := os.Open(src)
|
||||
if err != nil {
|
||||
@@ -345,7 +420,7 @@ func copyFile(src, dest string) (w int64, err error) {
|
||||
return io.Copy(dstFile, srcFile)
|
||||
}
|
||||
|
||||
//检测文件夹路径时候存在
|
||||
// 检测文件夹路径时候存在
|
||||
func pathExists(path string) (bool, error) {
|
||||
_, err := os.Stat(path)
|
||||
if err == nil {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package version
|
||||
|
||||
const VERSION = "0.26.21"
|
||||
const VERSION = "0.26.27"
|
||||
|
||||
// Compulsory minimum version, Minimum downward compatibility to this version
|
||||
func GetVersion() string {
|
||||
|
||||
+14
-8
@@ -23,12 +23,13 @@ type NetBridge interface {
|
||||
SendLinkInfo(clientId int, link *conn.Link, t *file.Tunnel) (target net.Conn, err error)
|
||||
}
|
||||
|
||||
//BaseServer struct
|
||||
// BaseServer struct
|
||||
type BaseServer struct {
|
||||
id int
|
||||
bridge NetBridge
|
||||
task *file.Tunnel
|
||||
errorContent []byte
|
||||
errorCode int
|
||||
sync.Mutex
|
||||
}
|
||||
|
||||
@@ -41,7 +42,7 @@ func NewBaseServer(bridge *bridge.Bridge, task *file.Tunnel) *BaseServer {
|
||||
}
|
||||
}
|
||||
|
||||
//add the flow
|
||||
// add the flow
|
||||
func (s *BaseServer) FlowAdd(in, out int64) {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
@@ -49,7 +50,7 @@ func (s *BaseServer) FlowAdd(in, out int64) {
|
||||
s.task.Flow.InletFlow += in
|
||||
}
|
||||
|
||||
//change the flow
|
||||
// change the flow
|
||||
func (s *BaseServer) FlowAddHost(host *file.Host, in, out int64) {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
@@ -57,13 +58,13 @@ func (s *BaseServer) FlowAddHost(host *file.Host, in, out int64) {
|
||||
host.Flow.InletFlow += in
|
||||
}
|
||||
|
||||
//write fail bytes to the connection
|
||||
// write fail bytes to the connection
|
||||
func (s *BaseServer) writeConnFail(c net.Conn) {
|
||||
c.Write([]byte(common.ConnectionFailBytes))
|
||||
c.Write(s.errorContent)
|
||||
}
|
||||
|
||||
//auth check
|
||||
// auth check
|
||||
func (s *BaseServer) auth(r *http.Request, c *conn.Conn, u, p string) error {
|
||||
if u != "" && p != "" && !common.CheckAuth(r, u, p) {
|
||||
c.Write([]byte(common.UnauthorizedBytes))
|
||||
@@ -73,7 +74,7 @@ func (s *BaseServer) auth(r *http.Request, c *conn.Conn, u, p string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
//check flow limit of the client ,and decrease the allow num of client
|
||||
// check flow limit of the client ,and decrease the allow num of client
|
||||
func (s *BaseServer) CheckFlowAndConnNum(client *file.Client) error {
|
||||
if client.Flow.FlowLimit > 0 && (client.Flow.FlowLimit<<20) < (client.Flow.ExportFlow+client.Flow.InletFlow) {
|
||||
return errors.New("Traffic exceeded")
|
||||
@@ -93,7 +94,7 @@ func in(target string, str_array []string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
//create a new connection and start bytes copying
|
||||
// create a new connection and start bytes copying
|
||||
func (s *BaseServer) DealClient(c *conn.Conn, client *file.Client, addr string,
|
||||
rb []byte, tp string, f func(), flow *file.Flow, localProxy bool, task *file.Tunnel) error {
|
||||
|
||||
@@ -109,7 +110,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)
|
||||
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()
|
||||
|
||||
+15
-1
@@ -10,6 +10,7 @@ import (
|
||||
"ehang.io/nps/lib/file"
|
||||
"ehang.io/nps/lib/goroutine"
|
||||
"ehang.io/nps/server/connection"
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"io"
|
||||
"net"
|
||||
@@ -196,13 +197,26 @@ reset:
|
||||
return
|
||||
}
|
||||
|
||||
if host.Client.IpWhite && host.Client.IpWhitePass != "" {
|
||||
if common.IsAuthIp(c.RemoteAddr().String(), host.Client.VerifyKey, host.Client.IpWhiteList) {
|
||||
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()))
|
||||
authHtml = strings.ReplaceAll(authHtml, "${vkey}", host.Client.VerifyKey)
|
||||
authHtml = strings.ReplaceAll(authHtml, "${port}", beego.AppConfig.String("web_port"))
|
||||
s.errorContent, err = []byte(authHtml), err
|
||||
s.errorCode = 401
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 判断访问地址是否在黑名单内
|
||||
if common.IsBlackIp(c.RemoteAddr().String(), host.Client.VerifyKey, host.Client.BlackIpList) {
|
||||
c.Close()
|
||||
return
|
||||
}
|
||||
|
||||
lk = conn.NewLink("http", targetAddr, host.Client.Cnf.Crypt, host.Client.Cnf.Compress, r.RemoteAddr, host.Target.LocalProxy)
|
||||
lk = conn.NewLink("http", targetAddr, host.Client.Cnf.Crypt, host.Client.Cnf.Compress, r.RemoteAddr, host.Target.LocalProxy, "")
|
||||
if target, err = s.bridge.SendLinkInfo(host.Client.Id, lk, nil); err != nil {
|
||||
logs.Notice("connect to target %s error %s", lk.Host, err)
|
||||
return
|
||||
|
||||
+31
-1
@@ -4,6 +4,7 @@ import (
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"ehang.io/nps/lib/cache"
|
||||
@@ -48,7 +49,36 @@ func (https *HttpsServer) Start() error {
|
||||
https.handleHttps2(c, serverName, rb, r)
|
||||
} else {
|
||||
logs.Debug("使用上传证书")
|
||||
https.cert(host, c, rb, host.CertFilePath, host.KeyFilePath)
|
||||
|
||||
// 判断是路径还是证书,-----BEGIN 开头的为证书
|
||||
if strings.Contains(host.CertFilePath, "-----BEGIN") || strings.Contains(host.KeyFilePath, "-----BEGIN") {
|
||||
logs.Debug("通过上传文件加载证书")
|
||||
https.cert(host, c, rb, host.CertFilePath, host.KeyFilePath)
|
||||
} else {
|
||||
logs.Debug("通过路径加载证书")
|
||||
if !common.FileExists(host.CertFilePath) || !common.FileExists(host.KeyFilePath) {
|
||||
c.Close()
|
||||
logs.Error("证书或秘钥文件不存在", host.KeyFilePath, host.CertFilePath)
|
||||
return
|
||||
}
|
||||
|
||||
cert, err := common.ReadAllFromFile(host.CertFilePath)
|
||||
if err != nil {
|
||||
c.Close()
|
||||
logs.Error("加载证书失败", err)
|
||||
return
|
||||
}
|
||||
key, err := common.ReadAllFromFile(host.KeyFilePath)
|
||||
if err != nil {
|
||||
c.Close()
|
||||
logs.Error("加载证书秘钥失败", err)
|
||||
return
|
||||
}
|
||||
|
||||
https.cert(host, c, rb, string(cert), string(key))
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
+11
-11
@@ -51,7 +51,7 @@ type Sock5ModeServer struct {
|
||||
listener net.Listener
|
||||
}
|
||||
|
||||
//req
|
||||
// req
|
||||
func (s *Sock5ModeServer) handleRequest(c net.Conn) {
|
||||
/*
|
||||
The SOCKS request is formed as follows:
|
||||
@@ -84,7 +84,7 @@ func (s *Sock5ModeServer) handleRequest(c net.Conn) {
|
||||
}
|
||||
}
|
||||
|
||||
//reply
|
||||
// reply
|
||||
func (s *Sock5ModeServer) sendReply(c net.Conn, rep uint8) {
|
||||
reply := []byte{
|
||||
5,
|
||||
@@ -105,7 +105,7 @@ func (s *Sock5ModeServer) sendReply(c net.Conn, rep uint8) {
|
||||
c.Write(reply)
|
||||
}
|
||||
|
||||
//do conn
|
||||
// do conn
|
||||
func (s *Sock5ModeServer) doConnect(c net.Conn, command uint8) {
|
||||
addrType := make([]byte, 1)
|
||||
c.Read(addrType)
|
||||
@@ -146,7 +146,7 @@ func (s *Sock5ModeServer) doConnect(c net.Conn, command uint8) {
|
||||
return
|
||||
}
|
||||
|
||||
//conn
|
||||
// conn
|
||||
func (s *Sock5ModeServer) handleConnect(c net.Conn) {
|
||||
s.doConnect(c, connectMethod)
|
||||
}
|
||||
@@ -216,7 +216,7 @@ func (s *Sock5ModeServer) handleUDP(c net.Conn) {
|
||||
s.sendUdpReply(c, reply, succeeded, common.GetServerIpByClientIp(c.RemoteAddr().(*net.TCPAddr).IP))
|
||||
defer reply.Close()
|
||||
// new a tunnel to client
|
||||
link := conn.NewLink("udp5", "", s.task.Client.Cnf.Crypt, s.task.Client.Cnf.Compress, c.RemoteAddr().String(), false)
|
||||
link := conn.NewLink("udp5", "", s.task.Client.Cnf.Crypt, s.task.Client.Cnf.Compress, c.RemoteAddr().String(), false, "")
|
||||
target, err := s.bridge.SendLinkInfo(s.task.Client.Id, link, s.task)
|
||||
if err != nil {
|
||||
logs.Warn("get connection from client id %d error %s", s.task.Client.Id, err.Error())
|
||||
@@ -280,7 +280,7 @@ func (s *Sock5ModeServer) handleUDP(c net.Conn) {
|
||||
}
|
||||
}
|
||||
|
||||
//new conn
|
||||
// new conn
|
||||
func (s *Sock5ModeServer) handleConn(c net.Conn) {
|
||||
buf := make([]byte, 2)
|
||||
if _, err := io.ReadFull(c, buf); err != nil {
|
||||
@@ -317,7 +317,7 @@ func (s *Sock5ModeServer) handleConn(c net.Conn) {
|
||||
s.handleRequest(c)
|
||||
}
|
||||
|
||||
//socks5 auth
|
||||
// socks5 auth
|
||||
func (s *Sock5ModeServer) Auth(c net.Conn) error {
|
||||
header := []byte{0, 0}
|
||||
if _, err := io.ReadAtLeast(c, header, 2); err != nil {
|
||||
@@ -345,7 +345,7 @@ func (s *Sock5ModeServer) Auth(c net.Conn) error {
|
||||
// enable multi user auth
|
||||
U = string(user)
|
||||
if len(U) == 0 {
|
||||
return errors.New("验证不通过")
|
||||
return errors.New("验证不通过")
|
||||
}
|
||||
var ok bool
|
||||
P, ok = s.task.MultiAccount.AccountMap[U]
|
||||
@@ -370,7 +370,7 @@ func (s *Sock5ModeServer) Auth(c net.Conn) error {
|
||||
}
|
||||
}
|
||||
|
||||
//start
|
||||
// start
|
||||
func (s *Sock5ModeServer) Start() error {
|
||||
return conn.NewTcpListenerAndProcess(s.task.ServerIp+":"+strconv.Itoa(s.task.Port), func(c net.Conn) {
|
||||
if err := s.CheckFlowAndConnNum(s.task.Client); err != nil {
|
||||
@@ -384,7 +384,7 @@ func (s *Sock5ModeServer) Start() error {
|
||||
}, &s.listener)
|
||||
}
|
||||
|
||||
//new
|
||||
// new
|
||||
func NewSock5ModeServer(bridge NetBridge, task *file.Tunnel) *Sock5ModeServer {
|
||||
s := new(Sock5ModeServer)
|
||||
s.bridge = bridge
|
||||
@@ -392,7 +392,7 @@ func NewSock5ModeServer(bridge NetBridge, task *file.Tunnel) *Sock5ModeServer {
|
||||
return s
|
||||
}
|
||||
|
||||
//close
|
||||
// close
|
||||
func (s *Sock5ModeServer) Close() error {
|
||||
return s.listener.Close()
|
||||
}
|
||||
|
||||
+2
-2
@@ -27,7 +27,7 @@ func NewUdpModeServer(bridge *bridge.Bridge, task *file.Tunnel) *UdpModeServer {
|
||||
return s
|
||||
}
|
||||
|
||||
//开始
|
||||
// 开始
|
||||
func (s *UdpModeServer) Start() error {
|
||||
var err error
|
||||
if s.task.ServerIp == "" {
|
||||
@@ -80,7 +80,7 @@ func (s *UdpModeServer) process(addr *net.UDPAddr, data []byte) {
|
||||
return
|
||||
}
|
||||
defer s.task.Client.AddConn()
|
||||
link := conn.NewLink(common.CONN_UDP, s.task.Target.TargetStr, s.task.Client.Cnf.Crypt, s.task.Client.Cnf.Compress, addr.String(), s.task.Target.LocalProxy)
|
||||
link := conn.NewLink(common.CONN_UDP, s.task.Target.TargetStr, s.task.Client.Cnf.Crypt, s.task.Client.Cnf.Compress, addr.String(), s.task.Target.LocalProxy, "")
|
||||
if clientConn, err := s.bridge.SendLinkInfo(s.task.Client.Id, link, s.task); err != nil {
|
||||
return
|
||||
} else {
|
||||
|
||||
@@ -119,7 +119,7 @@ func NewHttpReverseProxy(s *httpServer) *HttpReverseProxy {
|
||||
host = ctx.Value("host").(*file.Host)
|
||||
targetAddr = ctx.Value("target").(string)
|
||||
|
||||
lk = conn.NewLink("http", targetAddr, host.Client.Cnf.Crypt, host.Client.Cnf.Compress, r.RemoteAddr, host.Target.LocalProxy)
|
||||
lk = conn.NewLink("http", targetAddr, host.Client.Cnf.Crypt, host.Client.Cnf.Compress, r.RemoteAddr, host.Target.LocalProxy, "")
|
||||
if target, err = s.bridge.SendLinkInfo(host.Client.Id, lk, nil); err != nil {
|
||||
logs.Notice("connect to target %s error %s", lk.Host, err)
|
||||
return nil, NewHTTPError(http.StatusBadGateway, "Cannot connect to the server")
|
||||
@@ -150,7 +150,7 @@ func NewHttpReverseProxy(s *httpServer) *HttpReverseProxy {
|
||||
host = ctx.Value("host").(*file.Host)
|
||||
targetAddr = ctx.Value("target").(string)
|
||||
|
||||
lk = conn.NewLink("tcp", targetAddr, host.Client.Cnf.Crypt, host.Client.Cnf.Compress, r.RemoteAddr, host.Target.LocalProxy)
|
||||
lk = conn.NewLink("tcp", targetAddr, host.Client.Cnf.Crypt, host.Client.Cnf.Compress, r.RemoteAddr, host.Target.LocalProxy, "")
|
||||
if target, err = s.bridge.SendLinkInfo(host.Client.Id, lk, nil); err != nil {
|
||||
logs.Notice("connect to target %s error %s", lk.Host, err)
|
||||
return nil, NewHTTPError(http.StatusBadGateway, "Cannot connect to the target")
|
||||
|
||||
+14
-39
@@ -27,6 +27,7 @@ import (
|
||||
var (
|
||||
Bridge *bridge.Bridge
|
||||
RunList sync.Map //map[int]interface{}
|
||||
once sync.Once
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -328,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)
|
||||
@@ -339,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
|
||||
@@ -508,15 +481,17 @@ func GetDashboardData() map[string]interface{} {
|
||||
|
||||
// 实例化流量数据到文件
|
||||
func flowSession(m time.Duration) {
|
||||
ticker := time.NewTicker(m)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
file.GetDb().JsonDb.StoreHostToJsonFile()
|
||||
file.GetDb().JsonDb.StoreTasksToJsonFile()
|
||||
file.GetDb().JsonDb.StoreClientsToJsonFile()
|
||||
file.GetDb().JsonDb.StoreGlobalToJsonFile()
|
||||
once.Do(func() {
|
||||
ticker := time.NewTicker(m)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
file.GetDb().JsonDb.StoreHostToJsonFile()
|
||||
file.GetDb().JsonDb.StoreTasksToJsonFile()
|
||||
file.GetDb().JsonDb.StoreClientsToJsonFile()
|
||||
file.GetDb().JsonDb.StoreGlobalToJsonFile()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"ehang.io/nps/lib/file"
|
||||
"encoding/hex"
|
||||
"html"
|
||||
"time"
|
||||
|
||||
"ehang.io/nps/lib/crypt"
|
||||
@@ -40,3 +42,52 @@ 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 == "" || ip == "" || password == "" {
|
||||
s.Data["json"] = map[string]interface{}{"success": false, "message": "参数错误"}
|
||||
s.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
c, err := file.GetDb().GetClientByVkey(vkey)
|
||||
if err != nil {
|
||||
s.Data["json"] = map[string]interface{}{"success": false, "message": "客户端密钥错误"}
|
||||
s.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
if c.IpWhitePass != password {
|
||||
s.Data["json"] = map[string]interface{}{"success": false, "message": "授权密码错误"}
|
||||
s.ServeJSON()
|
||||
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()
|
||||
}
|
||||
|
||||
func (s *AuthController) getEscapeString(key string) string {
|
||||
return html.EscapeString(s.GetString(key))
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
@@ -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] {
|
||||
|
||||
+70
-11
@@ -94,17 +94,18 @@ func (s *IndexController) Add() {
|
||||
} else {
|
||||
id := int(file.GetDb().JsonDb.GetTaskId())
|
||||
t := &file.Tunnel{
|
||||
Port: s.GetIntNoErr("port"),
|
||||
ServerIp: s.getEscapeString("server_ip"),
|
||||
Mode: s.getEscapeString("type"),
|
||||
Target: &file.Target{TargetStr: s.getEscapeString("target"), LocalProxy: s.GetBoolNoErr("local_proxy")},
|
||||
Id: id,
|
||||
Status: true,
|
||||
Remark: s.getEscapeString("remark"),
|
||||
Password: s.getEscapeString("password"),
|
||||
LocalPath: s.getEscapeString("local_path"),
|
||||
StripPre: s.getEscapeString("strip_pre"),
|
||||
Flow: &file.Flow{},
|
||||
Port: s.GetIntNoErr("port"),
|
||||
ServerIp: s.getEscapeString("server_ip"),
|
||||
Mode: s.getEscapeString("type"),
|
||||
Target: &file.Target{TargetStr: s.getEscapeString("target"), LocalProxy: s.GetBoolNoErr("local_proxy")},
|
||||
Id: id,
|
||||
Status: true,
|
||||
Remark: s.getEscapeString("remark"),
|
||||
Password: s.getEscapeString("password"),
|
||||
LocalPath: s.getEscapeString("local_path"),
|
||||
StripPre: s.getEscapeString("strip_pre"),
|
||||
ProtoVersion: s.getEscapeString("proto_version"),
|
||||
Flow: &file.Flow{},
|
||||
}
|
||||
|
||||
if t.Port <= 0 {
|
||||
@@ -131,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{})
|
||||
@@ -181,6 +229,7 @@ func (s *IndexController) Edit() {
|
||||
t.Password = s.getEscapeString("password")
|
||||
t.Id = id
|
||||
t.LocalPath = s.getEscapeString("local_path")
|
||||
t.ProtoVersion = s.getEscapeString("proto_version")
|
||||
t.StripPre = s.getEscapeString("strip_pre")
|
||||
t.Remark = s.getEscapeString("remark")
|
||||
t.Target.LocalProxy = s.GetBoolNoErr("local_proxy")
|
||||
@@ -274,6 +323,11 @@ func (s *IndexController) AddHost() {
|
||||
CertFilePath: s.getEscapeString("cert_file_path"),
|
||||
AutoHttps: s.GetBoolNoErr("AutoHttps"),
|
||||
}
|
||||
|
||||
if h.Scheme == "http" {
|
||||
h.AutoHttps = false
|
||||
}
|
||||
|
||||
var err error
|
||||
if h.Client, err = file.GetDb().GetClient(s.GetIntNoErr("client_id")); err != nil {
|
||||
s.AjaxErr("add error the client can not be found")
|
||||
@@ -330,6 +384,11 @@ func (s *IndexController) EditHost() {
|
||||
h.CertFilePath = s.getEscapeString("cert_file_path")
|
||||
h.Target.LocalProxy = s.GetBoolNoErr("local_proxy")
|
||||
h.AutoHttps = s.GetBoolNoErr("AutoHttps")
|
||||
|
||||
if h.Scheme == "http" {
|
||||
h.AutoHttps = false
|
||||
}
|
||||
|
||||
file.GetDb().JsonDb.StoreHostToJsonFile()
|
||||
}
|
||||
s.AjaxOk("modified success")
|
||||
|
||||
@@ -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{})
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -0,0 +1,234 @@
|
||||
<!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="vkey">${vkey}</div>
|
||||
<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
|
||||
var vkey = document.getElementById("vkey").innerText
|
||||
var ip = document.getElementById("ip_addr").innerText
|
||||
var port = document.getElementById("port").innerText
|
||||
|
||||
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)
|
||||
})
|
||||
|
||||
var host = window.location.hostname
|
||||
xhr.open("get", "//" + host + ':' + port + "/auth/ipwhiteauth?vkey=" + vkey + "&ip=" + ip + "&pass=" + pwd)
|
||||
xhr.send()
|
||||
}
|
||||
</script>
|
||||
|
||||
</html>
|
||||
@@ -189,11 +189,19 @@
|
||||
<zh-CN>访问端命令</zh-CN>
|
||||
<en-US>Access command</en-US>
|
||||
</lang>
|
||||
<lang id="word-protoversion">
|
||||
<zh-CN>Proxy Protocol Version</zh-CN>
|
||||
<en-US>Proxy Protocol Version</en-US>
|
||||
</lang>
|
||||
|
||||
<lang id="word-quicklycommand">
|
||||
<zh-CN>快捷启动命令</zh-CN>
|
||||
<en-US>Quickly command</en-US>
|
||||
</lang>
|
||||
<lang id="word-tlsquicklycommand">
|
||||
<zh-CN>TLS快捷启动命令</zh-CN>
|
||||
<en-US>TLS Quickly command</en-US>
|
||||
</lang>
|
||||
|
||||
<lang id="word-commandclient">
|
||||
<zh-CN>客户端命令</zh-CN>
|
||||
@@ -285,13 +293,13 @@
|
||||
<en-US>HTTP port</en-US>
|
||||
</lang>
|
||||
<lang id="word-httpscert">
|
||||
<zh-CN>HTTPS 证书(pem格式)</zh-CN>
|
||||
<zh-CN>HTTPS 证书(或证书路径)</zh-CN>
|
||||
<en-US>HTTPS cert</en-US>
|
||||
</lang>
|
||||
<lang id="word-https">HTTPS
|
||||
</lang>
|
||||
<lang id="word-httpskey">
|
||||
<zh-CN>HTTPS 密钥(key格式)</zh-CN>
|
||||
<zh-CN>HTTPS 密钥(或秘钥路径)</zh-CN>
|
||||
<en-US>HTTPS key</en-US>
|
||||
</lang>
|
||||
<lang id="word-httpsport">
|
||||
@@ -591,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>
|
||||
@@ -724,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>
|
||||
@@ -762,6 +782,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>
|
||||
@@ -775,6 +810,10 @@
|
||||
<zh-CN>你确定你要停止它吗?</zh-CN>
|
||||
<en-US>Are you sure you want to stop it?</en-US>
|
||||
</lang>
|
||||
<lang id="copy">
|
||||
<zh-CN>你确定要复制它吗?</zh-CN>
|
||||
<en-US>Are you sure you want to copy it?</en-US>
|
||||
</lang>
|
||||
</confirm>
|
||||
|
||||
<reply>
|
||||
|
||||
@@ -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,13 +67,15 @@
|
||||
+ '<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/>'
|
||||
+ '<b langtag="word-commandclient"></b>: ' + "<code>./npc{{.win}} -server={{.ip}}:{{.p}} -vkey=" + row.VerifyKey + " -type=" +{{.bridgeType}} +"</code><button class=\"copy btn btn-info btn-xs\" onclick=\"copyCommand(this)\" data-clipboard-text=\"\">复制</button><br/>"
|
||||
+ '<b langtag="word-commandclient-tls"></b>: ' + "<code>./npc{{.win}} -server={{.ip}}:{{.tls_p}} -vkey=" + row.VerifyKey + " -tls_enable=true</code><button class=\"copy btn btn-info btn-xs\" onclick=\"copyCommand(this)\" data-clipboard-text=\"\">复制</button>"
|
||||
},
|
||||
|
||||
+43
-26
@@ -24,7 +24,9 @@
|
||||
<option value="socks5" langtag="scheme-socks5"></option>
|
||||
<option value="secret" langtag="scheme-secret"></option>
|
||||
<option value="p2p" langtag="scheme-p2p"></option>
|
||||
{{/*<option value="file" langtag="scheme-file"></option>*/}}
|
||||
{{/*
|
||||
<option value="file" langtag="scheme-file"></option>
|
||||
*/}}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@@ -32,10 +34,11 @@
|
||||
<div class="form-group" id="client_id">
|
||||
<label class="control-label font-bold" langtag="word-clientid"></label>
|
||||
<div class="col-sm-10">
|
||||
<select class="form-control" name="client_id" placeholder="" langtag="word-belongclient"></select>
|
||||
<select class="form-control" name="client_id" placeholder="" id="nps_client_id"
|
||||
langtag="word-belongclient"></select>
|
||||
|
||||
<!-- <input value="{{.client_id}}" class="form-control" type="text" name="client_id"-->
|
||||
<!-- placeholder="" langtag="word-clientid">-->
|
||||
<!-- <input value="{{.client_id}}" class="form-control" type="text" name="client_id"-->
|
||||
<!-- placeholder="" langtag="word-clientid">-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -47,13 +50,13 @@
|
||||
</div>
|
||||
</div>
|
||||
{{if eq true .allow_multi_ip}}
|
||||
<div class="form-group" id="server_ip">
|
||||
<label class="control-label font-bold" langtag="word-serverip"></label>
|
||||
<div class="col-sm-10">
|
||||
<input class="form-control" type="text" value="0.0.0.0" name="server_ip" placeholder=""
|
||||
langtag="info-suchasip">
|
||||
</div>
|
||||
<div class="form-group" id="server_ip">
|
||||
<label class="control-label font-bold" langtag="word-serverip"></label>
|
||||
<div class="col-sm-10">
|
||||
<input class="form-control" type="text" value="0.0.0.0" name="server_ip" placeholder=""
|
||||
langtag="info-suchasip">
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
<div class="form-group" id="port">
|
||||
<label class="control-label font-bold" langtag="word-serverport"></label>
|
||||
@@ -64,15 +67,15 @@
|
||||
</div>
|
||||
|
||||
{{if eq true .allow_local_proxy}}
|
||||
<div class="form-group" id="local_proxy">
|
||||
<label class="control-label font-bold" langtag="word-proxytolocal"></label>
|
||||
<div class="col-sm-10">
|
||||
<select class="form-control" name="local_proxy">
|
||||
<option value="0" langtag="word-no"></option>
|
||||
<option value="1" langtag="word-yes"></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group" id="local_proxy">
|
||||
<label class="control-label font-bold" langtag="word-proxytolocal"></label>
|
||||
<div class="col-sm-10">
|
||||
<select class="form-control" name="local_proxy">
|
||||
<option value="0" langtag="word-no"></option>
|
||||
<option value="1" langtag="word-yes"></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
<div class="form-group" id="target">
|
||||
@@ -108,6 +111,20 @@
|
||||
<span class="help-block m-b-none" langtag="info-identificationkey"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group" id="proto_version">
|
||||
<label class="control-label font-bold">Proxy Protocol Version:</label>
|
||||
<div class="col-sm-10">
|
||||
<select class="form-control" name="proto_version">
|
||||
<option value=""></option>
|
||||
<option value="V1">V1</option>
|
||||
<option value="V2">V2</option>
|
||||
</select>
|
||||
<span class="help-block m-b-none">开启此功能,请确保本地的服务能够支持 Proxy Protocol 协议。</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="hr-line-dashed"></div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-4 col-sm-offset-2">
|
||||
@@ -126,7 +143,7 @@
|
||||
<script>
|
||||
var arr = []
|
||||
arr["all"] = ["port", "target", "password", "local_path", "strip_pre", "local_proxy", "client_id", "server_ip"]
|
||||
arr["tcp"] = ["port", "target", "local_proxy", "client_id", "server_ip"]
|
||||
arr["tcp"] = ["port", "target", "local_proxy", "client_id", "server_ip", "proto_version"]
|
||||
arr["udp"] = ["port", "target", "local_proxy", "client_id", "server_ip"]
|
||||
arr["socks5"] = ["port", "client_id", "server_ip"]
|
||||
arr["httpProxy"] = ["port", "client_id", "server_ip"]
|
||||
@@ -162,15 +179,15 @@
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "{{.web_base_url}}/client/list", // 服务器数据的加载地址
|
||||
data: {order:"asc",offset:0,limit:999},
|
||||
dataType : "json",
|
||||
success : function(data) {
|
||||
data: {order: "asc", offset: 0, limit: 999},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data && data.rows.length > 0) {
|
||||
for(var i=0; i<data.rows.length; i++){
|
||||
var option="<option value=\""+data.rows[i].Id+"\"";
|
||||
option += ">"+data.rows[i].Id + '-' +data.rows[i].Remark+"</option>"; //动态添加数据
|
||||
for (var i = 0; i < data.rows.length; i++) {
|
||||
var option = "<option value=\"" + data.rows[i].Id + "\"";
|
||||
option += ">" + data.rows[i].Id + '-' + data.rows[i].Remark + "</option>"; //动态添加数据
|
||||
$("select[name='client_id']").append(option);
|
||||
$("select[name='client_id']").find("option[value='{{.t.Client.Id}}']").attr("selected",true);
|
||||
$("select[name='client_id']").find("option[value='{{.client_id}}']").attr("selected", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+48
-20
@@ -8,7 +8,7 @@
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label font-bold" langtag="word-scheme"></label>
|
||||
<div class="col-sm-10">
|
||||
<span class="help-block m-b-none font-bold" langtag="word-usecase"></span>:
|
||||
<span class="help-block m-b-none font-bold" langtag="word-usecase"></span>:
|
||||
<span id="usecase">
|
||||
<span id="casetcp" langtag="info-casetcp"></span>
|
||||
<span id="caseudp" langtag="info-caseudp"></span>
|
||||
@@ -25,7 +25,9 @@
|
||||
<option value="socks5" langtag="scheme-socks5"></option>
|
||||
<option value="secret" langtag="scheme-secret"></option>
|
||||
<option value="p2p" langtag="scheme-p2p"></option>
|
||||
{{/*<option value="file" langtag="scheme-file"></option>*/}}
|
||||
{{/*
|
||||
<option value="file" langtag="scheme-file"></option>
|
||||
*/}}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@@ -33,45 +35,52 @@
|
||||
<div class="form-group" id="client_id">
|
||||
<label class="col-sm-2 control-label font-bold" langtag="word-clientid"></label>
|
||||
<div class="col-sm-10">
|
||||
<input value="{{.t.Client.Id}}" value="{{.client_id}}" class="form-control" type="text" name="client_id" placeholder="" langtag="word-clientid">
|
||||
<input value="{{.t.Client.Id}}" value="{{.client_id}}" class="form-control" type="text"
|
||||
name="client_id" placeholder="" langtag="word-clientid">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label font-bold" langtag="word-remark"></label>
|
||||
<div class="col-sm-10">
|
||||
<input value="{{.t.Remark}}" class="form-control" type="text" name="remark" placeholder="" langtag="info-unrestricted">
|
||||
<input value="{{.t.Remark}}" class="form-control" type="text" name="remark" placeholder=""
|
||||
langtag="info-unrestricted">
|
||||
</div>
|
||||
</div>
|
||||
{{if eq true .allow_multi_ip}}
|
||||
{{if eq true .allow_multi_ip}}
|
||||
<div class="form-group" id="server_ip">
|
||||
<label class="col-sm-2 control-label font-bold" langtag="word-serverip"></label>
|
||||
<div class="col-sm-10">
|
||||
<input class="form-control" type="text" value="{{.t.ServerIp}}" name="server_ip" placeholder="" langtag="info-suchasip">
|
||||
<input class="form-control" type="text" value="{{.t.ServerIp}}" name="server_ip"
|
||||
placeholder="" langtag="info-suchasip">
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
<div class="form-group" id="port">
|
||||
<label class="col-sm-2 control-label font-bold" langtag="word-serverport"></label>
|
||||
<div class="col-sm-10">
|
||||
<input value="{{.t.Port}}" class="form-control" type="text" name="port" placeholder="" langtag="info-suchasport">
|
||||
<input value="{{.t.Port}}" class="form-control" type="text" name="port" placeholder=""
|
||||
langtag="info-suchasport">
|
||||
</div>
|
||||
</div>
|
||||
{{if eq true .allow_local_proxy}}
|
||||
{{if eq true .allow_local_proxy}}
|
||||
<div class="form-group" id="local_proxy">
|
||||
<label class="control-label col-sm-2 font-bold" langtag="word-proxytolocal"></label>
|
||||
<div class="col-sm-10">
|
||||
<select class="form-control" name="local_proxy">
|
||||
<option {{if eq false .t.Target.LocalProxy}}selected{{end}} value="0" langtag="word-no"></option>
|
||||
<option {{if eq true .t.Target.LocalProxy}}selected{{end}} value="1" langtag="word-yes"></option>
|
||||
<option {{if eq false .t.Target.LocalProxy}}selected{{end}} value="0"
|
||||
langtag="word-no"></option>
|
||||
<option {{if eq true .t.Target.LocalProxy}}selected{{end}} value="1"
|
||||
langtag="word-yes"></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
<div class="form-group" id="target">
|
||||
<label class="col-sm-2 control-label font-bold" langtag="word-target"></label>
|
||||
<div class="col-sm-10">
|
||||
<textarea class="form-control" name="target" rows="4" placeholder="" langtag="info-suchasiplist">{{.t.Target.TargetStr}}</textarea>
|
||||
<textarea class="form-control" name="target" rows="4" placeholder=""
|
||||
langtag="info-suchasiplist">{{.t.Target.TargetStr}}</textarea>
|
||||
<span class="help-block m-b-none" langtag="info-targettunnel"></span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -79,30 +88,48 @@
|
||||
<div class="form-group" id="local_path">
|
||||
<label class="col-sm-2 control-label font-bold" langtag="word-localpath"></label>
|
||||
<div class="col-sm-10">
|
||||
<input value="{{.t.LocalPath}}" class="form-control" type="text" name="local_path" placeholder="" langtag="info-suchaslocalpath">
|
||||
<input value="{{.t.LocalPath}}" class="form-control" type="text" name="local_path"
|
||||
placeholder="" langtag="info-suchaslocalpath">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group" id="strip_pre">
|
||||
<label class="col-sm-2 control-label font-bold" langtag="word-stripprefix"></label>
|
||||
<div class="col-sm-10">
|
||||
<input value="{{.t.StripPre}}" class="form-control" type="text" name="strip_pre" placeholder="" langtag="info-suchasstripprefix">
|
||||
<input value="{{.t.StripPre}}" class="form-control" type="text" name="strip_pre"
|
||||
placeholder="" langtag="info-suchasstripprefix">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group" id="password">
|
||||
<label class="col-sm-2 control-label font-bold" langtag="word-identificationkey"></label>
|
||||
<div class="col-sm-10">
|
||||
<input value="{{.t.Password}}" class="form-control" type="text" name="password" placeholder="" langtag="word-identificationkey">
|
||||
<input value="{{.t.Password}}" class="form-control" type="text" name="password"
|
||||
placeholder="" langtag="word-identificationkey">
|
||||
<span class="help-block m-b-none" langtag="info-identificationkey"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group" id="proto_version">
|
||||
<label class="control-label font-bold">Proxy Protocol Version:</label>
|
||||
<div class="col-sm-10">
|
||||
<select class="form-control" name="proto_version" id="ProtoVersion">
|
||||
<option value=""></option>
|
||||
<option value="V1">V1</option>
|
||||
<option value="V2">V2</option>
|
||||
</select>
|
||||
<span class="help-block m-b-none">开启此功能,请确保本地的服务能够支持 Proxy Protocol 协议。</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<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('edit', '{{.web_base_url}}/index/edit', $('form').serializeArray())">
|
||||
<button class="btn btn-success" type="button"
|
||||
onclick="submitform('edit', '{{.web_base_url}}/index/edit', $('form').serializeArray())">
|
||||
<i class="fa fa-fw fa-lg fa-check-circle"></i> <span langtag="word-save"></span>
|
||||
|
||||
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -115,7 +142,7 @@
|
||||
<script>
|
||||
var arr = []
|
||||
arr["all"] = ["port", "target", "password", "local_path", "strip_pre", "local_proxy"]
|
||||
arr["tcp"] = ["client_id", "port", "target", "local_proxy"]
|
||||
arr["tcp"] = ["client_id", "port", "target", "local_proxy", "proto_version"]
|
||||
arr["udp"] = ["client_id", "port", "target", "local_proxy"]
|
||||
arr["socks5"] = ["client_id", "port"]
|
||||
arr["httpProxy"] = ["client_id", "port"]
|
||||
@@ -127,7 +154,7 @@
|
||||
$(".form-group[id]").css("display", "none");
|
||||
$("#usecase span").css("display", "none");
|
||||
o = $("#type").val();
|
||||
$('#case'+ o).css("display", "inline")
|
||||
$('#case' + o).css("display", "inline")
|
||||
for (var i = 0; i < arr[o].length; i++) {
|
||||
$("#" + arr[o][i]).css("display", "block")
|
||||
}
|
||||
@@ -135,6 +162,7 @@
|
||||
|
||||
$(function () {
|
||||
$("#type").val('{{.t.Mode}}');
|
||||
$("#ProtoVersion").val('{{.t.ProtoVersion}}');
|
||||
resetForm()
|
||||
$("#type").on("change", function () {
|
||||
resetForm()
|
||||
|
||||
@@ -50,14 +50,16 @@
|
||||
<label class="control-label font-bold" langtag="word-httpscert"></label>
|
||||
<div class="col-sm-10">
|
||||
<textarea rows="6" class="form-control" type="text" name="cert_file_path" id="pemText"
|
||||
placeholder="请将证书文件拖拽或将内容复制粘贴到此处,证书文件格式为:xxxx_example.com.pem"></textarea>
|
||||
placeholder="请将证书文件拖拽或将内容复制粘贴到此处,证书文件格式为:xxxx_example.com.pem。
|
||||
或者配置证书文件路径。"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" id="key_file">
|
||||
<label class="control-label font-bold" langtag="word-httpskey"></label>
|
||||
<div class="col-sm-10">
|
||||
<textarea rows="6" class="form-control" type="text" name="key_file_path" id="pemKey"
|
||||
placeholder="请将私钥文件拖拽或复制粘贴到此处,证书秘钥格式为:xxxx_example.com.key"></textarea>
|
||||
placeholder="请将私钥文件拖拽或复制粘贴到此处,证书秘钥格式为:xxxx_example.com.key。
|
||||
或者配置秘钥文件路径。"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
||||
@@ -48,13 +48,17 @@
|
||||
<div class="form-group" id="cert_file">
|
||||
<label class="control-label font-bold" langtag="word-httpscert"></label>
|
||||
<div class="col-sm-10">
|
||||
<textarea rows="6" class="form-control" type="text" name="cert_file_path" id="pemText" placeholder="请将证书文件拖拽或将内容复制粘贴到此处,证书文件格式为:xxxx_example.com.pem">{{.h.CertFilePath}}</textarea>
|
||||
<textarea rows="6" class="form-control" type="text" name="cert_file_path" id="pemText"
|
||||
placeholder="请将证书文件拖拽或将内容复制粘贴到此处,证书文件格式为:xxxx_example.com.pem。
|
||||
或者配置证书文件路径。">{{.h.CertFilePath}}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" id="key_file">
|
||||
<label class="control-label font-bold" langtag="word-httpskey"></label>
|
||||
<div class="col-sm-10">
|
||||
<textarea rows="6" class="form-control" type="text" name="key_file_path" id="pemKey" placeholder="请将私钥文件拖拽或复制粘贴到此处,证书秘钥格式为:xxxx_example.com.key">{{.h.KeyFilePath}}</textarea>
|
||||
<textarea rows="6" class="form-control" type="text" name="key_file_path" id="pemKey"
|
||||
placeholder="请将私钥文件拖拽或复制粘贴到此处,证书秘钥格式为:xxxx_example.com.key。
|
||||
或者配置秘钥文件路径。">{{.h.KeyFilePath}}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
+ '<b langtag="word-compress"></b>: ' + row.Client.Cnf.Compress + ' '
|
||||
+ '<b langtag="word-basicusername"></b>: ' + row.Client.Cnf.U + ' '
|
||||
+ '<b langtag="word-basicpassword"></b>: ' + row.Client.Cnf.P + ' '
|
||||
+ '<b langtag="word-ishttp"></b>: ' + row.IsHttp + ' '
|
||||
+ '<b langtag="word-protoversion"></b>: ' + row.ProtoVersion + ' '
|
||||
if (row.Mode == "p2p") {
|
||||
return tmp + "<br/><br>"
|
||||
+ '<b langtag="word-commandaccessp2p"></b>: ' + "<code>./npc{{.win}} -server={{.ip}}:{{.p}} -vkey=" + row.Client.VerifyKey
|
||||
@@ -215,6 +215,7 @@
|
||||
title: '<span langtag="word-option"></span>',//内容
|
||||
align: 'center',
|
||||
halign: 'center',
|
||||
width: '200px',
|
||||
visible: true,//false表示不显示
|
||||
formatter: function (value, row, index) {
|
||||
btn_group = '<div class="btn-group">'
|
||||
@@ -227,8 +228,12 @@
|
||||
}
|
||||
btn_group += "<a onclick=\"submitform('delete', '{{.web_base_url}}/index/del', {'id':" + row.Id
|
||||
btn_group += '})" class="btn btn-outline btn-danger"><i class="fa fa-trash"></i></a>'
|
||||
|
||||
btn_group += '<a href="{{.web_base_url}}/index/edit?id=' + row.Id
|
||||
btn_group += '" class="btn btn-outline btn-success"><i class="fa fa-edit"></i></a></div>'
|
||||
btn_group += '" class="btn btn-outline btn-success"><i class="fa fa-edit"></i></a>'
|
||||
|
||||
btn_group += "<a onclick=\"submitform('copy', '{{.web_base_url}}/index/copy', {'id':" + row.Id
|
||||
btn_group += '})" class="btn btn-outline btn-primary"><i class="fa fa-copy"></i></a></div>'
|
||||
return btn_group
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@
|
||||
<ul class="nav navbar-top-links navbar-right">
|
||||
<li>
|
||||
<span class="m-r-sm text-muted welcome-message"><span langtag="word-welcome"></span>
|
||||
<a href="https://ehang.io/nps" langtag="application"></a></span>
|
||||
<a href="https://github.com/yisier/nps" langtag="application"></a></span>
|
||||
</li>
|
||||
<li>
|
||||
<span class="btn-group dropdown">
|
||||
|
||||
Reference in New Issue
Block a user