Compare commits
89 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1e1ff7127e | ||
|
|
e9c0997799 | ||
|
|
958b6f9bcd | ||
|
|
a73b7bd74d | ||
|
|
e502ea6f32 | ||
| 4b97d80152 | |||
|
|
8c4e8d82ac | ||
|
|
b75a641568 | ||
|
|
6a7635a01a | ||
|
|
cbd9611c3d | ||
|
|
8d54567c0f | ||
|
|
245f4fa32f | ||
| 4a714dcd0e | |||
| 43d3ef275e | |||
| d581a65002 | |||
| f6d2362f48 | |||
| 53ba8780ff | |||
| 0dc6d9bc12 | |||
| a8165c9b93 | |||
| bd83acef45 | |||
|
|
b18d06d83d | ||
|
|
eef4390878 | ||
|
|
621893872d | ||
| 8d61054332 | |||
| 7cf43c869a | |||
| 70bddc6c1b | |||
| db0a36fc00 | |||
|
|
32ced78da4 | ||
|
|
8b574adfe6 | ||
|
|
6d787693dc | ||
|
|
e8de396f6c | ||
|
|
59af75a785 | ||
|
|
7c30c6d150 | ||
| 2f79a5d093 | |||
| 856bb3e27b | |||
|
|
7e09934024 | ||
| e2d276c4fc | |||
| c182e17abb | |||
| f41672a613 | |||
| 8eb72831c1 | |||
|
|
79bbf4a39c | ||
|
|
09401aae46 | ||
|
|
c0bce28529 | ||
|
|
1780913228 | ||
|
|
3c0f1e53aa | ||
|
|
65123ada6a | ||
|
|
21cf6b9c8b | ||
|
|
655fced1ce | ||
|
|
bf56c9ead9 | ||
|
|
d8c991883c | ||
|
|
0df98345d5 | ||
|
|
60f4c75d4b | ||
|
|
c7ee259531 | ||
|
|
15438835b1 | ||
|
|
34f27aa3aa | ||
|
|
9506c7b1b6 | ||
|
|
3b7c9311fe | ||
|
|
b92d9c061a | ||
|
|
b8a24f5751 | ||
|
|
7e2f59eba8 | ||
|
|
ef8b65cbf2 | ||
|
|
058756af0a | ||
|
|
ac10af1112 | ||
|
|
3528d6ed17 | ||
|
|
4f8583dfbe | ||
|
|
78e5c1e59c | ||
|
|
88aeb36053 | ||
|
|
29c7567095 | ||
|
|
25d05eab9c | ||
|
|
5cdf8cc380 | ||
|
|
92f3e6fe23 | ||
|
|
c95ef224d8 | ||
|
|
91c202c786 | ||
|
|
60d8cfcf70 | ||
|
|
56be865d3e | ||
|
|
134069df34 | ||
|
|
f7ccc9c386 | ||
|
|
3eca20e927 | ||
|
|
4636bd7e9f | ||
|
|
5e7c4511f8 | ||
|
|
fe28fc5623 | ||
|
|
8401948dc0 | ||
|
|
4413eb3571 | ||
|
|
fbadd44af5 | ||
|
|
e6488d3f1b | ||
|
|
e4ecc57825 | ||
|
|
c5e90c9e6c | ||
|
|
c8c6d17c9c | ||
|
|
dd87729455 |
13
Makefile
@@ -1,8 +1,13 @@
|
||||
export GO111MODULE=on
|
||||
export CGO_ENABLED=0
|
||||
export GOOS=linux
|
||||
export GOARCH=amd64
|
||||
|
||||
build: frps-multiuser
|
||||
cp ./config/frps-multiuser.ini ./bin/frps-multiuser.ini
|
||||
build: frps-panel
|
||||
cp ./config/frps-panel.toml ./bin/frps-panel.toml
|
||||
cp ./config/frps-tokens.toml ./bin/frps-tokens.toml
|
||||
cp -r ./assets/ ./bin/assets/
|
||||
|
||||
frps-multiuser:
|
||||
go build -o ./bin/frps-multiuser ./cmd/frps-multiuser
|
||||
frps-panel:
|
||||
rm -rf ./bin
|
||||
go build -o ./bin/frps-panel ./cmd/frps-panel
|
||||
|
||||
@@ -5,20 +5,21 @@ package: copy
|
||||
sh ./package.sh
|
||||
|
||||
copy: build
|
||||
cp ./config/frps-multiuser.ini ./release/frps-multiuser.ini
|
||||
cp ./config/frps-panel.toml ./release/frps-panel.toml
|
||||
cp ./config/frps-tokens.toml ./release/frps-tokens.toml
|
||||
cp -r ./assets/ ./release/assets/
|
||||
|
||||
build:
|
||||
env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o ./release/frps-multiuser-darwin-amd64 ./cmd/frps-multiuser
|
||||
env CGO_ENABLED=0 GOOS=freebsd GOARCH=386 go build -ldflags "$(LDFLAGS)" -o ./release/frps-multiuser-freebsd-386 ./cmd/frps-multiuser
|
||||
env CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o ./release/frps-multiuser-freebsd-amd64 ./cmd/frps-multiuser
|
||||
env CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags "$(LDFLAGS)" -o ./release/frps-multiuser-linux-386 ./cmd/frps-multiuser
|
||||
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o ./release/frps-multiuser-linux-amd64 ./cmd/frps-multiuser
|
||||
env CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -ldflags "$(LDFLAGS)" -o ./release/frps-multiuser-linux-arm ./cmd/frps-multiuser
|
||||
env CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -o ./release/frps-multiuser-linux-arm64 ./cmd/frps-multiuser
|
||||
env CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags "$(LDFLAGS)" -o ./release/frps-multiuser-windows-386.exe ./cmd/frps-multiuser
|
||||
env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o ./release/frps-multiuser-windows-amd64.exe ./cmd/frps-multiuser
|
||||
env CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build -ldflags "$(LDFLAGS)" -o ./release/frps-multiuser-linux-mips64 ./cmd/frps-multiuser
|
||||
env CGO_ENABLED=0 GOOS=linux GOARCH=mips64le go build -ldflags "$(LDFLAGS)" -o ./release/frps-multiuser-linux-mips64le ./cmd/frps-multiuser
|
||||
env CGO_ENABLED=0 GOOS=linux GOARCH=mips GOMIPS=softfloat go build -ldflags "$(LDFLAGS)" -o ./release/frps-multiuser-linux-mips ./cmd/frps-multiuser
|
||||
env CGO_ENABLED=0 GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build -ldflags "$(LDFLAGS)" -o ./release/frps-multiuser-linux-mipsle ./cmd/frps-multiuser
|
||||
env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o ./release/frps-panel-darwin-amd64 ./cmd/frps-panel
|
||||
env CGO_ENABLED=0 GOOS=freebsd GOARCH=386 go build -ldflags "$(LDFLAGS)" -o ./release/frps-panel-freebsd-386 ./cmd/frps-panel
|
||||
env CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o ./release/frps-panel-freebsd-amd64 ./cmd/frps-panel
|
||||
env CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags "$(LDFLAGS)" -o ./release/frps-panel-linux-386 ./cmd/frps-panel
|
||||
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o ./release/frps-panel-linux-amd64 ./cmd/frps-panel
|
||||
env CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -ldflags "$(LDFLAGS)" -o ./release/frps-panel-linux-arm ./cmd/frps-panel
|
||||
env CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -o ./release/frps-panel-linux-arm64 ./cmd/frps-panel
|
||||
env CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags "$(LDFLAGS)" -o ./release/frps-panel-windows-386.exe ./cmd/frps-panel
|
||||
env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o ./release/frps-panel-windows-amd64.exe ./cmd/frps-panel
|
||||
env CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build -ldflags "$(LDFLAGS)" -o ./release/frps-panel-linux-mips64 ./cmd/frps-panel
|
||||
env CGO_ENABLED=0 GOOS=linux GOARCH=mips64le go build -ldflags "$(LDFLAGS)" -o ./release/frps-panel-linux-mips64le ./cmd/frps-panel
|
||||
env CGO_ENABLED=0 GOOS=linux GOARCH=mips GOMIPS=softfloat go build -ldflags "$(LDFLAGS)" -o ./release/frps-panel-linux-mips ./cmd/frps-panel
|
||||
env CGO_ENABLED=0 GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build -ldflags "$(LDFLAGS)" -o ./release/frps-panel-linux-mipsle ./cmd/frps-panel
|
||||
257
README.md
@@ -1,138 +1,202 @@
|
||||
# frps-multiuser
|
||||
|
||||
frp server plugin to support multiple users for [frp](https://github.com/fatedier/frp).
|
||||
|
||||
frps-multiuser will run as one single process and accept HTTP requests from frps.
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
## update notes
|
||||
|
||||
+ **the default tokens file is frps-multiuser.ini now,ini file support comment**
|
||||
+ **remove `-l`,it configure in `frps-multiuser.ini` now**
|
||||
+ **change `-f` to `-c`,the same as `frps`**
|
||||
+ **if \[users\] section is empty,the authentication will only be handle by frps**
|
||||
+ **if user under \[disabled\] section ,and the value is `disable`, it means that user is be disabled, and can not connect to server**
|
||||
+ **add a manage ui, and change color mode base on browser**
|
||||
+ **you can dynamic `add`,`remove`,`disable` or `enable` user now**
|
||||
+ **you can limit `ports`,`domains` and `subdomains` for each user now**
|
||||
|
||||
***when a user is dynamic been `remove` or `disable`,it will take some time to be effective***
|
||||
***the limit of `ports`、`domains`、`subdomains` only effective at `NewProxy`***
|
||||
# frps-panel(Support FRP >= 0.52.0)
|
||||
|
||||
[README](README.md) | [中文文档](README_zh.md)
|
||||
|
||||
frp server plugin to show server info and support multiple users for [frp](https://github.com/fatedier/frp).
|
||||
|
||||
frps-panel will run as one single process and accept HTTP requests from frps.
|
||||
|
||||
## Since version 2.0.0,this plugin only support frp version >= v0.52.0
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
### Features
|
||||
|
||||
* Support multiple user authentication by tokens saved in file.
|
||||
* Support dynamic `add`,`remove`,`disable` or `enable` user
|
||||
* Limit `ports`,`domains` and `subdomains` for each user
|
||||
+ **Show frp server info**
|
||||
+ **Support multiple user authentication by tokens saved in file.**
|
||||
+ **Dynamic `add`,`remove`,`disable` or `enable` user now**
|
||||
+ **Limit `ports`,`domains` and `subdomains` for each user now**
|
||||
|
||||
***when a user is dynamic been `remove` or `disable`,it will take some time to be effective***
|
||||
|
||||
***the limit of `ports`、`domains`、`subdomains` only effective at `NewProxy`***
|
||||
|
||||
### Download
|
||||
|
||||
Download frps-multiuser binary file from [Release](../../releases).
|
||||
Download frps-panel binary file from [Release](../../releases).
|
||||
|
||||
### Requirements
|
||||
|
||||
frp version >= v0.31.0
|
||||
frp version >= v0.52.3
|
||||
|
||||
### Usage
|
||||
|
||||
1. Create file `frps-multiuser.ini` including all support usernames and tokens.
|
||||
1. Create file `frps-panel.toml` including common config.
|
||||
|
||||
```ini
|
||||
```toml
|
||||
#frps-panel.toml
|
||||
[common]
|
||||
;plugin listen ip
|
||||
plugin_addr = 127.0.0.1
|
||||
;plugin listen port
|
||||
# frps panel config info
|
||||
plugin_addr = "127.0.0.1"
|
||||
plugin_port = 7200
|
||||
;the username of manage ui,optional
|
||||
admin_user = admin
|
||||
;the password of manage ui,optional
|
||||
admin_pwd = admin
|
||||
#admin_user = "admin"
|
||||
#admin_pwd = "admin"
|
||||
# specified login state keep time
|
||||
admin_keep_time = 0
|
||||
|
||||
[users]
|
||||
;user user1 with meta_token 123
|
||||
user1 = 123
|
||||
;user user2 with meta_token abc
|
||||
user2 = abc
|
||||
# enable tls
|
||||
tls_mode = false
|
||||
# tls_cert_file = "cert.crt"
|
||||
# tls_key_file = "cert.key"
|
||||
|
||||
[ports]
|
||||
;user1 can only use ports 8080,9090 to 9010 ,other ports will fail to create proxy (frpc can normally startup)
|
||||
user1=8080,9090-9010
|
||||
|
||||
[domains]
|
||||
;user1 can only use domain web01.user1.com ,other domain will fail to create proxy (frpc can normally startup)
|
||||
user1=web01.user1.com
|
||||
|
||||
[subdomains]
|
||||
;user1 can only use subdomain web01 ,other subdomain will fail to create proxy (frpc can normally startup)
|
||||
user1=web01
|
||||
|
||||
[disabled]
|
||||
;user2 is disabled,when frpc use this user to connect with frps,if frpc is not startup,it cannot startup,if it's already startup,it will always show error logs on console
|
||||
user2 = disable
|
||||
# frp dashboard info
|
||||
dashboard_addr = "127.0.0.1"
|
||||
dashboard_port = 7500
|
||||
dashboard_user = "admin"
|
||||
dashboard_pwd = "admin"
|
||||
```
|
||||
|
||||
One user each line. Username and token are split by `=`.
|
||||
2. Create file `frps-tokens.toml` to save users,it should be the same place with `frps-panel.toml`.this file will auto create by system.
|
||||
|
||||
2. Run frps-multiuser:
|
||||
|
||||
`./frps-multiuser -c ./frps-multiuser.ini`
|
||||
|
||||
3. Register plugin in frps.
|
||||
|
||||
```ini
|
||||
# frps.ini
|
||||
[common]
|
||||
bind_port = 7000
|
||||
|
||||
[plugin.multiuser]
|
||||
addr = 127.0.0.1:7200
|
||||
path = /handler
|
||||
ops = Login,NewWorkConn,NewUserConn,NewProxy,Ping
|
||||
```toml
|
||||
#frps-tokens.toml
|
||||
[tokens]
|
||||
[tokens.user1]
|
||||
user = "user1"
|
||||
token = "token1"
|
||||
comment = "user1 with token1"
|
||||
ports = [8080, "10000-10200"]
|
||||
domains = ["web01.domain.com", "web02.domain.com"]
|
||||
subdomains = ["web01", "web02"]
|
||||
enable = true
|
||||
[tokens.user2]
|
||||
user = "user2"
|
||||
token = "token2"
|
||||
comment = "user2 with token2"
|
||||
ports = [9080]
|
||||
domains = ["web11.domain.com", "web12.domain.com"]
|
||||
subdomains = ["web11", "web12"]
|
||||
enable = false
|
||||
```
|
||||
|
||||
4. Specify username and meta_token in frpc configure file.
|
||||
|
||||
3. Run frps-panel:
|
||||
|
||||
`./frps-panel -c ./frps-panel.toml`
|
||||
|
||||
4. Register plugin in frps.
|
||||
|
||||
```toml
|
||||
# frps.toml
|
||||
bindPort = 7000
|
||||
|
||||
[[httpPlugins]]
|
||||
name = "frps-panel"
|
||||
addr = "127.0.0.1:7200"
|
||||
path = "/handler"
|
||||
ops = ["Login","NewWorkConn","NewUserConn","NewProxy","Ping"]
|
||||
```
|
||||
|
||||
5. Specify username and metadatas.token in frpc configure file.
|
||||
|
||||
For user1:
|
||||
|
||||
```ini
|
||||
# frpc.ini
|
||||
[common]
|
||||
server_addr = x.x.x.x
|
||||
server_port = 7000
|
||||
user = user1
|
||||
meta_token = 123
|
||||
```toml
|
||||
# frpc.toml
|
||||
serverAddr = "127.0.0.1"
|
||||
serverPort = 7000
|
||||
user = "user1"
|
||||
metadatas.token = "123"
|
||||
|
||||
[ssh]
|
||||
type = tcp
|
||||
local_port = 22
|
||||
remote_port = 8080
|
||||
[[proxies]]
|
||||
type = "tcp"
|
||||
localIP = 22
|
||||
localPort = 8080
|
||||
```
|
||||
or
|
||||
```toml
|
||||
# frpc.toml
|
||||
serverAddr = "127.0.0.1"
|
||||
serverPort = 7000
|
||||
user = "user1"
|
||||
[metadatas]
|
||||
token = "123"
|
||||
|
||||
[[proxies]]
|
||||
type = "tcp"
|
||||
localIP = 22
|
||||
localPort = 8080
|
||||
```
|
||||
|
||||
For user2:(user2 cannot connect to server,because it is disabled)
|
||||
|
||||
```ini
|
||||
# frpc.ini
|
||||
[common]
|
||||
server_addr = x.x.x.x
|
||||
server_port = 7000
|
||||
user = user2
|
||||
meta_token = abc
|
||||
```toml
|
||||
# frpc.toml
|
||||
serverAddr = "127.0.0.1"
|
||||
serverPort = 7000
|
||||
user = "user2"
|
||||
metadatas.token = "abc"
|
||||
|
||||
[ssh]
|
||||
type = tcp
|
||||
[[proxies]]
|
||||
type = "tcp"
|
||||
local_port = 22
|
||||
remote_port = 6000
|
||||
```
|
||||
or
|
||||
```toml
|
||||
# frpc.toml
|
||||
serverAddr = "127.0.0.1"
|
||||
serverPort = 7000
|
||||
user = "user2"
|
||||
[metadatas]
|
||||
token = "abc"
|
||||
|
||||
[[proxies]]
|
||||
type = "tcp"
|
||||
local_port = 22
|
||||
remote_port = 6000
|
||||
```
|
||||
|
||||
6. Manage your users in browser via: http://127.0.0.1:7200 or https://127.0.0.1:7200
|
||||
|
||||
## Run as service
|
||||
|
||||
this example is for `ubuntu` and with `root` user
|
||||
|
||||
+ 1.unzip `frps-panel.zip` to dir `/root/frps-panel`
|
||||
+ 2.touch a file with command `touch frps-panel.service` in dir `/root/frps-panel`.the file content is:
|
||||
```ini
|
||||
[Unit]
|
||||
Description = frp multiuser service
|
||||
After = network.target syslog.target
|
||||
Wants = network.target
|
||||
|
||||
[Service]
|
||||
Type = simple
|
||||
# config of frps-panel.toml,you should change the file path
|
||||
Environment=FRPS_PANEL_OPTS="-c /root/frps-panel/frps-panel.toml"
|
||||
# command of run frps-panel,you should change the file path
|
||||
ExecStart = /root/frps-panel/frps-panel $FRPS_PANEL_OPTS
|
||||
|
||||
[Install]
|
||||
WantedBy = multi-user.target
|
||||
```
|
||||
+ 3.copy `frps-panel.service` to `/etc/systemd/system/` with command `cp /root/frps-panel.service /etc/systemd/system/`
|
||||
+ 4.reload service with command `systemctl daemon-reload`
|
||||
+ 5.start service with command `service frps-panel start`
|
||||
|
||||
## Issues & Ideas
|
||||
|
||||
If you have any issues or ideas, put it on [issues](https://github.com/yhl452493373/frps-multiuser/issues). I will try my best to achieve it.
|
||||
___If you want visit mange ui from internet, you should change `plugin_addr` to `0.0.0.0`___
|
||||
|
||||
If you have any issues or ideas, put it on [issues](https://github.com/yhl452493373/frps-panel/issues). I will try my best to achieve it.
|
||||
|
||||
## Credits
|
||||
|
||||
@@ -140,3 +204,4 @@ If you have any issues or ideas, put it on [issues](https://github.com/yhl452493
|
||||
+ [fp-multiuser](https://github.com/gofrp/fp-multiuser)
|
||||
+ [layui](https://github.com/layui/layui)
|
||||
+ [layui-theme-dark](https://github.com/Sight-wcg/layui-theme-dark)
|
||||
+ [echarts](https://github.com/apache/echarts)
|
||||
|
||||
241
README_zh.md
@@ -1,35 +1,33 @@
|
||||
# frps-multiuser
|
||||
# frps-panel(支持 FRP >= 0.52.0)
|
||||
|
||||
[README](README.md) | [中文文档](README_zh.md)
|
||||
|
||||
frps-multiuser 是 [frp](https://github.com/fatedier/frp) 的一个服务端插件,用于支持多用户鉴权。
|
||||
frps-panel 是 [frp](https://github.com/fatedier/frp) 的一个服务端插件,用于查看服务器信息以及支持多用户鉴权。
|
||||
|
||||
frps-multiuser 会以一个单独的进程运行,并接收 frps 发送过来的 HTTP 请求。
|
||||
frps-panel 会以一个单独的进程运行,并接收 frps 发送过来的 HTTP 请求。
|
||||
|
||||
## 从版本2.0.0开始,本插件只支持版本号大于等于v0.52.0的frp
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
## 更新说明
|
||||
|
||||
+ **配置文件改为ini格式,便于增加注释**
|
||||
+ **删除-l参数,其需要的配置由`frps-multiuser.ini`决定**
|
||||
+ **指定配置文件的参数由`-f`改为`-c`,和`frps`一致**
|
||||
+ **配置文件中,\[users\]节下如无用户信息,则直接由frps的token认证**
|
||||
+ **配置文件中,\[disabled\]节下用户名对应的值如果为`disable`,则说明该账户被禁用,无法连接到服务器**
|
||||
+ **增加了管理界面,并且会根据浏览器主题自动切换深色或浅色模式**
|
||||
+ **新增动态`添加`、`删除`、`禁用`、`启用`用户**
|
||||
+ **新增对用户的`端口`、`域名`、`二级域名`进行限制**
|
||||
|
||||
***用户被`删除`或`禁用`后,不会马上生效,需要等一段时间***
|
||||
***用户`端口`、`域名`、`二级域名`限制仅在建立新连接(`NewProxy`)时生效***
|
||||
|
||||
### 功能
|
||||
|
||||
* 通过配置文件配置所有支持的用户名和 Token,只允许匹配的 frpc 客户端登录。
|
||||
* 动态`添加`、`删除`、`禁用`、`启用`用户
|
||||
* 对每个用户进行`端口`、`域名`、`二级域名`限制
|
||||
+ **支持展示服务器信息**
|
||||
+ **支持多用户鉴权**
|
||||
+ **动态`添加`、`删除`、`禁用`、`启用`用户**
|
||||
+ **对用户的`端口`、`域名`、`二级域名`进行限制**
|
||||
|
||||
***用户被`删除`或`禁用`后,不会马上生效,需要等一段时间***
|
||||
|
||||
***用户`端口`、`域名`、`二级域名`限制仅在建立新连接(`NewProxy`)时生效***
|
||||
|
||||
### 下载
|
||||
|
||||
@@ -37,102 +35,168 @@ frps-multiuser 会以一个单独的进程运行,并接收 frps 发送过来
|
||||
|
||||
### 要求
|
||||
|
||||
需要 frp 版本 >= v0.31.0
|
||||
需要 frp 版本 >= v0.52.3
|
||||
|
||||
### 使用示例
|
||||
|
||||
1. 创建 `frps-multiuser.ini` 文件,内容为所有支持的用户名和 token。
|
||||
1. 创建 `frps-panel.toml` 文件,内容为基础配置。
|
||||
|
||||
```ini
|
||||
```toml
|
||||
# frps-panel.toml
|
||||
[common]
|
||||
;插件监听地址
|
||||
plugin_addr = 127.0.0.1
|
||||
;插件端口
|
||||
# frps panel config info
|
||||
plugin_addr = "127.0.0.1"
|
||||
plugin_port = 7200
|
||||
;插件管理页面账号,可选
|
||||
admin_user = admin
|
||||
;插件管理页面密码,与账号一起进行鉴权,可选
|
||||
admin_pwd = admin
|
||||
#admin_user = "admin"
|
||||
#admin_pwd = "admin"
|
||||
# specified login state keep time
|
||||
admin_keep_time = 0
|
||||
|
||||
[users]
|
||||
;user1的meta_token为123
|
||||
user1 = 123
|
||||
;user2的meta_token为abc
|
||||
user2 = abc
|
||||
# enable tls
|
||||
tls_mode = false
|
||||
# tls_cert_file = "cert.crt"
|
||||
# tls_key_file = "cert.key"
|
||||
|
||||
[ports]
|
||||
;user1只能使用8080,9090到9010端口,其他端口则建立连接时返回失败(不影响客户端启动)
|
||||
user1=8080,9090-9010
|
||||
|
||||
[domains]
|
||||
;user1只能使用web01.yyy.zzz域名,配置了其他域名则建立连接时返回失败(不影响客户端启动)
|
||||
user1=web01.user1.com
|
||||
|
||||
[subdomains]
|
||||
;user1只能使用web01.xxx.yyy.zzz域名,配置了其他三级域名则建立连接时返回失败(不影响客户端启动)
|
||||
user1=web01
|
||||
|
||||
[disabled]
|
||||
;user2被禁用,frpc使用此账户与frps通信时,如果未启动则无法启动,如果已启动,则会一直打印错误日志
|
||||
user2 = disable
|
||||
# frp dashboard info
|
||||
dashboard_addr = "127.0.0.1"
|
||||
dashboard_port = 7500
|
||||
dashboard_user = "admin"
|
||||
dashboard_pwd = "admin"
|
||||
```
|
||||
|
||||
每一个用户占一行,用户名和 token 之间以 `=` 号分隔。
|
||||
2. 创建`frps-tokens.toml`文件,其内容为系统中的用户,该文件位置和`frps-panel.toml`相同。如不创建此文件,在增加用户时会自动创建。
|
||||
|
||||
2. 运行 frps-multiuser,指定监听地址以及 token 存储文件路径。
|
||||
|
||||
`./frps-multiuser -c ./frps-multiuser.ini`
|
||||
|
||||
3. 在 frps 的配置文件中注册插件,并启动。
|
||||
|
||||
```ini
|
||||
# frps.ini
|
||||
[common]
|
||||
bind_port = 7000
|
||||
|
||||
[plugin.multiuser]
|
||||
addr = 127.0.0.1:7200
|
||||
path = /handler
|
||||
ops = Login,NewWorkConn,NewUserConn,NewProxy,Ping
|
||||
```toml
|
||||
#frps-tokens.toml
|
||||
[tokens]
|
||||
[tokens.user1]
|
||||
user = "user1"
|
||||
token = "token1"
|
||||
comment = "user1 with token1"
|
||||
ports = [8080, "10000-10200"]
|
||||
domains = ["web01.domain.com", "web02.domain.com"]
|
||||
subdomains = ["web01", "web02"]
|
||||
enable = true
|
||||
[tokens.user2]
|
||||
user = "user2"
|
||||
token = "token2"
|
||||
comment = "user2 with token2"
|
||||
ports = [9080]
|
||||
domains = ["web11.domain.com", "web12.domain.com"]
|
||||
subdomains = ["web11", "web12"]
|
||||
enable = false
|
||||
```
|
||||
|
||||
4. 在 frpc 中指定用户名,在 meta 中指定 token,用户名以及 `meta_token` 的内容需要和之前创建的 token 文件匹配。
|
||||
3. 运行 frps-panel,指定配置文件路径。
|
||||
|
||||
`./frps-panel -c ./frps-panel.toml`
|
||||
|
||||
4. 在 frps 的配置文件中注册插件,并启动。
|
||||
|
||||
```toml
|
||||
# frps.toml
|
||||
bindPort = 7000
|
||||
|
||||
[[httpPlugins]]
|
||||
name = "frps-panel"
|
||||
addr = "127.0.0.1:7200"
|
||||
path = "/handler"
|
||||
ops = ["Login","NewWorkConn","NewUserConn","NewProxy","Ping"]
|
||||
```
|
||||
|
||||
5. 在 frpc 中指定用户名,在 metadatas 中指定 token,用户名以及 `metadatas.token` 的内容需要和之前创建的 token 文件匹配。
|
||||
|
||||
user1 的配置:
|
||||
|
||||
```ini
|
||||
# frpc.ini
|
||||
[common]
|
||||
server_addr = x.x.x.x
|
||||
server_port = 7000
|
||||
user = user1
|
||||
meta_token = 123
|
||||
```toml
|
||||
# frpc.toml
|
||||
serverAddr = "127.0.0.1"
|
||||
serverPort = 7000
|
||||
user = "user1"
|
||||
metadatas.token = "123"
|
||||
|
||||
[ssh]
|
||||
type = tcp
|
||||
local_port = 22
|
||||
remote_port = 8080
|
||||
[[proxies]]
|
||||
type = "tcp"
|
||||
localIP = 22
|
||||
localPort = 8080
|
||||
```
|
||||
或
|
||||
```toml
|
||||
# frpc.toml
|
||||
serverAddr = "127.0.0.1"
|
||||
serverPort = 7000
|
||||
user = "user1"
|
||||
[metadatas]
|
||||
token = "123"
|
||||
|
||||
[[proxies]]
|
||||
type = "tcp"
|
||||
localIP = 22
|
||||
localPort = 8080
|
||||
```
|
||||
|
||||
user2 的配置:(由于示例文件中user2被禁用,因此无法连接)
|
||||
|
||||
```ini
|
||||
# frpc.ini
|
||||
[common]
|
||||
server_addr = x.x.x.x
|
||||
server_port = 7000
|
||||
user = user2
|
||||
meta_token = abc
|
||||
```toml
|
||||
# frpc.toml
|
||||
serverAddr = "127.0.0.1"
|
||||
serverPort = 7000
|
||||
user = "user2"
|
||||
metadatas.token = "abc"
|
||||
|
||||
[ssh]
|
||||
type = tcp
|
||||
[[proxies]]
|
||||
type = "tcp"
|
||||
local_port = 22
|
||||
remote_port = 6000
|
||||
```
|
||||
或
|
||||
```toml
|
||||
# frpc.toml
|
||||
serverAddr = "127.0.0.1"
|
||||
serverPort = 7000
|
||||
user = "user2"
|
||||
[metadatas]
|
||||
token = "abc"
|
||||
|
||||
[[proxies]]
|
||||
type = "tcp"
|
||||
local_port = 22
|
||||
remote_port = 6000
|
||||
```
|
||||
|
||||
6.浏览器中输入地址: http://127.0.0.1:7200 或 https://127.0.0.1:7200 进入管理页面进行用户管理
|
||||
|
||||
## 以服务的形式运行
|
||||
|
||||
本实例是在 `ubuntu` 下, 以 `root` 用户执操作
|
||||
|
||||
+ 1、解压 `frps-panel.zip` 到目录 `/root/frps-panel`
|
||||
+ 2、在目录 `/root/frps-panel` 下 用命令创建文件:`touch frps-panel.service`。创建后修改文件内容:
|
||||
```ini
|
||||
[Unit]
|
||||
Description = frp multiuser service
|
||||
After = network.target syslog.target
|
||||
Wants = network.target
|
||||
|
||||
[Service]
|
||||
Type = simple
|
||||
# 启动frps-panel的配置文件路径,需修改为您的frps-panel.toml的路径
|
||||
Environment=FRPS_PANEL_OPTS="-c /root/frps-panel/frps-panel.toml"
|
||||
# 启动frps-panel的命令,需修改为您的frps-panel的安装路径
|
||||
ExecStart = /root/frps-panel/frps-panel $FRPS_PANEL_OPTS
|
||||
|
||||
[Install]
|
||||
WantedBy = multi-user.target
|
||||
```
|
||||
+ 3、复制服务文件: `cp /root/frps-panel.service /etc/systemd/system/`
|
||||
+ 4、重载服务: `systemctl daemon-reload`
|
||||
+ 5、启动服务: `service frps-panel start`
|
||||
|
||||
## 使用
|
||||
|
||||
如果使用中有问题或者有其他想法,在[issues](https://github.com/yhl452493373/frps-multiuser/issues)上提出来。 如果我能搞定的话,我尽量搞。
|
||||
___如果要从外网访问管理界面, 需要把配置中的 `plugin_addr` 改为 `0.0.0.0`___
|
||||
|
||||
如果使用中有问题或者有其他想法,在[issues](https://github.com/yhl452493373/frps-panel/issues)上提出来。 如果我能搞定的话,我尽量搞。
|
||||
|
||||
## 致谢
|
||||
|
||||
@@ -140,3 +204,4 @@ remote_port = 6000
|
||||
+ [fp-multiuser](https://github.com/gofrp/fp-multiuser)
|
||||
+ [layui](https://github.com/layui/layui)
|
||||
+ [layui-theme-dark](https://github.com/Sight-wcg/layui-theme-dark)
|
||||
+ [echarts](https://github.com/apache/echarts)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"User Manage": "User Manage",
|
||||
"Frps Panel": "Frps Panel",
|
||||
"User": "User",
|
||||
"Token": "Token",
|
||||
"Notes": "Notes",
|
||||
@@ -29,6 +29,7 @@
|
||||
"Other error": "Other error",
|
||||
"Param error": "Param error",
|
||||
"User exist": "User exist",
|
||||
"User not exist": "User not exist",
|
||||
"User format error": "User cannot be empty or include space char. It only allowed alphanumeric and underline.",
|
||||
"Token format error": "Token cannot be empty or include space char. It allow include those special char: _!@#$%^&*()",
|
||||
"Please check at least one user": "Please Check at least one user",
|
||||
@@ -45,5 +46,62 @@
|
||||
"Subdomains is invalid": "Subdomains is invalid",
|
||||
"Comment is invalid": "Comment is invalid, it cannot include line breaks",
|
||||
"Not limit": "Not limit",
|
||||
"None": "None"
|
||||
"None": "None",
|
||||
"Server Info": "Server Info",
|
||||
"Users": "Users",
|
||||
"Proxies": "Proxies",
|
||||
"Name": "Name",
|
||||
"Port": "Port",
|
||||
"Connections": "Connections",
|
||||
"Traffic In": "Traffic In",
|
||||
"Traffic Out": "Traffic Out",
|
||||
"Client Version": "Client Version",
|
||||
"Traffic Statistics": "Traffic Statistics",
|
||||
"Type": "Type",
|
||||
"Domains": "Domains",
|
||||
"SubDomain": "SubDomain",
|
||||
"Locations": "Locations",
|
||||
"HostRewrite": "HostRewrite",
|
||||
"Encryption": "Encryption",
|
||||
"Compression": "Compression",
|
||||
"Addr": "Addr",
|
||||
"online": "online",
|
||||
"offline": "offline",
|
||||
"true": "Yes",
|
||||
"false": "No",
|
||||
"Last Start": "Last Start",
|
||||
"Last Close": "Last Close",
|
||||
"Network Traffic": "Network Traffic",
|
||||
"today": "today",
|
||||
"now": "now",
|
||||
"Version": "Version",
|
||||
"Bind Port": "Bind Port",
|
||||
"KCP Bind Port": "KCP Bind Port",
|
||||
"QUIC Bind Port": "QUIC Bind Port",
|
||||
"HTTP Port": "HTTP Port",
|
||||
"HTTPS Port": "HTTPS Port",
|
||||
"TCPMUX Port": "TCPMUX Port",
|
||||
"Subdomain Host": "Subdomain Host",
|
||||
"Max Pool Count": "Max Pool Count",
|
||||
"Max Ports Per Client": "Max Ports Per Client",
|
||||
"Heart Beat Timeout": "Heart Beat Timeout",
|
||||
"Allow Ports": "Allow Ports",
|
||||
"TLS Only": "TLS Only",
|
||||
"Current Connections": "Current Connections",
|
||||
"Client Counts": "Client Counts",
|
||||
"Proxy Counts": "Proxy Counts",
|
||||
"Not Set": "Not Set",
|
||||
"Proxy": "Proxies",
|
||||
"Username": "Username",
|
||||
"Password": "Password",
|
||||
"Login": "Login",
|
||||
"Please input username": "Please input username",
|
||||
"Please input password": "Please input password",
|
||||
"Login success": "Login success",
|
||||
"Username or password incorrect": "Username or password incorrect",
|
||||
"Token invalid": "Token invalid",
|
||||
"Total": "Total ",
|
||||
"Items": " items",
|
||||
"Go to": "Go to",
|
||||
"Per Page": " / page"
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"User Manage": "用户管理",
|
||||
"Frps Panel": "Frps 面板",
|
||||
"User": "用户名(user)",
|
||||
"Token": "凭证(meta_token)",
|
||||
"Notes": "备注",
|
||||
@@ -29,6 +29,7 @@
|
||||
"Other error": "其他异常",
|
||||
"Param error": "参数异常",
|
||||
"User exist": "用户已经存在",
|
||||
"User not exist": "用户不存在",
|
||||
"User format error": "用户不能为空或包含空格。只允许英文数字、字母、下划线",
|
||||
"Token format error": "Token不能为空或包含空格。允许的特殊符号:_!@#$%^&*()",
|
||||
"Please check at least one user": "请选中需要操作的用户",
|
||||
@@ -39,11 +40,68 @@
|
||||
"Allowed domains": "允许域名",
|
||||
"Please input allowed domains": "请输入允许使用的域名,如:web01.domain.com,web02.domain.com",
|
||||
"Allowed subdomains": "允许子域名",
|
||||
"Please input allowed subdomains": "请输入允许使用的端口,如:web01,web02",
|
||||
"Please input allowed subdomains": "请输入允许使用的子域名,如:web01,web02",
|
||||
"Ports is invalid": "端口不正确",
|
||||
"Domains is invalid": "域名不正确",
|
||||
"Subdomains is invalid": "子域名不正确",
|
||||
"Comment is invalid": "备注不正确,不能包含换行",
|
||||
"Not limit": "无限制",
|
||||
"None": "无"
|
||||
"None": "无",
|
||||
"Server Info": "服务器信息",
|
||||
"Users": "用户列表",
|
||||
"Proxies": "代理列表",
|
||||
"Name": "名称",
|
||||
"Port": "端口",
|
||||
"Connections": "连接数",
|
||||
"Traffic In": "入站流量",
|
||||
"Traffic Out": "出站流量",
|
||||
"Client Version": "客户端版本",
|
||||
"Traffic Statistics": "流量统计",
|
||||
"Type": "连接类型",
|
||||
"Domains": "自定义域名",
|
||||
"SubDomain": "二级域名",
|
||||
"Locations": "路由",
|
||||
"HostRewrite": "自定义请求头",
|
||||
"Encryption": "数据加密",
|
||||
"Compression": "数据压缩",
|
||||
"Addr": "使用端口",
|
||||
"online": "在线",
|
||||
"offline": "离线",
|
||||
"true": "是",
|
||||
"false": "否",
|
||||
"Last Start": "上次连接时间",
|
||||
"Last Close": "上次断开时间",
|
||||
"Network Traffic": "网络流量",
|
||||
"today": "今日",
|
||||
"now": "当前",
|
||||
"Version": "版本号",
|
||||
"Bind Port": "TCP 端口",
|
||||
"KCP Bind Port": "KCP 端口",
|
||||
"QUIC Bind Port": "QUIC 端口",
|
||||
"HTTP Port": "HTTP 端口",
|
||||
"HTTPS Port": "HTTPS 端口",
|
||||
"TCPMUX Port": "TCPMUX 端口",
|
||||
"Subdomain Host": "二级域名后缀",
|
||||
"Max Pool Count": "每个代理最大连接池大小",
|
||||
"Max Ports Per Client": "单个客户端最大同时存在代理数",
|
||||
"Heart Beat Timeout": "心跳连接超时时间",
|
||||
"Allow Ports": "端口限制",
|
||||
"TLS Only": "仅接受启用 TLS 的客户端",
|
||||
"Current Connections": "当前连接数",
|
||||
"Client Counts": "客户端总数",
|
||||
"Proxy Counts": "代理总数",
|
||||
"Not Set": "未配置",
|
||||
"Proxy": "代理数量",
|
||||
"Username": "用户名",
|
||||
"Password": "密码",
|
||||
"Login": "登录",
|
||||
"Please input username": "请填写用户名",
|
||||
"Please input password": "请填写密码",
|
||||
"Login success": "登录成功",
|
||||
"Username or password incorrect": "用户名或密码错误",
|
||||
"Token invalid": "登录信息无效",
|
||||
"Total": "共",
|
||||
"Items": "条记录",
|
||||
"Go to": "到第",
|
||||
"Per Page": "条/页"
|
||||
}
|
||||
258
assets/static/css/color.css
Normal file
@@ -0,0 +1,258 @@
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: rgba(199, 199, 199, 0.8);
|
||||
}
|
||||
|
||||
.layui-bg-blue {
|
||||
background-color: #58b7ff !important;
|
||||
}
|
||||
|
||||
.layui-btn {
|
||||
background-color: #409eff;
|
||||
}
|
||||
|
||||
.layui-layer-btn .layui-layer-btn0 {
|
||||
background-color: #409eff;
|
||||
}
|
||||
|
||||
.layui-btn-primary {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.layui-btn-primary:hover {
|
||||
border-color: #79bbff;
|
||||
}
|
||||
|
||||
.layui-input:focus,
|
||||
.layui-textarea:focus {
|
||||
border-color: #79bbff !important;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.layui-form-danger + .layui-form-select .layui-input,
|
||||
.layui-form-danger:focus {
|
||||
border-color: #ff5722 !important;
|
||||
}
|
||||
|
||||
.layui-laypage a:hover {
|
||||
color: #409eff;
|
||||
}
|
||||
|
||||
.layui-laypage .layui-laypage-curr .layui-laypage-em {
|
||||
background-color: #409eff;
|
||||
}
|
||||
|
||||
.layui-laypage input:focus, .layui-laypage select:focus {
|
||||
border-color: #79bbff !important;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.layui-table-view .layui-table td[data-edit]:hover:after {
|
||||
border-color: #79bbff;
|
||||
}
|
||||
|
||||
.layui-form-checkbox[lay-skin=primary]:hover > i {
|
||||
border-color: #79bbff;
|
||||
}
|
||||
|
||||
.layui-form-checkbox[lay-skin=primary] > .layui-icon-indeterminate:before {
|
||||
background-color: #79bbff;
|
||||
}
|
||||
|
||||
.layui-form-checkbox[lay-skin=primary] > .layui-icon-indeterminate {
|
||||
border-color: #79bbff;
|
||||
}
|
||||
|
||||
.layui-form-checked[lay-skin=primary] > i {
|
||||
background-color: #409eff;
|
||||
border-color: #409eff !important;
|
||||
}
|
||||
|
||||
.layui-table-checked {
|
||||
background-color: #ecf5ff;
|
||||
}
|
||||
|
||||
.layui-table-checked:hover {
|
||||
background-color: #d9ecff;
|
||||
}
|
||||
|
||||
.layui-table-cell-c:hover {
|
||||
border-color: #79bbff;
|
||||
}
|
||||
|
||||
.layui-table-checked.layui-table-click,
|
||||
.layui-table-checked.layui-table-hover {
|
||||
background-color: #d9ecff;
|
||||
}
|
||||
|
||||
.layui-nav-tree .layui-nav-child dd.layui-this,
|
||||
.layui-nav-tree .layui-nav-child dd.layui-this a,
|
||||
.layui-nav-tree .layui-this,
|
||||
.layui-nav-tree .layui-this > a,
|
||||
.layui-nav-tree .layui-this > a:hover {
|
||||
background-color: #409eff;
|
||||
}
|
||||
|
||||
.layui-nav-tree .layui-nav-bar {
|
||||
background-color: #409eff;
|
||||
}
|
||||
|
||||
.proxy-expand .layui-row .layui-row > div:first-child {
|
||||
color: #99a9bf;
|
||||
}
|
||||
|
||||
section.server-info .text-row .text-col:first-child {
|
||||
color: #99a9bf;
|
||||
}
|
||||
|
||||
section.proxy-list .proxy-info .layui-row .layui-row > div:first-child {
|
||||
color: #99a9bf;
|
||||
}
|
||||
|
||||
.online,
|
||||
.offline {
|
||||
border-radius: 4px;
|
||||
padding: 2px 10px;
|
||||
font-size: 12px;
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
}
|
||||
|
||||
.online {
|
||||
color: #67c23a;
|
||||
background-color: #f0f9eb;
|
||||
border-color: #e1f3d8;
|
||||
}
|
||||
|
||||
.offline {
|
||||
color: #f56c6c;
|
||||
background-color: #fef0f0;
|
||||
border-color: #fde2e2;
|
||||
}
|
||||
|
||||
.version a,
|
||||
.version span {
|
||||
color: #99a9bf;
|
||||
}
|
||||
|
||||
.login-title,
|
||||
.login-title a {
|
||||
color: #333 !important;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: rgba(107, 107, 107, 0.8);
|
||||
}
|
||||
|
||||
.login-title,
|
||||
.login-title a {
|
||||
color: #99a9bf !important;
|
||||
}
|
||||
|
||||
.layui-bg-blue {
|
||||
background-color: #395c74 !important;
|
||||
}
|
||||
|
||||
.layui-btn {
|
||||
background-color: #4f80a1;
|
||||
}
|
||||
|
||||
.layui-layer-btn .layui-layer-btn0 {
|
||||
background-color: #4f80a1;
|
||||
}
|
||||
|
||||
.layui-btn-primary {
|
||||
background-color: transparent;
|
||||
border-color: #484849;
|
||||
}
|
||||
|
||||
.layui-btn-primary:hover {
|
||||
border-color: #5f5f60;
|
||||
}
|
||||
|
||||
.layui-input:focus,
|
||||
.layui-textarea:focus {
|
||||
border-color: #5f5f60 !important;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.layui-laypage a:hover {
|
||||
color: #4f80a1;
|
||||
}
|
||||
|
||||
.layui-laypage .layui-laypage-curr .layui-laypage-em {
|
||||
background-color: #4f80a1;
|
||||
}
|
||||
|
||||
.layui-laypage input:focus, .layui-laypage select:focus {
|
||||
border-color: #5f5f60 !important;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.layui-table-view .layui-table td[data-edit]:hover:after {
|
||||
border-color: #5f5f60;
|
||||
}
|
||||
|
||||
.layui-form-danger + .layui-form-select .layui-input,
|
||||
.layui-form-danger:focus {
|
||||
border-color: #ff5722 !important;
|
||||
}
|
||||
|
||||
.layui-form-checkbox[lay-skin=primary]:hover > i {
|
||||
border-color: #5f5f60;
|
||||
}
|
||||
|
||||
.layui-form-checkbox[lay-skin=primary] > .layui-icon-indeterminate:before {
|
||||
background-color: #5f5f60;
|
||||
}
|
||||
|
||||
.layui-form-checkbox[lay-skin=primary] > .layui-icon-indeterminate {
|
||||
border-color: #5f5f60;
|
||||
}
|
||||
|
||||
.layui-form-checked[lay-skin=primary] > i {
|
||||
background-color: #484849;
|
||||
border-color: #484849 !important;
|
||||
}
|
||||
|
||||
.layui-table-checked {
|
||||
background-color: rgba(255, 255, 255, .04);
|
||||
}
|
||||
|
||||
.layui-table-checked:hover {
|
||||
background-color: rgba(255, 255, 255, .08);
|
||||
}
|
||||
|
||||
.layui-table-cell-c:hover {
|
||||
border-color: #5f5f60;
|
||||
}
|
||||
|
||||
.layui-table-checked.layui-table-click,
|
||||
.layui-table-checked.layui-table-hover {
|
||||
background-color: #5f5f60;
|
||||
}
|
||||
|
||||
.layui-nav-tree .layui-nav-child dd.layui-this,
|
||||
.layui-nav-tree .layui-nav-child dd.layui-this a,
|
||||
.layui-nav-tree .layui-this,
|
||||
.layui-nav-tree .layui-this > a,
|
||||
.layui-nav-tree .layui-this > a:hover {
|
||||
background-color: #4f80a1;
|
||||
}
|
||||
|
||||
.layui-nav-tree .layui-nav-bar {
|
||||
background-color: #4f80a1;
|
||||
}
|
||||
|
||||
.online {
|
||||
color: #67c23a;
|
||||
background-color: #1c2518;
|
||||
border-color: #25371c;
|
||||
}
|
||||
|
||||
.offline {
|
||||
color: #f56c6c;
|
||||
background-color: #2b1d1d;
|
||||
border-color: #412626;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,85 @@
|
||||
body {
|
||||
padding: 15px;
|
||||
::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
border-radius: 4px;
|
||||
transition: 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
html, body {
|
||||
padding: 0;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
section {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
padding: 15px;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.layui-layout-admin .layui-body {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.layui-header {
|
||||
line-height: 60px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.layui-layout-admin .layui-side {
|
||||
width: 225px !important;
|
||||
}
|
||||
|
||||
.layui-side-scroll {
|
||||
width: 245px !important;
|
||||
position: absolute !important;
|
||||
top: 0 !important;
|
||||
bottom: 24px !important;
|
||||
height: auto !important;
|
||||
}
|
||||
|
||||
.layui-logo {
|
||||
width: 225px !important;
|
||||
}
|
||||
|
||||
.layui-title {
|
||||
position: absolute;
|
||||
left: 225px !important;
|
||||
right: 0;
|
||||
top: 0;
|
||||
height: 100%;
|
||||
padding: 0 15px;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.layui-title #title {
|
||||
flex: 1;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.layui-title #logout{
|
||||
display: inline-block;
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.layui-nav.layui-nav-tree {
|
||||
width: 225px !important;
|
||||
}
|
||||
|
||||
.layui-body {
|
||||
left: 225px;
|
||||
}
|
||||
|
||||
#searchForm input {
|
||||
height: 30px;
|
||||
line-height: 28px;
|
||||
@@ -51,3 +128,83 @@ body {
|
||||
.layui-layer-btn > a[class^=layui-layer-btn] {
|
||||
line-height: 28px;
|
||||
}
|
||||
|
||||
.layui-table-page {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
section.server-info {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
section.server-info .text-info,
|
||||
section.server-info .chart-info {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
section.server-info .text-info {
|
||||
padding: 0 20px;
|
||||
}
|
||||
|
||||
section.server-info .text-row {
|
||||
display: flex;
|
||||
font-size: 14px;
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
section.server-info .text-row .text-col {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
section.server-info .chart-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
section.server-info .chart-info > .chart-traffic,
|
||||
section.server-info .chart-info > .chart-count {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
section.server-info .chart-info > .chart-count {
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
section.server-info .chart-info #trafficPieChart,
|
||||
section.server-info .chart-info #countPieChart {
|
||||
width: 400px;
|
||||
height: 250px;
|
||||
}
|
||||
|
||||
.toggle-proxy-info-arrow {
|
||||
display: inline-block;
|
||||
transition-duration: 0.2s;
|
||||
}
|
||||
|
||||
.toggle-proxy-info-arrow.open {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
.proxy-info .layui-row {
|
||||
font-size: 14px !important;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.proxy-info .layui-col-xs6 .layui-row {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#trafficBarChart {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.version {
|
||||
height: 24px;
|
||||
line-height: 24px;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-size: 12px;
|
||||
}
|
||||
30
assets/static/css/login.css
Normal file
@@ -0,0 +1,30 @@
|
||||
html, body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.login-title {
|
||||
text-align: center;
|
||||
margin-bottom: 50px;
|
||||
}
|
||||
|
||||
.login-title .title-text {
|
||||
font-size: 24px;
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.login-title .title-version {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.login-container {
|
||||
width: 320px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
262
assets/static/js/index-proxy-list.js
Normal file
@@ -0,0 +1,262 @@
|
||||
var loadProxyInfo = (function ($) {
|
||||
var size = filesize.partial({base: 2, standard: "jedec"});
|
||||
var i18n = {};
|
||||
|
||||
/**
|
||||
* get proxy info
|
||||
* @param lang {{}} language json
|
||||
* @param title page title
|
||||
* @param proxyType proxy type
|
||||
*/
|
||||
function loadProxyInfo(lang, title, proxyType) {
|
||||
i18n = lang;
|
||||
$("#title").text(title);
|
||||
$('#content').empty();
|
||||
var loading = layui.layer.load();
|
||||
|
||||
$.getJSON('/proxy/api/proxy/' + proxyType).done(function (result) {
|
||||
if (result.success) {
|
||||
$('#content').html($('#proxyListTableTemplate').html());
|
||||
renderProxyListTable(JSON.parse(result.data)['proxies'], proxyType);
|
||||
} else {
|
||||
layui.layer.msg(result.message);
|
||||
}
|
||||
}).always(function () {
|
||||
layui.layer.close(loading);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* render proxy list table
|
||||
* @param data proxy data
|
||||
* @param proxyType proxy type
|
||||
*/
|
||||
function renderProxyListTable(data, proxyType) {
|
||||
proxyType = proxyType.toLowerCase();
|
||||
data.forEach(function (temp) {
|
||||
temp.conf = temp.conf || {
|
||||
remotePort: 0,
|
||||
transport: {
|
||||
useEncryption: false,
|
||||
useCompression: false
|
||||
},
|
||||
customDomains: null,
|
||||
subdomain: null,
|
||||
locations: null,
|
||||
hostHeaderRewrite: null
|
||||
};
|
||||
|
||||
temp.clientVersion = temp.clientVersion || '-';
|
||||
temp.conf.customDomains = temp.conf.customDomains || '-';
|
||||
temp.conf.subdomain = temp.conf.subdomain || '-';
|
||||
temp.conf.locations = temp.conf.locations || '-';
|
||||
temp.conf.hostHeaderRewrite = temp.conf.hostHeaderRewrite || '-';
|
||||
|
||||
if (temp.conf.customDomains !== '-') {
|
||||
temp.conf.customDomains = JSON.stringify(temp.conf.customDomains);
|
||||
}
|
||||
if (proxyType === 'http') {
|
||||
temp.conf.remotePort = httpPort;
|
||||
} else if (proxyType === 'https') {
|
||||
temp.conf.remotePort = httpsPort;
|
||||
}
|
||||
});
|
||||
var $section = $('#content > section');
|
||||
var cols = [
|
||||
{field: 'id', type: 'space', width: 60, align: 'center', templet: '#toggleProxyInfoArrowTemplate'},
|
||||
{field: 'name', title: i18n['Name'], sort: true},
|
||||
{
|
||||
field: 'port',
|
||||
title: i18n['Port'],
|
||||
width: '12%',
|
||||
sort: true,
|
||||
templet: '<span>{{= d.conf.remotePort }}</span>'
|
||||
},
|
||||
{field: 'curConns', title: i18n['Connections'], minWidth: 140, width: '12%', sort: true},
|
||||
{
|
||||
field: 'todayTrafficIn',
|
||||
title: i18n['TrafficIn'],
|
||||
minWidth: 140,
|
||||
width: '12%',
|
||||
sort: true,
|
||||
templet: function (d) {
|
||||
return size(d.todayTrafficIn);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'todayTrafficOut',
|
||||
title: i18n['TrafficOut'],
|
||||
minWidth: 140,
|
||||
width: '12%',
|
||||
sort: true,
|
||||
templet: function (d) {
|
||||
return size(d.todayTrafficOut);
|
||||
}
|
||||
},
|
||||
{field: 'clientVersion', title: i18n['ClientVersion'], minWidth: 140, width: '12%', sort: true},
|
||||
{
|
||||
field: 'status', title: i18n['Status'], width: '12%', sort: true, templet: function (d) {
|
||||
return '<span class="' + d.status + '">' + i18n[d.status] + '</span>';
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
var proxyListTable = layui.table.render({
|
||||
elem: '#proxyListTable',
|
||||
height: $section.height(),
|
||||
text: {none: i18n['EmptyData']},
|
||||
cols: [cols],
|
||||
page: pageOptions,
|
||||
data: data,
|
||||
initSort: {
|
||||
field: 'name',
|
||||
type: 'asc'
|
||||
},
|
||||
done: function (res, curr, count, origin) {
|
||||
//向每一行tr后面追加显示子table的tr
|
||||
var $tr = $('.layui-table-view[lay-id=' + this.id + '] tbody tr');
|
||||
var expandTrTemplateHtml = $('#expandTrTemplate').html();
|
||||
for (var i = 0; i < $tr.length; i++) {
|
||||
var datum = res.data[i];
|
||||
var useEncryption = datum.conf.transport.useEncryption || false;
|
||||
var useCompression = datum.conf.transport.useCompression || false;
|
||||
datum.conf.transport.useEncryption = i18n[useEncryption];
|
||||
datum.conf.transport.useCompression = i18n[useCompression];
|
||||
var html = layui.laytpl(expandTrTemplateHtml).render({
|
||||
index: i,
|
||||
colspan: cols.length - 1,
|
||||
proxyType: proxyType,
|
||||
data: datum
|
||||
});
|
||||
$($tr[i]).after(html);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
layui.table.on('tool(proxyListTable)', function (obj) {
|
||||
var index = obj.index;
|
||||
$(this).toggleClass('open');
|
||||
var open = $(this).hasClass('open');
|
||||
$('#childTr_' + index).toggleClass('layui-hide', !open);
|
||||
proxyListTable.resize();
|
||||
});
|
||||
|
||||
window.onresize = function () {
|
||||
proxyListTable.resize();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* load traffic statistics data
|
||||
*/
|
||||
function loadTrafficStatistics() {
|
||||
var proxyName = $(this).closest('.layui-row').find('input').val();
|
||||
var loading = layui.layer.load();
|
||||
$.getJSON('/proxy/api/traffic/' + proxyName).done(function (result) {
|
||||
if (result.success) {
|
||||
renderTrafficChart(JSON.parse(result.data));
|
||||
} else {
|
||||
layui.layer.msg(result.message);
|
||||
}
|
||||
}).always(function () {
|
||||
layui.layer.close(loading);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* render traffic statistics chart
|
||||
* @param data traffic data
|
||||
*/
|
||||
function renderTrafficChart(data) {
|
||||
var html = layui.laytpl($('#trafficStaticTemplate').html()).render();
|
||||
var dates = [];
|
||||
var now = new Date();
|
||||
for (var i = 0; i < data.trafficIn.length; i++) {
|
||||
dates.push(now.getFullYear() + "/" + (now.getMonth() + 1) + "/" + now.getDate());
|
||||
now.setDate(now.getDate() - 1);
|
||||
}
|
||||
layui.layer.open({
|
||||
title: i18n['TrafficStatistics'],
|
||||
type: 1,
|
||||
content: html,
|
||||
area: ['800px', '400px'],
|
||||
success: function () {
|
||||
var chartDom = document.getElementById('trafficBarChart');
|
||||
var chart = echarts.init(chartDom);
|
||||
var option = {
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: {
|
||||
type: 'shadow',
|
||||
},
|
||||
formatter: function (data) {
|
||||
var html = ''
|
||||
if (data.length > 0) {
|
||||
html += data[0].name + '<br/>'
|
||||
}
|
||||
for (var v of data) {
|
||||
var colorEl = '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:9px;height:9px;background-color:' + v.color + '"></span>'
|
||||
html += colorEl + v.seriesName + ': ' + size(v.value) + '<br/>'
|
||||
}
|
||||
return html
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
data: [i18n['TrafficIn'], i18n['TrafficOut']],
|
||||
textStyle: {
|
||||
textBorderColor: '#fff',
|
||||
textBorderWidth: 2
|
||||
}
|
||||
},
|
||||
grid: {
|
||||
left: '3%',
|
||||
right: '4%',
|
||||
bottom: '3%',
|
||||
containLabel: true,
|
||||
},
|
||||
xAxis: [
|
||||
{
|
||||
type: 'category',
|
||||
data: dates.reverse()
|
||||
}
|
||||
],
|
||||
yAxis: [
|
||||
{
|
||||
type: 'value',
|
||||
axisLabel: {
|
||||
formatter: function (value) {
|
||||
return size(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
series: [
|
||||
{
|
||||
name: i18n['TrafficIn'],
|
||||
type: 'bar',
|
||||
data: data.trafficIn.reverse(),
|
||||
},
|
||||
{
|
||||
name: i18n['TrafficOut'],
|
||||
type: 'bar',
|
||||
data: data.trafficOut.reverse(),
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
option && chart.setOption(option);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* document event
|
||||
*/
|
||||
(function bindDocumentEvent() {
|
||||
$(document).on('click.trafficStatistics', '.traffic-statistics', function () {
|
||||
loadTrafficStatistics.call(this);
|
||||
});
|
||||
})();
|
||||
|
||||
return loadProxyInfo;
|
||||
})(layui.$);
|
||||
190
assets/static/js/index-server-info.js
Normal file
@@ -0,0 +1,190 @@
|
||||
var loadServerInfo = (function ($) {
|
||||
var size = filesize.partial({base: 2, standard: "jedec"});
|
||||
var i18n = {};
|
||||
|
||||
/**
|
||||
* get server info
|
||||
* @param lang {{}} language json
|
||||
* @param title page title
|
||||
*/
|
||||
function loadServerInfo(lang, title) {
|
||||
i18n = lang;
|
||||
$("#title").text(title);
|
||||
$('#content').empty();
|
||||
var loading = layui.layer.load();
|
||||
|
||||
$.getJSON('/proxy/api/serverinfo').done(function (result) {
|
||||
if (result.success) {
|
||||
var data = JSON.parse(result.data);
|
||||
data.proxyCounts = 0;
|
||||
httpPort = data.vhostHTTPPort;
|
||||
httpsPort = data.vhostHTTPSPort;
|
||||
for (var proxy in data.proxyTypeCount) {
|
||||
data.proxyCounts = data.proxyCounts + data.proxyTypeCount[proxy];
|
||||
}
|
||||
data.bindPort = data.bindPort || i18n['Disable'];
|
||||
data.kcpBindPort = data.kcpBindPort || i18n['Disable'];
|
||||
data.quicBindPort = data.quicBindPort || i18n['Disable'];
|
||||
data.vhostHTTPPort = data.vhostHTTPPort || i18n['Disable'];
|
||||
data.vhostHTTPSPort = data.vhostHTTPSPort || i18n['Disable'];
|
||||
data.tcpmuxHTTPConnectPort = data.tcpmuxHTTPConnectPort || i18n['Disable'];
|
||||
data.subdomainHost = data.subdomainHost || i18n['NotSet'];
|
||||
data.maxPoolCount = data.maxPoolCount || i18n['NotSet'];
|
||||
data.maxPortsPerClient = data.maxPortsPerClient || i18n['NotLimit'];
|
||||
data.heartbeatTimeout = data.heartbeatTimeout || i18n['NotSet'];
|
||||
data.allowPortsStr = data.allowPortsStr || i18n['NotLimit'];
|
||||
data.tlsForce = i18n[data.tlsForce || false];
|
||||
renderServerInfo(data);
|
||||
} else {
|
||||
layui.layer.msg(result.message);
|
||||
}
|
||||
}).always(function () {
|
||||
layui.layer.close(loading);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* render server info page
|
||||
* @param data server info data
|
||||
*/
|
||||
function renderServerInfo(data) {
|
||||
var html = layui.laytpl($('#serverInfoTemplate').html()).render(data);
|
||||
$('#content').html(html);
|
||||
$('#frpVersion').text(data.version);
|
||||
|
||||
renderTrafficChart(data);
|
||||
renderCountChart(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* render traffic chart with echarts
|
||||
* @param data traffic data
|
||||
*/
|
||||
function renderTrafficChart(data) {
|
||||
var chartLegend = [i18n['TrafficIn'], i18n['TrafficOut']];
|
||||
var chartData = [
|
||||
{value: data.totalTrafficIn, name: i18n['TrafficIn']},
|
||||
{value: data.totalTrafficOut, name: i18n['TrafficOut']}
|
||||
];
|
||||
var chartDom = document.getElementById('trafficPieChart');
|
||||
var chart = echarts.init(chartDom);
|
||||
var option = {
|
||||
title: {
|
||||
text: i18n['NetworkTraffic'],
|
||||
subtext: i18n['today'],
|
||||
left: 'center',
|
||||
textStyle: {
|
||||
textBorderColor: '#fff',
|
||||
textBorderWidth: 2
|
||||
},
|
||||
subtextStyle: {
|
||||
textBorderColor: '#fff',
|
||||
textBorderWidth: 2
|
||||
}
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
formatter: function (v) {
|
||||
return size(v.value) + ' (' + v.percent + '%)';
|
||||
},
|
||||
},
|
||||
legend: {
|
||||
orient: 'vertical',
|
||||
left: 'left',
|
||||
data: chartLegend,
|
||||
textStyle: {
|
||||
textBorderColor: '#fff',
|
||||
textBorderWidth: 2
|
||||
}
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: 'pie',
|
||||
radius: '55%',
|
||||
center: ['50%', '60%'],
|
||||
data: chartData,
|
||||
emphasis: {
|
||||
itemStyle: {
|
||||
shadowBlur: 10,
|
||||
shadowOffsetX: 0,
|
||||
shadowColor: 'rgba(0, 0, 0, 0.5)'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
option && chart.setOption(option);
|
||||
}
|
||||
|
||||
/**
|
||||
* render proxy count chat with echarts
|
||||
* @param data proxy count data
|
||||
*/
|
||||
function renderCountChart(data) {
|
||||
var proxies = data.proxyTypeCount;
|
||||
var chartLegend = [];
|
||||
var chartData = [];
|
||||
|
||||
for (var type in proxies) {
|
||||
var temp = {
|
||||
name: type.toUpperCase(),
|
||||
value: proxies[type]
|
||||
};
|
||||
chartLegend.push(type.toUpperCase());
|
||||
chartData.push(temp);
|
||||
}
|
||||
|
||||
var chartDom = document.getElementById('countPieChart');
|
||||
var chart = echarts.init(chartDom);
|
||||
var option = {
|
||||
title: {
|
||||
text: i18n['Proxy'],
|
||||
subtext: i18n['now'],
|
||||
left: 'center',
|
||||
textStyle: {
|
||||
textBorderColor: '#fff',
|
||||
textBorderWidth: 2
|
||||
},
|
||||
subtextStyle: {
|
||||
textBorderColor: '#fff',
|
||||
textBorderWidth: 2
|
||||
}
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
formatter: function (v) {
|
||||
return v.value + ' (' + v.percent + '%)';
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
orient: 'vertical',
|
||||
left: 'left',
|
||||
data: chartLegend,
|
||||
textStyle: {
|
||||
textBorderColor: '#fff',
|
||||
textBorderWidth: 2
|
||||
}
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: 'pie',
|
||||
radius: '55%',
|
||||
center: ['50%', '60%'],
|
||||
data: chartData,
|
||||
emphasis: {
|
||||
itemStyle: {
|
||||
shadowBlur: 10,
|
||||
shadowOffsetX: 0,
|
||||
shadowColor: 'rgba(0, 0, 0, 0.5)'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
option && chart.setOption(option);
|
||||
}
|
||||
|
||||
return loadServerInfo;
|
||||
})(layui.$);
|
||||
728
assets/static/js/index-user-list.js
Normal file
@@ -0,0 +1,728 @@
|
||||
var loadUserList = (function ($) {
|
||||
var i18n = {};
|
||||
var apiType = {
|
||||
Remove: 1,
|
||||
Enable: 2,
|
||||
Disable: 3
|
||||
};
|
||||
var verifyRules = {
|
||||
user: function (value, item) {
|
||||
var result = verifyUser(value);
|
||||
if (!result.valid) {
|
||||
return i18n['UserFormatError'];
|
||||
}
|
||||
if (item != null) {
|
||||
if (typeof item === "function") {
|
||||
item && item(result.trim);
|
||||
} else {
|
||||
$(item).val(result.trim);
|
||||
}
|
||||
}
|
||||
},
|
||||
token: function (value, item) {
|
||||
var result = verifyToken(value);
|
||||
if (!result.valid) {
|
||||
return i18n['TokenFormatError'];
|
||||
}
|
||||
if (item != null) {
|
||||
if (typeof item === "function") {
|
||||
item && item(result.trim);
|
||||
} else {
|
||||
$(item).val(result.trim);
|
||||
}
|
||||
}
|
||||
},
|
||||
comment: function (value, item) {
|
||||
var result = verifyComment(value);
|
||||
if (!result.valid) {
|
||||
return i18n['CommentInvalid'];
|
||||
}
|
||||
if (item != null) {
|
||||
if (typeof item === "function") {
|
||||
item && item(result.trim);
|
||||
} else {
|
||||
$(item).val(result.trim);
|
||||
}
|
||||
}
|
||||
},
|
||||
ports: function (value, item) {
|
||||
var result = verifyPorts(value);
|
||||
if (!result.valid) {
|
||||
return i18n['PortsInvalid'];
|
||||
}
|
||||
if (item != null) {
|
||||
if (typeof item === "function") {
|
||||
item && item(result.trim);
|
||||
} else {
|
||||
$(item).val(result.trim);
|
||||
}
|
||||
}
|
||||
},
|
||||
domains: function (value, item) {
|
||||
var result = verifyDomains(value);
|
||||
if (!result.valid) {
|
||||
return i18n['DomainsInvalid'];
|
||||
}
|
||||
if (item != null) {
|
||||
if (typeof item === "function") {
|
||||
item && item(result.trim);
|
||||
} else {
|
||||
$(item).val(result.trim);
|
||||
}
|
||||
}
|
||||
},
|
||||
subdomains: function (value, item) {
|
||||
var result = verifySubdomains(value);
|
||||
if (!result.valid) {
|
||||
return i18n['SubdomainsInvalid'];
|
||||
}
|
||||
if (item != null) {
|
||||
if (typeof item === "function") {
|
||||
item && item(result.trim);
|
||||
} else {
|
||||
$(item).val(result.trim);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* verify user value
|
||||
* @param username
|
||||
*/
|
||||
function verifyUser(username) {
|
||||
var valid = true;
|
||||
if (username.trim() === '' || !/^\w+$/.test(username)) {
|
||||
valid = false;
|
||||
}
|
||||
return {
|
||||
valid: valid,
|
||||
trim: username.trim()
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* verify token value
|
||||
* @param token
|
||||
*/
|
||||
function verifyToken(token) {
|
||||
var valid = true;
|
||||
if (token.trim() === '' || !/^[\w!@#$%^&*()]+$/.test(token)) {
|
||||
valid = false;
|
||||
}
|
||||
return {
|
||||
valid: valid,
|
||||
trim: token.trim()
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* verify comment is valid
|
||||
* @param comment
|
||||
*
|
||||
* @return {{valid:boolean, trim:string}}
|
||||
*/
|
||||
function verifyComment(comment) {
|
||||
var valid = true;
|
||||
if (comment.trim() !== '' && /[\n\t\r]/.test(comment)) {
|
||||
valid = false;
|
||||
}
|
||||
return {
|
||||
valid: valid,
|
||||
trim: comment.trim().replace(/[\n\t\r]/g, '')
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* verify ports is valid
|
||||
* @param ports
|
||||
*
|
||||
* @return {{valid:boolean, trim:string}}
|
||||
*/
|
||||
function verifyPorts(ports) {
|
||||
var valid = true;
|
||||
if (ports.trim() !== '') {
|
||||
try {
|
||||
ports.split(",").forEach(function (port) {
|
||||
if (/^\s*\d{1,5}\s*$/.test(port)) {
|
||||
if (parseInt(port) < 1 || parseInt(port) > 65535) {
|
||||
valid = false;
|
||||
}
|
||||
} else if (/^\s*\d{1,5}\s*-\s*\d{1,5}\s*$/.test(port)) {
|
||||
var portRange = port.split('-');
|
||||
if (parseInt(portRange[0]) < 1 || parseInt(portRange[0]) > 65535) {
|
||||
valid = false;
|
||||
} else if (parseInt(portRange[1]) < 1 || parseInt(portRange[1]) > 65535) {
|
||||
valid = false;
|
||||
} else if (parseInt(portRange[0]) > parseInt(portRange[1])) {
|
||||
valid = false;
|
||||
}
|
||||
} else {
|
||||
valid = false;
|
||||
}
|
||||
if (valid === false) {
|
||||
throw 'break';
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
return {
|
||||
valid: valid,
|
||||
trim: ports.replace(/\s/g, '')
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* verify domains is valid
|
||||
* @param domains
|
||||
*
|
||||
* @return {{valid:boolean, trim:string}}
|
||||
*/
|
||||
function verifyDomains(domains) {
|
||||
var valid = true;
|
||||
if (domains.trim() !== '') {
|
||||
try {
|
||||
domains.split(',').forEach(function (domain) {
|
||||
if (!/^([a-zA-Z0-9]+(-[a-zA-Z0-9]+)*\.)+[a-zA-Z]{2,}$/.test(domain.trim())) {
|
||||
valid = false;
|
||||
throw 'break';
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
return {
|
||||
valid: valid,
|
||||
trim: domains.replace(/\s/g, '')
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* verify subdomains is valid
|
||||
* @param subdomains
|
||||
*
|
||||
* @return {{valid:boolean, trim:string}}
|
||||
*/
|
||||
function verifySubdomains(subdomains) {
|
||||
var valid = true;
|
||||
if (subdomains.trim() !== '') {
|
||||
try {
|
||||
subdomains.split(',').forEach(function (subdomain) {
|
||||
if (!/^[a-zA-z0-9][a-zA-z0-9-]{0,19}$/.test(subdomain.trim())) {
|
||||
valid = false;
|
||||
throw 'break';
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
return {
|
||||
valid: valid,
|
||||
trim: subdomains.replace(/\s/g, '')
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* set verify rule of layui.form
|
||||
*/
|
||||
(function setFormVerifyRule() {
|
||||
layui.form.verify(verifyRules);
|
||||
})();
|
||||
|
||||
/**
|
||||
* load i18n language
|
||||
* @param lang {{}} language json
|
||||
* @param title page title
|
||||
*/
|
||||
function loadUserList(lang, title) {
|
||||
i18n = lang;
|
||||
$("#title").text(title);
|
||||
var html = layui.laytpl($('#userListTemplate').html()).render();
|
||||
$('#content').html(html);
|
||||
|
||||
var $section = $('#content > section');
|
||||
layui.table.render({
|
||||
elem: '#tokenTable',
|
||||
height: $section.height() - $('#searchForm').height() + 8,
|
||||
text: {none: i18n['EmptyData']},
|
||||
url: '/tokens',
|
||||
method: 'get',
|
||||
where: {},
|
||||
dataType: 'json',
|
||||
editTrigger: 'dblclick',
|
||||
page: pageOptions,
|
||||
toolbar: '#userListToolbarTemplate',
|
||||
defaultToolbar: false,
|
||||
cols: [[
|
||||
{type: 'checkbox'},
|
||||
{field: 'user', title: i18n['User'], width: 150, sort: true},
|
||||
{field: 'token', title: i18n['Token'], width: 200, sort: true, edit: true},
|
||||
{field: 'comment', title: i18n['Notes'], sort: true, edit: 'textarea'},
|
||||
{field: 'ports', title: i18n['AllowedPorts'], sort: true, edit: 'textarea'},
|
||||
{field: 'domains', title: i18n['AllowedDomains'], sort: true, edit: 'textarea'},
|
||||
{field: 'subdomains', title: i18n['AllowedSubdomains'], sort: true, edit: 'textarea'},
|
||||
{
|
||||
field: 'enable',
|
||||
title: i18n['Status'],
|
||||
width: 100,
|
||||
templet: '<span>{{d.enable? "' + i18n['Enable'] + '":"' + i18n['Disable'] + '"}}</span>',
|
||||
sort: true
|
||||
},
|
||||
{title: i18n['Operation'], width: 150, toolbar: '#userListOperationTemplate'}
|
||||
]],
|
||||
parseData: function (res) {
|
||||
res.data.forEach(function (data) {
|
||||
data.ports = data.ports.join(',');
|
||||
data.domains = data.domains.join(',');
|
||||
data.subdomains = data.subdomains.join(',');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
bindFormEvent();
|
||||
}
|
||||
|
||||
/**
|
||||
* bind event of {{@link layui.form}}
|
||||
*/
|
||||
function bindFormEvent() {
|
||||
layui.table.on('edit(tokenTable)', function (obj) {
|
||||
var field = obj.field;
|
||||
var value = obj.value;
|
||||
var oldValue = obj.oldValue;
|
||||
|
||||
var before = $.extend(true, {}, obj.data);
|
||||
var after = $.extend(true, {}, obj.data);
|
||||
var verifyMsg = false;
|
||||
if (field === 'token') {
|
||||
verifyMsg = verifyRules.token(value, function (trim) {
|
||||
updateTableField(obj, field, trim)
|
||||
});
|
||||
if (verifyMsg) {
|
||||
layui.layer.msg(verifyMsg);
|
||||
return obj.reedit();
|
||||
}
|
||||
|
||||
before.token = oldValue;
|
||||
after.token = value;
|
||||
} else if (field === 'comment') {
|
||||
verifyMsg = verifyRules.comment(value, function (trim) {
|
||||
updateTableField(obj, field, trim)
|
||||
});
|
||||
if (verifyMsg) {
|
||||
layui.layer.msg(verifyMsg);
|
||||
return obj.reedit();
|
||||
}
|
||||
|
||||
before.comment = oldValue;
|
||||
after.comment = value;
|
||||
} else if (field === 'ports') {
|
||||
verifyMsg = verifyRules.ports(value, function (trim) {
|
||||
updateTableField(obj, field, trim)
|
||||
});
|
||||
if (verifyMsg) {
|
||||
layui.layer.msg(verifyMsg);
|
||||
return obj.reedit();
|
||||
}
|
||||
|
||||
before.ports = oldValue;
|
||||
after.ports = value;
|
||||
} else if (field === 'domains') {
|
||||
verifyMsg = verifyRules.domains(value, function (trim) {
|
||||
updateTableField(obj, field, trim)
|
||||
});
|
||||
if (verifyMsg) {
|
||||
layui.layer.msg(verifyMsg);
|
||||
return obj.reedit();
|
||||
}
|
||||
|
||||
before.domains = oldValue;
|
||||
after.domains = value;
|
||||
} else if (field === 'subdomains') {
|
||||
verifyMsg = verifyRules.subdomains(value, function (trim) {
|
||||
updateTableField(obj, field, trim)
|
||||
});
|
||||
if (verifyMsg) {
|
||||
layui.layer.msg(verifyMsg);
|
||||
return obj.reedit();
|
||||
}
|
||||
|
||||
before.subdomains = oldValue;
|
||||
after.subdomains = value;
|
||||
}
|
||||
|
||||
before.ports = before.ports.split(',')
|
||||
before.domains = before.domains.split(',')
|
||||
before.subdomains = before.subdomains.split(',')
|
||||
after.ports = after.ports.split(',')
|
||||
after.domains = after.domains.split(',')
|
||||
after.subdomains = after.subdomains.split(',')
|
||||
|
||||
update(before, after);
|
||||
});
|
||||
|
||||
layui.table.on('toolbar(tokenTable)', function (obj) {
|
||||
var id = obj.config.id;
|
||||
var checkStatus = layui.table.checkStatus(id);
|
||||
var data = checkStatus.data;
|
||||
|
||||
data.forEach(function (temp) {
|
||||
temp.ports = temp.ports.split(',')
|
||||
temp.ports.forEach(function (port, index) {
|
||||
if (/^\d+$/.test(String(port))) {
|
||||
temp.ports[index] = parseInt(String(port));
|
||||
}
|
||||
});
|
||||
|
||||
temp.domains = temp.domains.split(',')
|
||||
temp.subdomains = temp.subdomains.split(',')
|
||||
});
|
||||
|
||||
switch (obj.event) {
|
||||
case 'add':
|
||||
addPopup();
|
||||
break
|
||||
case 'remove':
|
||||
batchRemovePopup(data);
|
||||
break
|
||||
case 'disable':
|
||||
batchDisablePopup(data);
|
||||
break
|
||||
case 'enable':
|
||||
batchEnablePopup(data);
|
||||
break
|
||||
}
|
||||
});
|
||||
|
||||
layui.table.on('tool(tokenTable)', function (obj) {
|
||||
var data = obj.data;
|
||||
|
||||
data.ports = data.ports.split(',')
|
||||
data.ports.forEach(function (port, index) {
|
||||
if (/^\d+$/.test(String(port))) {
|
||||
data.ports[index] = parseInt(String(port));
|
||||
}
|
||||
});
|
||||
data.domains = data.domains.split(',')
|
||||
data.subdomains = data.subdomains.split(',')
|
||||
switch (obj.event) {
|
||||
case 'remove':
|
||||
removePopup(data);
|
||||
break;
|
||||
case 'disable':
|
||||
disablePopup(data);
|
||||
break;
|
||||
case 'enable':
|
||||
enablePopup(data);
|
||||
break
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* update layui table data
|
||||
* @param obj table update obj
|
||||
* @param field update field
|
||||
* @param trim new value
|
||||
*/
|
||||
function updateTableField(obj, field, trim) {
|
||||
var newData = {};
|
||||
newData[field] = trim;
|
||||
obj.update(newData);
|
||||
}
|
||||
|
||||
/**
|
||||
* add user popup
|
||||
*/
|
||||
function addPopup() {
|
||||
layui.layer.open({
|
||||
type: 1,
|
||||
title: i18n['NewUser'],
|
||||
area: ['500px'],
|
||||
content: layui.laytpl(document.getElementById('addUserTemplate').innerHTML).render(),
|
||||
btn: [i18n['Confirm'], i18n['Cancel']],
|
||||
btn1: function (index) {
|
||||
if (layui.form.validate('#addUserForm')) {
|
||||
var formData = layui.form.val('addUserForm');
|
||||
if (formData.ports != null) {
|
||||
formData.ports = formData.ports.split(',')
|
||||
formData.ports.forEach(function (port, index) {
|
||||
if (/^\d+$/.test(String(port))) {
|
||||
formData.ports[index] = parseInt(String(port));
|
||||
}
|
||||
})
|
||||
}
|
||||
if (formData.domains != null) {
|
||||
formData.domains = formData.domains.split(',')
|
||||
}
|
||||
if (formData.subdomains != null) {
|
||||
formData.subdomains = formData.subdomains.split(',')
|
||||
}
|
||||
add(formData, index);
|
||||
}
|
||||
},
|
||||
btn2: function (index) {
|
||||
layui.layer.close(index);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* add user action
|
||||
* @param data {{user:string, token:string, comment:string, enable:boolean, ports:[string|number], domains:[string], subdomains:[string]}} user data
|
||||
* @param index popup index
|
||||
*/
|
||||
function add(data, index) {
|
||||
var loading = layui.layer.load();
|
||||
$.ajax({
|
||||
url: '/add',
|
||||
type: 'post',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify(data),
|
||||
success: function (result) {
|
||||
if (result.success) {
|
||||
reloadTable();
|
||||
layui.layer.close(index);
|
||||
layui.layer.msg(i18n['OperateSuccess'], function (index) {
|
||||
layui.layer.close(index);
|
||||
});
|
||||
} else {
|
||||
errorMsg(result);
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
layui.layer.close(loading);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* update user action
|
||||
* @param before {{user:string, token:string, comment:string, enable:boolean, ports:[string|number], domains:[string], subdomains:[string]}} data before update
|
||||
* @param after {{user:string, token:string, comment:string, enable:boolean, ports:[string|number], domains:[string], subdomains:[string]}} data after update
|
||||
*/
|
||||
function update(before, after) {
|
||||
before.ports.forEach(function (port, index) {
|
||||
if (/^\d+$/.test(String(port))) {
|
||||
before.ports[index] = parseInt(String(port));
|
||||
}
|
||||
});
|
||||
after.ports.forEach(function (port, index) {
|
||||
if (/^\d+$/.test(String(port)) && typeof port === "string") {
|
||||
after.ports[index] = parseInt(String(port));
|
||||
}
|
||||
});
|
||||
var loading = layui.layer.load();
|
||||
$.ajax({
|
||||
url: '/update',
|
||||
type: 'post',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({
|
||||
before: before,
|
||||
after: after,
|
||||
}),
|
||||
success: function (result) {
|
||||
if (result.success) {
|
||||
layui.layer.msg(i18n['OperateSuccess']);
|
||||
} else {
|
||||
errorMsg(result);
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
layui.layer.close(loading);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* batch remove user popup
|
||||
* @param data {[{user:string, token:string, comment:string, enable:boolean, ports:[string|number], domains:[string], subdomains:[string]}]} user data list
|
||||
*/
|
||||
function batchRemovePopup(data) {
|
||||
if (data.length === 0) {
|
||||
layui.layer.msg(i18n['ShouldCheckUser']);
|
||||
return;
|
||||
}
|
||||
layui.layer.confirm(i18n['ConfirmRemoveUser'], {
|
||||
title: i18n['OperationConfirm'],
|
||||
btn: [i18n['Confirm'], i18n['Cancel']]
|
||||
}, function (index) {
|
||||
operate(apiType.Remove, data, index);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* batch disable user popup
|
||||
* @param data {[{user:string, token:string, comment:string, enable:boolean, ports:[string|number], domains:[string], subdomains:[string]}]} user data list
|
||||
*/
|
||||
function batchDisablePopup(data) {
|
||||
if (data.length === 0) {
|
||||
layui.layer.msg(i18n['ShouldCheckUser']);
|
||||
return;
|
||||
}
|
||||
layui.layer.confirm(i18n['ConfirmDisableUser'], {
|
||||
title: i18n['OperationConfirm'],
|
||||
btn: [i18n['Confirm'], i18n['Cancel']]
|
||||
}, function (index) {
|
||||
operate(apiType.Disable, data, index);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* batch enable user popup
|
||||
* @param data {[{user:string, token:string, comment:string, enable:boolean, ports:[string|number], domains:[string], subdomains:[string]}]} user data list
|
||||
*/
|
||||
function batchEnablePopup(data) {
|
||||
if (data.length === 0) {
|
||||
layui.layer.msg(i18n['ShouldCheckUser']);
|
||||
return;
|
||||
}
|
||||
layui.layer.confirm(i18n['ConfirmEnableUser'], {
|
||||
title: i18n['OperationConfirm'],
|
||||
btn: [i18n['Confirm'], i18n['Cancel']]
|
||||
}, function (index) {
|
||||
operate(apiType.Enable, data, index);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* remove one user popup
|
||||
* @param data {{user:string, token:string, comment:string, enable:boolean, ports:[string|number], domains:[string], subdomains:[string]}} user data
|
||||
*/
|
||||
function removePopup(data) {
|
||||
layui.layer.confirm(i18n['ConfirmRemoveUser'], {
|
||||
title: i18n['OperationConfirm'],
|
||||
btn: [i18n['Confirm'], i18n['Cancel']]
|
||||
}, function (index) {
|
||||
operate(apiType.Remove, [data], index);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* disable one user popup
|
||||
* @param data {{user:string, token:string, comment:string, enable:boolean, ports:[string|number], domains:[string], subdomains:[string]}} user data
|
||||
*/
|
||||
function disablePopup(data) {
|
||||
layui.layer.confirm(i18n['ConfirmDisableUser'], {
|
||||
title: i18n['OperationConfirm'],
|
||||
btn: [i18n['Confirm'], i18n['Cancel']]
|
||||
}, function (index) {
|
||||
operate(apiType.Disable, [data], index);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* enable one user popup
|
||||
* @param data {{user:string, token:string, comment:string, enable:boolean, ports:[string|number], domains:[string], subdomains:[string]}} user data
|
||||
*/
|
||||
function enablePopup(data) {
|
||||
layui.layer.confirm(i18n['ConfirmEnableUser'], {
|
||||
title: i18n['OperationConfirm'],
|
||||
btn: [i18n['Confirm'], i18n['Cancel']]
|
||||
}, function (index) {
|
||||
operate(apiType.Enable, [data], index);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* operate actions
|
||||
* @param type {apiType} action type
|
||||
* @param data {[{user:string, token:string, comment:string, enable:boolean, ports:[string|number], domains:[string], subdomains:[string]}]} user data list
|
||||
* @param index popup index
|
||||
*/
|
||||
function operate(type, data, index) {
|
||||
var url;
|
||||
var extendMessage = '';
|
||||
if (type === apiType.Remove) {
|
||||
url = "/remove";
|
||||
extendMessage = ', ' + i18n['RemoveUser'] + i18n['TakeTimeMakeEffective'];
|
||||
} else if (type === apiType.Disable) {
|
||||
url = "/disable";
|
||||
extendMessage = ', ' + i18n['RemoveUser'] + i18n['TakeTimeMakeEffective'];
|
||||
} else if (type === apiType.Enable) {
|
||||
url = "/enable";
|
||||
} else {
|
||||
layer.layer.msg(i18n['OperateError']);
|
||||
return;
|
||||
}
|
||||
var loading = layui.layer.load();
|
||||
$.post({
|
||||
url: url,
|
||||
type: 'post',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({
|
||||
users: data
|
||||
}),
|
||||
success: function (result) {
|
||||
if (result.success) {
|
||||
reloadTable();
|
||||
layui.layer.close(index);
|
||||
layui.layer.msg(i18n['OperateSuccess'] + extendMessage, function (index) {
|
||||
layui.layer.close(index);
|
||||
});
|
||||
} else {
|
||||
errorMsg(result);
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
layui.layer.close(loading);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* reload user table
|
||||
*/
|
||||
function reloadTable() {
|
||||
var searchData = layui.form.val('searchForm');
|
||||
layui.table.reloadData('tokenTable', {
|
||||
where: searchData
|
||||
}, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* show error message popup
|
||||
* @param result
|
||||
*/
|
||||
function errorMsg(result) {
|
||||
var reason = i18n['OtherError'];
|
||||
if (result.code === 1)
|
||||
reason = i18n['ParamError'];
|
||||
else if (result.code === 2)
|
||||
reason = i18n['UserExist'];
|
||||
else if (result.code === 3)
|
||||
reason = i18n['UserNotExist'];
|
||||
else if (result.code === 4)
|
||||
reason = i18n['ParamError'];
|
||||
else if (result.code === 5)
|
||||
reason = i18n['UserFormatError'];
|
||||
else if (result.code === 6)
|
||||
reason = i18n['TokenFormatError'];
|
||||
else if (result.code === 7)
|
||||
reason = i18n['CommentInvalid'];
|
||||
else if (result.code === 8)
|
||||
reason = i18n['PortsInvalid'];
|
||||
else if (result.code === 9)
|
||||
reason = i18n['DomainsInvalid'];
|
||||
else if (result.code === 10)
|
||||
reason = i18n['SubdomainsInvalid'];
|
||||
layui.layer.msg(i18n['OperateFailed'] + ',' + reason)
|
||||
}
|
||||
|
||||
/**
|
||||
* document event
|
||||
*/
|
||||
(function bindDocumentEvent() {
|
||||
$(document).on('click.search', '#searchBtn', function () {
|
||||
reloadTable();
|
||||
return false;
|
||||
}).on('click.reset', '#resetBtn', function () {
|
||||
$('#searchForm')[0].reset();
|
||||
reloadTable();
|
||||
return false;
|
||||
});
|
||||
})();
|
||||
|
||||
return loadUserList;
|
||||
})(layui.$)
|
||||
@@ -1,640 +1,58 @@
|
||||
var $ = layui.$;
|
||||
var httpPort, httpsPort, pageOptions;
|
||||
(function ($) {
|
||||
$(function () {
|
||||
var apiType = {
|
||||
Remove: 1,
|
||||
Enable: 2,
|
||||
Disable: 3
|
||||
}
|
||||
|
||||
/**
|
||||
* verify user value
|
||||
* @param username
|
||||
*/
|
||||
function verifyUser(username) {
|
||||
var valid = true;
|
||||
if (username.trim() === '' || !/^\w+$/.test(username)) {
|
||||
valid = false;
|
||||
}
|
||||
return {
|
||||
valid: valid,
|
||||
trim: username
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* verify token value
|
||||
* @param token
|
||||
*/
|
||||
function verifyToken(token) {
|
||||
var valid = true;
|
||||
if (token.trim() === '' || !/^[\w!@#$%^&*()]+$/.test(token)) {
|
||||
valid = false;
|
||||
}
|
||||
return {
|
||||
valid: valid,
|
||||
trim: token.trim()
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* verify comment is valid
|
||||
* @param comment
|
||||
*
|
||||
* @return {{valid:boolean, trim:string}}
|
||||
*/
|
||||
function verifyComment(comment) {
|
||||
var valid = true;
|
||||
if (comment.trim() !== '' && /[\n\t\r]/.test(comment)) {
|
||||
valid = false;
|
||||
}
|
||||
return {
|
||||
valid: valid,
|
||||
trim: comment.replace(/[\n\t\r]/g, '')
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* verify ports is valid
|
||||
* @param ports
|
||||
*
|
||||
* @return {{valid:boolean, trim:string}}
|
||||
*/
|
||||
function verifyPorts(ports) {
|
||||
var valid = true;
|
||||
if (ports.trim() !== '') {
|
||||
try {
|
||||
ports.split(",").forEach(function (port) {
|
||||
if (/^\s*\d{1,5}\s*$/.test(port)) {
|
||||
if (parseInt(port) < 1 || parseInt(port) > 65535) {
|
||||
valid = false;
|
||||
}
|
||||
} else if (/^\s*\d{1,5}\s*-\s*\d{1,5}\s*$/.test(port)) {
|
||||
var portRange = port.split('-');
|
||||
if (parseInt(portRange[0]) < 1 || parseInt(portRange[0]) > 65535) {
|
||||
valid = false;
|
||||
} else if (parseInt(portRange[1]) < 1 || parseInt(portRange[1]) > 65535) {
|
||||
valid = false;
|
||||
} else if (parseInt(portRange[0]) > parseInt(portRange[1])) {
|
||||
valid = false;
|
||||
}
|
||||
} else {
|
||||
valid = false;
|
||||
}
|
||||
if (valid === false) {
|
||||
throw 'break';
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
return {
|
||||
valid: valid,
|
||||
trim: ports.replace(/\s/g, '')
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* verify domains is valid
|
||||
* @param domains
|
||||
*
|
||||
* @return {{valid:boolean, trim:string}}
|
||||
*/
|
||||
function verifyDomains(domains) {
|
||||
var valid = true;
|
||||
if (domains.trim() !== '') {
|
||||
try {
|
||||
domains.split(',').forEach(function (domain) {
|
||||
if (!/^(?=^.{3,255}$)[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62}){1,3}$/.test(domain.trim())) {
|
||||
valid = false;
|
||||
throw 'break';
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
return {
|
||||
valid: valid,
|
||||
trim: domains.replace(/\s/g, '')
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* verify subdomains is valid
|
||||
* @param subdomains
|
||||
*
|
||||
* @return {{valid:boolean, trim:string}}
|
||||
*/
|
||||
function verifySubdomains(subdomains) {
|
||||
var valid = true;
|
||||
if (subdomains.trim() !== '') {
|
||||
try {
|
||||
subdomains.split(',').forEach(function (subdomain) {
|
||||
if (!/^[a-zA-z0-9][a-zA-Z0-9-]{0,19}$/.test(subdomain.trim())) {
|
||||
valid = false;
|
||||
throw 'break';
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
return {
|
||||
valid: valid,
|
||||
trim: subdomains.replace(/\s/g, '')
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* load i18n language
|
||||
* @param lang {{}}
|
||||
*/
|
||||
function langLoaded(lang) {
|
||||
//set verify rules
|
||||
var verifyRules = {
|
||||
user: function (value, item) {
|
||||
var result = verifyUser(value);
|
||||
if (!result.valid) {
|
||||
return lang['UserFormatError'];
|
||||
}
|
||||
if (item != null) {
|
||||
if (typeof item === "function") {
|
||||
item && item(result.trim);
|
||||
} else {
|
||||
$(item).val(result.trim);
|
||||
}
|
||||
}
|
||||
},
|
||||
token: function (value, item) {
|
||||
var result = verifyToken(value);
|
||||
if (!result.valid) {
|
||||
return lang['TokenFormatError'];
|
||||
}
|
||||
if (item != null) {
|
||||
if (typeof item === "function") {
|
||||
item && item(result.trim);
|
||||
} else {
|
||||
$(item).val(result.trim);
|
||||
}
|
||||
}
|
||||
},
|
||||
comment: function (value, item) {
|
||||
var result = verifyComment(value);
|
||||
if (!result.valid) {
|
||||
return lang['CommentInvalid'];
|
||||
}
|
||||
if (item != null) {
|
||||
if (typeof item === "function") {
|
||||
item && item(result.trim);
|
||||
} else {
|
||||
$(item).val(result.trim);
|
||||
}
|
||||
}
|
||||
},
|
||||
ports: function (value, item) {
|
||||
var result = verifyPorts(value);
|
||||
if (!result.valid) {
|
||||
return lang['PortsInvalid'];
|
||||
}
|
||||
if (item != null) {
|
||||
if (typeof item === "function") {
|
||||
item && item(result.trim);
|
||||
} else {
|
||||
$(item).val(result.trim);
|
||||
}
|
||||
}
|
||||
},
|
||||
domains: function (value, item) {
|
||||
var result = verifyDomains(value);
|
||||
if (!result.valid) {
|
||||
return lang['DomainsInvalid'];
|
||||
}
|
||||
if (item != null) {
|
||||
if (typeof item === "function") {
|
||||
item && item(result.trim);
|
||||
} else {
|
||||
$(item).val(result.trim);
|
||||
}
|
||||
}
|
||||
},
|
||||
subdomains: function (value, item) {
|
||||
var result = verifySubdomains(value);
|
||||
if (!result.valid) {
|
||||
return lang['SubdomainsInvalid'];
|
||||
}
|
||||
if (item != null) {
|
||||
if (typeof item === "function") {
|
||||
item && item(result.trim);
|
||||
} else {
|
||||
$(item).val(result.trim);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
layui.form.set({
|
||||
verIncludeRequired: true,
|
||||
verify: verifyRules
|
||||
});
|
||||
|
||||
layui.table.render({
|
||||
elem: '#tokenTable',
|
||||
url: '/tokens',
|
||||
method: 'get',
|
||||
where: {},
|
||||
dataType: 'json',
|
||||
editTrigger: 'dblclick',
|
||||
page: navigator.language.indexOf("zh") === 0,
|
||||
toolbar: '#toolbarTemplate',
|
||||
defaultToolbar: false,
|
||||
text: {none: lang['EmptyData']},
|
||||
cols: [[
|
||||
{type: 'checkbox'},
|
||||
{field: 'user', title: lang['User'], width: 150, sort: true},
|
||||
{field: 'token', title: lang['Token'], width: 200, sort: true, edit: true},
|
||||
{field: 'comment', title: lang['Notes'], sort: true, edit: 'textarea'},
|
||||
{field: 'ports', title: lang['AllowedPorts'], sort: true, edit: 'textarea'},
|
||||
{field: 'domains', title: lang['AllowedDomains'], sort: true, edit: 'textarea'},
|
||||
{field: 'subdomains', title: lang['AllowedSubdomains'], sort: true, edit: 'textarea'},
|
||||
{
|
||||
field: 'status',
|
||||
title: lang['Status'],
|
||||
width: 100,
|
||||
templet: '<span>{{d.status? "' + lang['Enable'] + '":"' + lang['Disable'] + '"}}</span>',
|
||||
sort: true
|
||||
},
|
||||
{title: lang['Operation'], width: 150, toolbar: '#operationTemplate'}
|
||||
]]
|
||||
});
|
||||
|
||||
/**
|
||||
* update layui table data
|
||||
* @param obj table update obj
|
||||
* @param field update field
|
||||
* @param trim new value
|
||||
*/
|
||||
function updateTableField(obj, field, trim) {
|
||||
var newData = {};
|
||||
newData[field] = trim;
|
||||
obj.update(newData);
|
||||
}
|
||||
|
||||
layui.table.on('edit(tokenTable)', function (obj) {
|
||||
var field = obj.field;
|
||||
var value = obj.value;
|
||||
var oldValue = obj.oldValue;
|
||||
var before = $.extend(true, {}, obj.data);
|
||||
var after = $.extend(true, {}, obj.data);
|
||||
var verifyMsg = false;
|
||||
if (field === 'token') {
|
||||
verifyMsg = verifyRules.token(value, function (trim) {
|
||||
updateTableField(obj, field, trim)
|
||||
});
|
||||
if (verifyMsg) {
|
||||
layui.layer.msg(verifyMsg);
|
||||
return obj.reedit();
|
||||
}
|
||||
|
||||
before.token = oldValue;
|
||||
after.token = value;
|
||||
} else if (field === 'comment') {
|
||||
verifyMsg = verifyRules.comment(value, function (trim) {
|
||||
updateTableField(obj, field, trim)
|
||||
});
|
||||
if (verifyMsg) {
|
||||
layui.layer.msg(verifyMsg);
|
||||
return obj.reedit();
|
||||
}
|
||||
|
||||
before.comment = oldValue;
|
||||
after.comment = value;
|
||||
} else if (field === 'ports') {
|
||||
verifyMsg = verifyRules.ports(value, function (trim) {
|
||||
updateTableField(obj, field, trim)
|
||||
});
|
||||
if (verifyMsg) {
|
||||
layui.layer.msg(verifyMsg);
|
||||
return obj.reedit();
|
||||
}
|
||||
|
||||
before.ports = oldValue;
|
||||
after.ports = value;
|
||||
} else if (field === 'domains') {
|
||||
verifyMsg = verifyRules.domains(value, function (trim) {
|
||||
updateTableField(obj, field, trim)
|
||||
});
|
||||
if (verifyMsg) {
|
||||
layui.layer.msg(verifyMsg);
|
||||
return obj.reedit();
|
||||
}
|
||||
|
||||
before.domains = oldValue;
|
||||
after.domains = value;
|
||||
} else if (field === 'subdomains') {
|
||||
verifyMsg = verifyRules.subdomains(value, function (trim) {
|
||||
updateTableField(obj, field, trim)
|
||||
});
|
||||
if (verifyMsg) {
|
||||
layui.layer.msg(verifyMsg);
|
||||
return obj.reedit();
|
||||
}
|
||||
|
||||
before.subdomains = oldValue;
|
||||
after.subdomains = value;
|
||||
}
|
||||
|
||||
update(before, after);
|
||||
});
|
||||
|
||||
layui.table.on('toolbar(tokenTable)', function (obj) {
|
||||
var id = obj.config.id;
|
||||
var checkStatus = layui.table.checkStatus(id);
|
||||
switch (obj.event) {
|
||||
case 'add':
|
||||
addPopup();
|
||||
break
|
||||
case 'remove':
|
||||
batchRemovePopup(checkStatus.data);
|
||||
break
|
||||
case 'disable':
|
||||
batchDisablePopup(checkStatus.data);
|
||||
break
|
||||
case 'enable':
|
||||
batchEnablePopup(checkStatus.data);
|
||||
break
|
||||
}
|
||||
});
|
||||
layui.table.on('tool(tokenTable)', function (obj) {
|
||||
var data = obj.data;
|
||||
switch (obj.event) {
|
||||
case 'remove':
|
||||
removePopup(data);
|
||||
break;
|
||||
case 'disable':
|
||||
disablePopup(data);
|
||||
break;
|
||||
case 'enable':
|
||||
enablePopup(data);
|
||||
break
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* add user popup
|
||||
*/
|
||||
function addPopup() {
|
||||
layui.layer.open({
|
||||
type: 1,
|
||||
title: lang['NewUser'],
|
||||
area: ['500px'],
|
||||
content: layui.laytpl(document.getElementById('addTemplate').innerHTML).render(),
|
||||
btn: [lang['Confirm'], lang['Cancel']],
|
||||
btn1: function (index) {
|
||||
if (layui.form.validate('#addUserForm')) {
|
||||
add(layui.form.val('addUserForm'), index);
|
||||
}
|
||||
},
|
||||
btn2: function (index) {
|
||||
layui.layer.close(index);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* add user action
|
||||
* @param data {{user:string, token:string, comment:string, status:boolean, ports:string, domains:string, subdomains:string}} user data
|
||||
* @param index popup index
|
||||
*/
|
||||
function add(data, index) {
|
||||
var loading = layui.layer.load();
|
||||
$.ajax({
|
||||
url: '/add',
|
||||
type: 'post',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify(data),
|
||||
success: function (result) {
|
||||
if (result.success) {
|
||||
reloadTable();
|
||||
layui.layer.close(index);
|
||||
layui.layer.msg(lang['OperateSuccess'], function (index) {
|
||||
layui.layer.close(index);
|
||||
});
|
||||
} else {
|
||||
errorMsg(result);
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
layui.layer.close(loading);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* update user action
|
||||
* @param before {{user:string, token:string, comment:string, status:boolean, ports:string, domains:string, subdomains:string}} data before update
|
||||
* @param after {{user:string, token:string, comment:string, status:boolean, ports:string, domains:string, subdomains:string}} data after update
|
||||
*/
|
||||
function update(before, after) {
|
||||
var loading = layui.layer.load();
|
||||
$.ajax({
|
||||
url: '/update',
|
||||
type: 'post',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({
|
||||
before: before,
|
||||
after: after,
|
||||
}),
|
||||
success: function (result) {
|
||||
if (result.success) {
|
||||
layui.layer.msg(lang['OperateSuccess']);
|
||||
} else {
|
||||
errorMsg(result);
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
layui.layer.close(loading);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* batch remove user popup
|
||||
* @param data {[{user:string, token:string, comment:string, status:boolean, ports:string, domains:string, subdomains:string}]} user data list
|
||||
*/
|
||||
function batchRemovePopup(data) {
|
||||
if (data.length === 0) {
|
||||
layui.layer.msg(lang['ShouldCheckUser']);
|
||||
return;
|
||||
}
|
||||
layui.layer.confirm(lang['ConfirmRemoveUser'], {
|
||||
title: lang['OperationConfirm'],
|
||||
btn: [lang['Confirm'], lang['Cancel']]
|
||||
}, function (index) {
|
||||
operate(apiType.Remove, data, index);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* batch disable user popup
|
||||
* @param data {[{user:string, token:string, comment:string, status:boolean, ports:string, domains:string, subdomains:string}]} user data list
|
||||
*/
|
||||
function batchDisablePopup(data) {
|
||||
if (data.length === 0) {
|
||||
layui.layer.msg(lang['ShouldCheckUser']);
|
||||
return;
|
||||
}
|
||||
layui.layer.confirm(lang['ConfirmDisableUser'], {
|
||||
title: lang['OperationConfirm'],
|
||||
btn: [lang['Confirm'], lang['Cancel']]
|
||||
}, function (index) {
|
||||
operate(apiType.Disable, data, index);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* batch enable user popup
|
||||
* @param data {[{user:string, token:string, comment:string, status:boolean, ports:string, domains:string, subdomains:string}]} user data list
|
||||
*/
|
||||
function batchEnablePopup(data) {
|
||||
if (data.length === 0) {
|
||||
layui.layer.msg(lang['ShouldCheckUser']);
|
||||
return;
|
||||
}
|
||||
layui.layer.confirm(lang['ConfirmEnableUser'], {
|
||||
title: lang['OperationConfirm'],
|
||||
btn: [lang['Confirm'], lang['Cancel']]
|
||||
}, function (index) {
|
||||
operate(apiType.Enable, data, index);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* remove one user popup
|
||||
* @param data {{user:string, token:string, comment:string, status:boolean, ports:string, domains:string, subdomains:string}} user data
|
||||
*/
|
||||
function removePopup(data) {
|
||||
layui.layer.confirm(lang['ConfirmRemoveUser'], {
|
||||
title: lang['OperationConfirm'],
|
||||
btn: [lang['Confirm'], lang['Cancel']]
|
||||
}, function (index) {
|
||||
operate(apiType.Remove, [data], index);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* disable one user popup
|
||||
* @param data {{user:string, token:string, comment:string, status:boolean, ports:string, domains:string, subdomains:string}} user data
|
||||
*/
|
||||
function disablePopup(data) {
|
||||
layui.layer.confirm(lang['ConfirmDisableUser'], {
|
||||
title: lang['OperationConfirm'],
|
||||
btn: [lang['Confirm'], lang['Cancel']]
|
||||
}, function (index) {
|
||||
operate(apiType.Disable, [data], index);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* enable one user popup
|
||||
* @param data {{user:string, token:string, comment:string, status:boolean, ports:string, domains:string, subdomains:string}} user data
|
||||
*/
|
||||
function enablePopup(data) {
|
||||
layui.layer.confirm(lang['ConfirmEnableUser'], {
|
||||
title: lang['OperationConfirm'],
|
||||
btn: [lang['Confirm'], lang['Cancel']]
|
||||
}, function (index) {
|
||||
operate(apiType.Enable, [data], index);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* operate actions
|
||||
* @param type {apiType} action type
|
||||
* @param data {[{user:string, token:string, comment:string, status:boolean, ports:string, domains:string, subdomains:string}]} user data list
|
||||
* @param index popup index
|
||||
*/
|
||||
function operate(type, data, index) {
|
||||
var url;
|
||||
var extendMessage = '';
|
||||
if (type === apiType.Remove) {
|
||||
url = "/remove";
|
||||
extendMessage = ', ' + lang['RemoveUser'] + lang['TakeTimeMakeEffective'];
|
||||
} else if (type === apiType.Disable) {
|
||||
url = "/disable";
|
||||
extendMessage = ', ' + lang['RemoveUser'] + lang['TakeTimeMakeEffective'];
|
||||
} else if (type === apiType.Enable) {
|
||||
url = "/enable";
|
||||
} else {
|
||||
layer.layer.msg(lang['OperateError']);
|
||||
return;
|
||||
}
|
||||
var loading = layui.layer.load();
|
||||
$.post({
|
||||
url: url,
|
||||
type: 'post',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({
|
||||
users: data
|
||||
}),
|
||||
success: function (result) {
|
||||
if (result.success) {
|
||||
reloadTable();
|
||||
layui.layer.close(index);
|
||||
layui.layer.msg(lang['OperateSuccess'] + extendMessage, function (index) {
|
||||
layui.layer.close(index);
|
||||
});
|
||||
} else {
|
||||
errorMsg(result);
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
layui.layer.close(loading);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* reload user table
|
||||
*/
|
||||
function reloadTable() {
|
||||
var searchData = layui.form.val('searchForm');
|
||||
layui.table.reloadData('tokenTable', {
|
||||
where: searchData
|
||||
}, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* show error message popup
|
||||
* @param result
|
||||
*/
|
||||
function errorMsg(result) {
|
||||
var reason = lang['Other Error'];
|
||||
if (result.code === 1)
|
||||
reason = lang['ParamError'];
|
||||
else if (result.code === 2)
|
||||
reason = lang['UserExist'];
|
||||
else if (result.code === 3)
|
||||
reason = lang['ParamError'];
|
||||
else if (result.code === 4)
|
||||
reason = lang['UserFormatError'];
|
||||
else if (result.code === 5)
|
||||
reason = lang['TokenFormatError'];
|
||||
layui.layer.msg(lang['OperateFailed'] + ',' + reason)
|
||||
}
|
||||
|
||||
/**
|
||||
* click event
|
||||
*/
|
||||
$(document).on('click.search', '#searchBtn', function () {
|
||||
reloadTable();
|
||||
return false;
|
||||
}).on('click.reset', '#resetBtn', function () {
|
||||
$('#searchForm')[0].reset();
|
||||
reloadTable();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
function init() {
|
||||
var langLoading = layui.layer.load()
|
||||
$.getJSON('/lang').done(langLoaded).always(function () {
|
||||
$.getJSON('/lang.json').done(function (lang) {
|
||||
pageOptions = {
|
||||
limitTemplet: function (item) {
|
||||
return item + lang['PerPage'];
|
||||
},
|
||||
skipText: [lang['Goto'], '', lang['Confirm']],
|
||||
countText: [lang['Total'], lang['Items']]
|
||||
};
|
||||
|
||||
$.ajaxSetup({
|
||||
error: function (xhr,) {
|
||||
if (xhr.status === 401) {
|
||||
layui.layer.msg(lang['TokenInvalid'], function () {
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
layui.element.on('nav(leftNav)', function (elem) {
|
||||
var id = elem.attr('id');
|
||||
var title = elem.text();
|
||||
if (id === 'serverInfo') {
|
||||
loadServerInfo(lang, title.trim());
|
||||
} else if (id === 'userList') {
|
||||
loadUserList(lang, title.trim());
|
||||
} else if (elem.closest('.layui-nav-item').attr('id') === 'proxyList') {
|
||||
if (id != null && id.trim() !== '') {
|
||||
var suffix = elem.closest('.layui-nav-item').children('a').text().trim();
|
||||
loadProxyInfo(lang, title + " " + suffix, id);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('#leftNav .layui-this > a').click();
|
||||
}).always(function () {
|
||||
layui.layer.close(langLoading);
|
||||
});
|
||||
}
|
||||
|
||||
function logout() {
|
||||
$.get("/logout", function (result) {
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
|
||||
$(document).on('click.logout', '#logout', function () {
|
||||
logout();
|
||||
});
|
||||
|
||||
init();
|
||||
});
|
||||
})(layui.$);
|
||||
33
assets/static/js/login.js
Normal file
@@ -0,0 +1,33 @@
|
||||
(function ($) {
|
||||
$(function () {
|
||||
function login() {
|
||||
if (!layui.form.validate('#loginForm')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: "/login",
|
||||
type: 'post',
|
||||
data: {
|
||||
username: $('#username').val(),
|
||||
password: $('#password').val()
|
||||
},
|
||||
success: function (result) {
|
||||
if (result.success) {
|
||||
window.location.reload();
|
||||
} else {
|
||||
layui.layer.msg(result.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(document).on('click.login', '#login', function () {
|
||||
login();
|
||||
}).on('keydown', function (e) {
|
||||
if (e.keyCode === 13) {
|
||||
login();
|
||||
}
|
||||
});
|
||||
})
|
||||
})(layui.$)
|
||||
45
assets/static/lib/echarts.min.js
vendored
Normal file
6
assets/static/lib/filesize.min.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/*!
|
||||
2022 Jason Mulligan <jason.mulligan@avoidwork.com>
|
||||
@version 9.0.11
|
||||
*/
|
||||
!function(i,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(i="undefined"!=typeof globalThis?globalThis:i||self).filesize=t()}(this,(function(){"use strict";function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(i){return typeof i}:function(i){return i&&"function"==typeof Symbol&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},i(t)}var t="array",o="bits",e="byte",n="bytes",r="",b="exponent",l="function",a="iec",d="Invalid number",f="Invalid rounding method",u="jedec",s="object",c=".",p="round",y="kbit",m="string",v={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function g(g){var h=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},B=h.bits,M=void 0!==B&&B,S=h.pad,T=void 0!==S&&S,w=h.base,x=void 0===w?-1:w,E=h.round,j=void 0===E?2:E,N=h.locale,P=void 0===N?r:N,k=h.localeOptions,G=void 0===k?{}:k,K=h.separator,Y=void 0===K?r:K,Z=h.spacer,z=void 0===Z?" ":Z,I=h.symbols,L=void 0===I?{}:I,O=h.standard,q=void 0===O?r:O,A=h.output,C=void 0===A?m:A,D=h.fullform,F=void 0!==D&&D,H=h.fullforms,J=void 0===H?[]:H,Q=h.exponent,R=void 0===Q?-1:Q,U=h.roundingMethod,V=void 0===U?p:U,W=h.precision,X=void 0===W?0:W,$=R,_=Number(g),ii=[],ti=0,oi=r;-1===x&&0===q.length?(x=10,q=u):-1===x&&q.length>0?x=(q=q===a?a:u)===a?2:10:q=10===(x=2===x?2:10)||q===u?u:a;var ei=10===x?1e3:1024,ni=!0===F,ri=_<0,bi=Math[V];if(isNaN(g))throw new TypeError(d);if(i(bi)!==l)throw new TypeError(f);if(ri&&(_=-_),(-1===$||isNaN($))&&($=Math.floor(Math.log(_)/Math.log(ei)))<0&&($=0),$>8&&(X>0&&(X+=8-$),$=8),C===b)return $;if(0===_)ii[0]=0,oi=ii[1]=v.symbol[q][M?o:n][$];else{ti=_/(2===x?Math.pow(2,10*$):Math.pow(1e3,$)),M&&(ti*=8)>=ei&&$<8&&(ti/=ei,$++);var li=Math.pow(10,$>0?j:0);ii[0]=bi(ti*li)/li,ii[0]===ei&&$<8&&-1===R&&(ii[0]=1,$++),oi=ii[1]=10===x&&1===$?M?y:"kB":v.symbol[q][M?o:n][$]}if(ri&&(ii[0]=-ii[0]),X>0&&(ii[0]=ii[0].toPrecision(X)),ii[1]=L[ii[1]]||ii[1],!0===P?ii[0]=ii[0].toLocaleString():P.length>0?ii[0]=ii[0].toLocaleString(P,G):Y.length>0&&(ii[0]=ii[0].toString().replace(c,Y)),T&&!1===Number.isInteger(ii[0])&&j>0){var ai=Y||c,di=ii[0].toString().split(ai),fi=di[1]||r,ui=fi.length,si=j-ui;ii[0]="".concat(di[0]).concat(ai).concat(fi.padEnd(ui+si,"0"))}return ni&&(ii[1]=J[$]?J[$]:v.fullform[q][$]+(M?"bit":e)+(1===ii[0]?r:"s")),C===t?ii:C===s?{value:ii[0],symbol:ii[1],exponent:$,unit:oi}:ii.join(z)}return g.partial=function(i){return function(t){return g(t,i)}},g}));
|
||||
//# sourceMappingURL=filesize.min.js.map
|
||||
1
assets/static/lib/layui/css/layui.css
Normal file
|
Before Width: | Height: | Size: 322 KiB After Width: | Height: | Size: 322 KiB |
1
assets/static/lib/layui/layui.js
Normal file
@@ -1,14 +1,20 @@
|
||||
<!--suppress HtmlFormInputWithoutLabel -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>${ .UserManage }</title>
|
||||
<link rel="stylesheet" href="./static/layui/css/layui.css">
|
||||
<link rel="stylesheet" href="./static/css/layui-theme-dark.css">
|
||||
<link rel="stylesheet" href="./static/css/index.css">
|
||||
<script src="./static/layui/layui.js"></script>
|
||||
<script src="./static/js/index.js"></script>
|
||||
<title>${ .FrpsPanel }</title>
|
||||
<link rel="stylesheet" href="./static/lib/layui/css/layui.css?v=${ .version }">
|
||||
<link rel="stylesheet" href="./static/css/layui-theme-dark.css?v=${ .version }">
|
||||
<link rel="stylesheet" href="./static/css/index.css?v=${ .version }">
|
||||
<link rel="stylesheet" href="./static/css/color.css?v=${ .version }">
|
||||
<script src="./static/lib/layui/layui.js?v=${ .version }"></script>
|
||||
<script src="./static/lib/echarts.min.js?v=${ .version }"></script>
|
||||
<script src="./static/lib/filesize.min.js?v=${ .version }"></script>
|
||||
<script src="./static/js/index-server-info.js?v=${ .version }"></script>
|
||||
<script src="./static/js/index-user-list.js?v=${ .version }"></script>
|
||||
<script src="./static/js/index-proxy-list.js?v=${ .version }"></script>
|
||||
<script src="./static/js/index.js?v=${ .version }"></script>
|
||||
<style>
|
||||
.layui-table-cell:empty::after {
|
||||
section.user-list .layui-table-cell:empty::after {
|
||||
content: '${ .NotLimit }';
|
||||
}
|
||||
|
||||
@@ -18,6 +24,142 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-layout layui-layout-admin">
|
||||
<div class="layui-header layui-bg-blue">
|
||||
<div class="layui-logo layui-bg-black">${ .FrpsPanel }</div>
|
||||
<div class="layui-title">
|
||||
<span id="title"></span>
|
||||
${ if .showExit }
|
||||
<span class="layui-icon layui-icon-logout" id="logout"></span>
|
||||
${ end }
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-side layui-bg-black">
|
||||
<div class="layui-side-scroll">
|
||||
<ul class="layui-nav layui-nav-tree" lay-filter="leftNav" id="leftNav">
|
||||
<li class="layui-nav-item layui-this">
|
||||
<a href="javascript:void(0)" id="serverInfo">${ .ServerInfo }</a>
|
||||
</li>
|
||||
<li class="layui-nav-item">
|
||||
<a href="javascript:void(0)" id="userList">${ .Users }</a>
|
||||
</li>
|
||||
<li class="layui-nav-item layui-nav-itemed" id="proxyList">
|
||||
<a class="" href="javascript:void(0)">${ .Proxies }</a>
|
||||
<dl class="layui-nav-child">
|
||||
<dd>
|
||||
<a href="javascript:void(0)" id="tcp">TCP</a>
|
||||
</dd>
|
||||
<dd>
|
||||
<a href="javascript:void(0)" id="udp">UDP</a>
|
||||
</dd>
|
||||
<dd>
|
||||
<a href="javascript:void(0)" id="http">HTTP</a>
|
||||
</dd>
|
||||
<dd>
|
||||
<a href="javascript:void(0)" id="https">HTTPS</a>
|
||||
</dd>
|
||||
<dd>
|
||||
<a href="javascript:void(0)" id="stcp">STCP</a>
|
||||
</dd>
|
||||
<dd>
|
||||
<a href="javascript:void(0)" id="sudp">SUDP</a>
|
||||
</dd>
|
||||
</dl>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="version">
|
||||
<a href="https://github.com/fatedier/frp" target="_blank">Frp <span id="frpVersion"></span></a>
|
||||
<span> | </span>
|
||||
<a href="https://github.com/yhl452493373/frps-panel" target="_blank">${ .FrpsPanel } ${ .version }</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-body" id="content"></div>
|
||||
</div>
|
||||
|
||||
<!--服务器信息模板-->
|
||||
<script type="text/html" id="serverInfoTemplate">
|
||||
<section class="server-info">
|
||||
<div class="text-info">
|
||||
<div class="text-row">
|
||||
<div class="text-col">${ .Version }</div>
|
||||
<div class="text-col">{{= d.version }}</div>
|
||||
</div>
|
||||
<div class="text-row">
|
||||
<div class="text-col">${ .BindPort }</div>
|
||||
<div class="text-col">{{= d.bindPort }}</div>
|
||||
</div>
|
||||
<div class="text-row">
|
||||
<div class="text-col">${ .KCPBindPort }</div>
|
||||
<div class="text-col">{{= d.kcpBindPort }}</div>
|
||||
</div>
|
||||
<div class="text-row">
|
||||
<div class="text-col">${ .QUICBindPort }</div>
|
||||
<div class="text-col">{{= d.quicBindPort }}</div>
|
||||
</div>
|
||||
<div class="text-row">
|
||||
<div class="text-col">${ .HTTPPort }</div>
|
||||
<div class="text-col">{{= d.vhostHTTPPort }}</div>
|
||||
</div>
|
||||
<div class="text-row">
|
||||
<div class="text-col">${ .HTTPSPort }</div>
|
||||
<div class="text-col">{{= d.vhostHTTPSPort }}</div>
|
||||
</div>
|
||||
<div class="text-row">
|
||||
<div class="text-col">${ .TCPMUXPort }</div>
|
||||
<div class="text-col">{{= d.tcpmuxHTTPConnectPort }}</div>
|
||||
</div>
|
||||
<div class="text-row">
|
||||
<div class="text-col">${ .SubdomainHost }</div>
|
||||
<div class="text-col">{{= d.subdomainHost }}</div>
|
||||
</div>
|
||||
<div class="text-row">
|
||||
<div class="text-col">${ .MaxPoolCount }</div>
|
||||
<div class="text-col">{{= d.maxPoolCount }}</div>
|
||||
</div>
|
||||
<div class="text-row">
|
||||
<div class="text-col">${ .MaxPortsPerClient }</div>
|
||||
<div class="text-col">{{= d.maxPortsPerClient }}</div>
|
||||
</div>
|
||||
<div class="text-row">
|
||||
<div class="text-col">${ .HeartBeatTimeout }</div>
|
||||
<div class="text-col">{{= d.heartbeatTimeout }}</div>
|
||||
</div>
|
||||
<div class="text-row">
|
||||
<div class="text-col">${ .AllowPorts }</div>
|
||||
<div class="text-col">{{= d.allowPortsStr }}</div>
|
||||
</div>
|
||||
<div class="text-row">
|
||||
<div class="text-col">${ .TLSOnly }</div>
|
||||
<div class="text-col">{{= d.tlsForce }}</div>
|
||||
</div>
|
||||
<div class="text-row">
|
||||
<div class="text-col">${ .CurrentConnections }</div>
|
||||
<div class="text-col">{{= d.curConns }}</div>
|
||||
</div>
|
||||
<div class="text-row">
|
||||
<div class="text-col">${ .ClientCounts }</div>
|
||||
<div class="text-col">{{= d.clientCounts }}</div>
|
||||
</div>
|
||||
<div class="text-row">
|
||||
<div class="text-col">${ .ProxyCounts }</div>
|
||||
<div class="text-col">{{= d.proxyCounts }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="chart-info">
|
||||
<div class="chart-traffic">
|
||||
<div id="trafficPieChart"></div>
|
||||
</div>
|
||||
<div class="chart-count">
|
||||
<div id="countPieChart"></div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</script>
|
||||
|
||||
<!--用户列表模板-->
|
||||
<script type="text/html" id="userListTemplate">
|
||||
<section class="user-list">
|
||||
<form class="layui-form layui-row layui-col-space16" id="searchForm" lay-filter="searchForm">
|
||||
<div class="layui-col-md3">
|
||||
<div class="layui-input-wrap">
|
||||
@@ -49,12 +191,17 @@
|
||||
<div class="layui-col-md3">
|
||||
<div class="layui-btn-container">
|
||||
<button class="layui-btn layui-btn-sm" id="searchBtn">${ .Search }</button>
|
||||
<button class="layui-btn layui-btn-sm layui-btn-primary" type="reset" id="resetBtn">${ .Reset }</button>
|
||||
<button class="layui-btn layui-btn-sm layui-btn-primary" type="reset" id="resetBtn">${ .Reset }
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<table id="tokenTable" lay-filter="tokenTable"></table>
|
||||
<script type="text/html" id="toolbarTemplate">
|
||||
</section>
|
||||
</script>
|
||||
|
||||
<!--用户列表-表格工具条按钮模板-->
|
||||
<script type="text/html" id="userListToolbarTemplate">
|
||||
<div class="layui-btn-container">
|
||||
<button class="layui-btn layui-btn-sm" lay-event="add">${ .NewUser }</button>
|
||||
<button class="layui-btn layui-btn-sm" lay-event="remove">${ .RemoveUser }</button>
|
||||
@@ -62,17 +209,21 @@
|
||||
<button class="layui-btn layui-btn-sm" lay-event="enable">${ .EnableUser }</button>
|
||||
</div>
|
||||
</script>
|
||||
<script type="text/html" id="operationTemplate">
|
||||
|
||||
<!--用户列表-操作按钮模板-->
|
||||
<script type="text/html" id="userListOperationTemplate">
|
||||
<div class="layui-clear-space">
|
||||
<a class="layui-btn layui-btn-xs" lay-event="remove">${ .Remove }</a>
|
||||
{{# if (d.status) { }}
|
||||
{{# if (d.enable) { }}
|
||||
<a class="layui-btn layui-btn-xs" lay-event="disable">${ .Disable }</a>
|
||||
{{# } else { }}
|
||||
<a class="layui-btn layui-btn-xs" lay-event="enable">${ .Enable }</a>
|
||||
{{# } }}
|
||||
</div>
|
||||
</script>
|
||||
<script type="text/html" id="addTemplate">
|
||||
|
||||
<!--用户列表-添加用户表单模板-->
|
||||
<script type="text/html" id="addUserTemplate">
|
||||
<form class="layui-form" id="addUserForm" lay-filter="addUserForm">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">${ .User }</label>
|
||||
@@ -118,5 +269,165 @@
|
||||
</div>
|
||||
</form>
|
||||
</script>
|
||||
|
||||
<!--代理列表-代理表格模板-->
|
||||
<script type="text/html" id="proxyListTableTemplate">
|
||||
<section class="proxy-list">
|
||||
<table id="proxyListTable" lay-filter="proxyListTable"></table>
|
||||
</section>
|
||||
</script>
|
||||
|
||||
<!--代理列表-代理表格展示代理详情的箭头模板-->
|
||||
<script type="text/html" id="toggleProxyInfoArrowTemplate">
|
||||
<i class='layui-icon layui-icon-triangle-r toggle-proxy-info-arrow' data-index='{{ d.LAY_INDEX }}'
|
||||
lay-event='toggleProxyInfo'></i>
|
||||
</script>
|
||||
|
||||
<!--代理列表-代理列表每行展开后的表格模板-->
|
||||
<script type="text/html" id="expandTrTemplate">
|
||||
<tr class="layui-hide proxy-info" id="childTr_{{= d.index }}">
|
||||
<td></td>
|
||||
<td colspan="{{= d.colspan }}">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-xs12">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md12">
|
||||
<input type="hidden" value="{{= d.data.name }}">
|
||||
<div class="layui-btn traffic-statistics">${ .TrafficStatistics }</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{# if (d.proxyType === 'http' || d.proxyType === 'https') { }}
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-xs6">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md3">${ .Name }</div>
|
||||
<div class="layui-col-md9">{{= d.data.name }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-xs6">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md3">${ .Type }</div>
|
||||
<div class="layui-col-md9">{{= d.proxyType.toUpperCase() }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-xs6">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md3">${ .Domains }</div>
|
||||
<div class="layui-col-md9">{{= d.data.conf.customDomains }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-xs6">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md3">${ .SubDomain }</div>
|
||||
<div class="layui-col-md9">{{= d.data.conf.subdomain }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-xs6">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md3">${ .Locations }</div>
|
||||
<div class="layui-col-md9">{{= d.data.conf.locations }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-xs6">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md3">${ .HostRewrite }</div>
|
||||
<div class="layui-col-md9">{{= d.data.conf.hostHeaderRewrite }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-xs6">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md3">${ .Encryption }</div>
|
||||
<div class="layui-col-md9">{{= d.data.conf.transport.useEncryption }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-xs6">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md3">${ .Compression }</div>
|
||||
<div class="layui-col-md9">{{= d.data.conf.transport.useCompression }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-xs6">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md3">${ .LastStart }</div>
|
||||
<div class="layui-col-md9">{{= d.data.lastStartTime }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-xs6">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md3">${ .LastClose }</div>
|
||||
<div class="layui-col-md9">{{= d.data.lastCloseTime }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{# } else { }}
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-xs6">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md3">${ .Name }</div>
|
||||
<div class="layui-col-md9">{{= d.data.name }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-xs6">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md3">${ .Type }</div>
|
||||
<div class="layui-col-md9">{{= d.proxyType.toUpperCase() }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-xs6">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md3">${ .Addr }</div>
|
||||
<div class="layui-col-md9">{{= d.data.conf.remotePort }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-xs6">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md3">${ .Encryption }</div>
|
||||
<div class="layui-col-md9">{{= d.data.conf.transport.useEncryption }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-xs6">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md3">${ .Compression }</div>
|
||||
<div class="layui-col-md9">{{= d.data.conf.transport.useCompression }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-xs6">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md3">${ .LastStart }</div>
|
||||
<div class="layui-col-md9">{{= d.data.lastStartTime }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-xs6">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md3">${ .LastClose }</div>
|
||||
<div class="layui-col-md9">{{= d.data.lastCloseTime }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{# } }}
|
||||
</td>
|
||||
</tr>
|
||||
</script>
|
||||
|
||||
<!--代理列表-每个代理的最近7天流量统计模板-->
|
||||
<script type="text/html" id="trafficStaticTemplate">
|
||||
<div id="trafficBarChart"></div>
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
43
assets/templates/login.html
Normal file
@@ -0,0 +1,43 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="">
|
||||
<head>
|
||||
<title>Login</title>
|
||||
<link rel="stylesheet" href="./static/lib/layui/css/layui.css?v=${ .version }">
|
||||
<link rel="stylesheet" href="./static/css/layui-theme-dark.css?v=${ .version }">
|
||||
<link rel="stylesheet" href="./static/css/color.css?v=${ .version }">
|
||||
<link rel="stylesheet" href="./static/css/login.css?v=${ .version }">
|
||||
<script src="./static/lib/layui/layui.js?v=${ .version }"></script>
|
||||
<script src="./static/js/login.js?v=${ .version }"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="login-title">
|
||||
<a href="https://github.com/yhl452493373/frps-panel" target="_blank">
|
||||
<span class="title-text">${ .FrpsPanel }</span>
|
||||
<span class="title-version">${ .version }</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="layui-form login-container" id="loginForm">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-wrap">
|
||||
<div class="layui-input-prefix">
|
||||
<i class="layui-icon layui-icon-username"></i>
|
||||
</div>
|
||||
<input type="text" id="username" value="" lay-verify="required" placeholder="${ .Username }"
|
||||
lay-reqtext="${ .PleaseInputUsername }" autocomplete="off" class="layui-input" lay-affix="clear">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-wrap">
|
||||
<div class="layui-input-prefix">
|
||||
<i class="layui-icon layui-icon-password"></i>
|
||||
</div>
|
||||
<input type="password" id="password" value="" lay-verify="required" placeholder="${ .Password }"
|
||||
lay-reqtext="${ .PleaseInputPassword }" autocomplete="off" class="layui-input" lay-affix="eye">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<button class="layui-btn layui-btn-fluid" id="login">${ .Login }</button>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,182 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"frps-multiuser/pkg/server"
|
||||
"frps-multiuser/pkg/server/controller"
|
||||
"github.com/spf13/cobra"
|
||||
"gopkg.in/ini.v1"
|
||||
"io/fs"
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const version = "0.0.2"
|
||||
|
||||
var (
|
||||
showVersion bool
|
||||
configFile string
|
||||
)
|
||||
|
||||
func init() {
|
||||
rootCmd.PersistentFlags().BoolVarP(&showVersion, "version", "v", false, "version of frps-multiuser")
|
||||
rootCmd.PersistentFlags().StringVarP(&configFile, "config", "c", "./frps-multiuser.ini", "config file of frps-multiuser")
|
||||
}
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "frps-multiuser",
|
||||
Short: "frps-multiuser is the server plugin of frp to support multiple users.",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if showVersion {
|
||||
log.Println(version)
|
||||
return nil
|
||||
}
|
||||
common, tokens, ports, domains, subdomains, iniFile, err := ParseConfigFile(configFile)
|
||||
if err != nil {
|
||||
log.Printf("fail to start frps-multiuser : %v", err)
|
||||
return nil
|
||||
}
|
||||
s, err := server.New(controller.HandleController{
|
||||
CommonInfo: common,
|
||||
Tokens: tokens,
|
||||
Ports: ports,
|
||||
Domains: domains,
|
||||
Subdomains: subdomains,
|
||||
ConfigFile: configFile,
|
||||
IniFile: iniFile,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = s.Run()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
func Execute() {
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func ParseConfigFile(file string) (controller.CommonInfo, map[string]controller.TokenInfo, map[string][]string, map[string][]string, map[string][]string, *ini.File, error) {
|
||||
common := controller.CommonInfo{}
|
||||
users := make(map[string]controller.TokenInfo)
|
||||
ports := make(map[string][]string)
|
||||
domains := make(map[string][]string)
|
||||
subdomains := make(map[string][]string)
|
||||
|
||||
iniFile, err := ini.LoadSources(ini.LoadOptions{
|
||||
Insensitive: false,
|
||||
InsensitiveSections: false,
|
||||
InsensitiveKeys: false,
|
||||
IgnoreInlineComment: true,
|
||||
AllowBooleanKeys: true,
|
||||
}, file)
|
||||
if err != nil {
|
||||
var pathError *fs.PathError
|
||||
if errors.As(err, &pathError) {
|
||||
log.Printf("token file %s not found", file)
|
||||
} else {
|
||||
log.Printf("fail to parse token file %s : %v", file, err)
|
||||
}
|
||||
return common, nil, nil, nil, nil, iniFile, err
|
||||
}
|
||||
|
||||
commonSection, err := iniFile.GetSection("common")
|
||||
if err != nil {
|
||||
log.Printf("fail to get [common] section from file %s : %v", file, err)
|
||||
return common, nil, nil, nil, nil, iniFile, err
|
||||
}
|
||||
pluginAddr := commonSection.Key("plugin_addr").Value()
|
||||
if len(pluginAddr) != 0 {
|
||||
common.PluginAddr = pluginAddr
|
||||
} else {
|
||||
common.PluginAddr = "0.0.0.0"
|
||||
}
|
||||
pluginPort := commonSection.Key("plugin_port").Value()
|
||||
if len(pluginPort) != 0 {
|
||||
port, err := strconv.Atoi(pluginPort)
|
||||
if err != nil {
|
||||
return common, nil, nil, nil, nil, iniFile, err
|
||||
}
|
||||
common.PluginPort = port
|
||||
} else {
|
||||
common.PluginPort = 7200
|
||||
}
|
||||
common.User = commonSection.Key("admin_user").Value()
|
||||
common.Pwd = commonSection.Key("admin_pwd").Value()
|
||||
|
||||
portsSection, err := iniFile.GetSection("ports")
|
||||
if err != nil {
|
||||
log.Printf("fail to get [ports] section from file %s : %v", file, err)
|
||||
return common, nil, nil, nil, nil, iniFile, err
|
||||
}
|
||||
for _, key := range portsSection.Keys() {
|
||||
user := key.Name()
|
||||
value := key.Value()
|
||||
port := strings.Split(controller.TrimAllSpaceReg.ReplaceAllString(value, ""), ",")
|
||||
ports[user] = port
|
||||
}
|
||||
|
||||
domainsSection, err := iniFile.GetSection("domains")
|
||||
if err != nil {
|
||||
log.Printf("fail to get [domains] section from file %s : %v", file, err)
|
||||
return common, nil, nil, nil, nil, iniFile, err
|
||||
}
|
||||
for _, key := range domainsSection.Keys() {
|
||||
user := key.Name()
|
||||
value := key.Value()
|
||||
domain := strings.Split(controller.TrimAllSpaceReg.ReplaceAllString(value, ""), ",")
|
||||
domains[user] = domain
|
||||
}
|
||||
|
||||
subdomainsSection, err := iniFile.GetSection("subdomains")
|
||||
if err != nil {
|
||||
log.Printf("fail to get [subdomains] section from file %s : %v", file, err)
|
||||
return common, nil, nil, nil, nil, iniFile, err
|
||||
}
|
||||
for _, key := range subdomainsSection.Keys() {
|
||||
user := key.Name()
|
||||
value := key.Value()
|
||||
subdomain := strings.Split(controller.TrimAllSpaceReg.ReplaceAllString(value, ""), ",")
|
||||
subdomains[user] = subdomain
|
||||
}
|
||||
|
||||
usersSection, err := iniFile.GetSection("users")
|
||||
if err != nil {
|
||||
log.Printf("fail to get [users] section from file %s : %v", file, err)
|
||||
return common, nil, nil, nil, nil, iniFile, err
|
||||
}
|
||||
|
||||
disabledSection, err := iniFile.GetSection("disabled")
|
||||
if err != nil {
|
||||
log.Printf("fail to get [disabled] section from file %s : %v", file, err)
|
||||
return common, nil, nil, nil, nil, iniFile, err
|
||||
}
|
||||
|
||||
keys := usersSection.Keys()
|
||||
for _, key := range keys {
|
||||
comment, found := strings.CutPrefix(key.Comment, ";")
|
||||
if !found {
|
||||
comment, found = strings.CutPrefix(comment, "#")
|
||||
}
|
||||
token := controller.TokenInfo{
|
||||
User: key.Name(),
|
||||
Token: key.Value(),
|
||||
Comment: comment,
|
||||
Ports: strings.Join(ports[key.Name()], ","),
|
||||
Domains: strings.Join(domains[key.Name()], ","),
|
||||
Subdomains: strings.Join(subdomains[key.Name()], ","),
|
||||
Status: !(disabledSection.HasKey(key.Name()) && disabledSection.Key(key.Name()).Value() == "disable"),
|
||||
}
|
||||
users[token.User] = token
|
||||
}
|
||||
|
||||
return common, users, ports, domains, subdomains, iniFile, nil
|
||||
}
|
||||
116
cmd/frps-panel/cmd.go
Normal file
@@ -0,0 +1,116 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"frps-panel/pkg/server"
|
||||
"frps-panel/pkg/server/controller"
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/spf13/cobra"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const version = "2.0.0"
|
||||
|
||||
var (
|
||||
showVersion bool
|
||||
configFile string
|
||||
)
|
||||
|
||||
func init() {
|
||||
rootCmd.PersistentFlags().BoolVarP(&showVersion, "version", "v", false, "version of frps-panel")
|
||||
rootCmd.PersistentFlags().StringVarP(&configFile, "config", "c", "./frps-panel.toml", "config file of frps-panel")
|
||||
}
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "frps-panel",
|
||||
Short: "frps-panel is the server plugin of frp to support multiple users.",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if showVersion {
|
||||
log.Println(version)
|
||||
return nil
|
||||
}
|
||||
executable, err := os.Executable()
|
||||
if err != nil {
|
||||
log.Printf("error get program path: %v", err)
|
||||
return err
|
||||
}
|
||||
rootDir := filepath.Dir(executable)
|
||||
|
||||
configDir := filepath.Dir(configFile)
|
||||
tokensFile := filepath.Join(configDir, "frps-tokens.toml")
|
||||
|
||||
config, tls, err := parseConfigFile(configFile, tokensFile)
|
||||
if err != nil {
|
||||
log.Printf("fail to start frps-panel : %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
s, err := server.New(
|
||||
rootDir,
|
||||
config,
|
||||
tls,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = s.Run()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
func Execute() {
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func parseConfigFile(configFile, tokensFile string) (controller.HandleController, server.TLS, error) {
|
||||
var common controller.Common
|
||||
var tokens controller.Tokens
|
||||
_, err := toml.DecodeFile(configFile, &common)
|
||||
if err != nil {
|
||||
log.Fatalf("decode config file %v error: %v", configFile, err)
|
||||
}
|
||||
|
||||
_, err = toml.DecodeFile(tokensFile, &tokens)
|
||||
if err != nil {
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
tokens = controller.Tokens{Tokens: make(map[string]controller.TokenInfo)}
|
||||
} else {
|
||||
log.Fatalf("decode token file %v error: %v", tokensFile, err)
|
||||
}
|
||||
}
|
||||
|
||||
common.Common.DashboardTls = strings.HasPrefix(strings.ToLower(common.Common.DashboardAddr), "https://")
|
||||
|
||||
tls := server.TLS{
|
||||
Enable: common.Common.TlsMode,
|
||||
Protocol: "HTTP",
|
||||
Cert: common.Common.TlsCertFile,
|
||||
Key: common.Common.TlsKeyFile,
|
||||
}
|
||||
|
||||
if tls.Enable {
|
||||
tls.Protocol = "HTTPS"
|
||||
|
||||
if strings.TrimSpace(tls.Cert) == "" || strings.TrimSpace(tls.Key) == "" {
|
||||
tls.Enable = false
|
||||
tls.Protocol = "HTTP"
|
||||
log.Printf("fail to enable tls: tls cert or key not exist, use http as default.")
|
||||
}
|
||||
}
|
||||
|
||||
return controller.HandleController{
|
||||
CommonInfo: common.Common,
|
||||
Tokens: tokens.Tokens,
|
||||
Version: version,
|
||||
ConfigFile: configFile,
|
||||
TokensFile: tokensFile,
|
||||
}, tls, nil
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
; basic options
|
||||
[common]
|
||||
plugin_addr = 127.0.0.1
|
||||
plugin_port = 7200
|
||||
admin_user = admin
|
||||
admin_pwd = admin
|
||||
|
||||
; user tokens
|
||||
[users]
|
||||
user1 = token1
|
||||
|
||||
; user been disabled
|
||||
[disabled]
|
||||
|
||||
; user allowed ports. it will be used when a new proxy connect on
|
||||
[ports]
|
||||
|
||||
; user allowed domains. it will be used when a new proxy connect on
|
||||
[domains]
|
||||
|
||||
; user allowed subdomains. it will be used when a new proxy connect on
|
||||
[subdomains]
|
||||
21
config/frps-panel.toml
Normal file
@@ -0,0 +1,21 @@
|
||||
# basic options
|
||||
[common]
|
||||
# frps panel config info
|
||||
plugin_addr = "127.0.0.1"
|
||||
plugin_port = 7200
|
||||
#admin_user = "admin"
|
||||
#admin_pwd = "admin"
|
||||
# specified login state keep time
|
||||
admin_keep_time = 0
|
||||
|
||||
# enable tls
|
||||
tls_mode = false
|
||||
#tls_cert_file = "cert.crt"
|
||||
#tls_key_file = "cert.key"
|
||||
|
||||
# frp dashboard info
|
||||
dashboard_addr = "127.0.0.1"
|
||||
dashboard_port = 7500
|
||||
dashboard_user = "admin"
|
||||
dashboard_pwd = "admin"
|
||||
|
||||
17
config/frps-tokens.toml
Normal file
@@ -0,0 +1,17 @@
|
||||
[tokens]
|
||||
[tokens.user1]
|
||||
user = "user1"
|
||||
token = "token1"
|
||||
comment = "user1 with token1"
|
||||
ports = [8080, "10000-10200"]
|
||||
domains = ["web01.domain.com", "web02.domain.com"]
|
||||
subdomains = ["web01", "web02"]
|
||||
enable = false
|
||||
[tokens.user2]
|
||||
user = "user2"
|
||||
token = "token2"
|
||||
comment = "user2 with token2"
|
||||
ports = [9080]
|
||||
domains = ["web11.domain.com", "web12.domain.com"]
|
||||
subdomains = ["web11", "web12"]
|
||||
enable = false
|
||||
22
go.mod
@@ -1,13 +1,15 @@
|
||||
module frps-multiuser
|
||||
module frps-panel
|
||||
|
||||
go 1.21
|
||||
|
||||
require (
|
||||
github.com/fatedier/frp v0.34.1
|
||||
github.com/BurntSushi/toml v1.0.0
|
||||
github.com/fatedier/frp v0.52.3
|
||||
github.com/gin-contrib/i18n v1.0.0
|
||||
github.com/gin-contrib/sessions v0.0.5
|
||||
github.com/gin-gonic/gin v1.9.1
|
||||
github.com/spf13/cobra v0.0.3
|
||||
gopkg.in/ini.v1 v1.67.0
|
||||
github.com/spf13/cobra v1.7.0
|
||||
golang.org/x/text v0.11.0
|
||||
)
|
||||
|
||||
require (
|
||||
@@ -15,14 +17,17 @@ require (
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
|
||||
github.com/chenzhuoyu/iasm v0.9.0 // indirect
|
||||
github.com/fatedier/beego v0.0.0-20171024143340-6c6a4f5bd5eb // indirect
|
||||
github.com/fatedier/golib v0.1.1-0.20200901083111-1f870741e185 // indirect
|
||||
github.com/fatedier/golib v0.1.1-0.20230725122706-dcbaee8eef40 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.14.1 // indirect
|
||||
github.com/goccy/go-json v0.10.2 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
||||
github.com/gorilla/context v1.1.1 // indirect
|
||||
github.com/gorilla/securecookie v1.1.1 // indirect
|
||||
github.com/gorilla/sessions v1.2.1 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
|
||||
github.com/leodido/go-urn v1.2.4 // indirect
|
||||
@@ -30,15 +35,16 @@ require (
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/nicksnyder/go-i18n/v2 v2.2.1 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.9 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
|
||||
github.com/samber/lo v1.38.1 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.2.11 // indirect
|
||||
golang.org/x/arch v0.4.0 // indirect
|
||||
golang.org/x/crypto v0.11.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20221205204356-47842c84f3db // indirect
|
||||
golang.org/x/net v0.12.0 // indirect
|
||||
golang.org/x/sys v0.10.0 // indirect
|
||||
golang.org/x/text v0.11.0 // indirect
|
||||
google.golang.org/protobuf v1.31.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
224
go.sum
@@ -1,64 +1,35 @@
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/Azure/go-ntlmssp v0.0.0-20200615164410-66371956d46c/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU=
|
||||
github.com/BurntSushi/toml v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU=
|
||||
github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
|
||||
github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
|
||||
github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM=
|
||||
github.com/bytedance/sonic v1.10.0-rc3 h1:uNSnscRapXTwUgTyOF0GVljYD08p9X/Lbr9MweSV3V0=
|
||||
github.com/bytedance/sonic v1.10.0-rc3/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d h1:77cEq6EriyTZ0g/qfRdp61a3Uu/AWrgIq2s0ClJV1g0=
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d/go.mod h1:8EPpVsBuRksnlj1mLy4AWzRNQYxauNi62uWcE3to6eA=
|
||||
github.com/chenzhuoyu/iasm v0.9.0 h1:9fhXjVzq5hUy2gkhhgHl95zG2cEAhw9OSGs8toWWAwo=
|
||||
github.com/chenzhuoyu/iasm v0.9.0/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog=
|
||||
github.com/coreos/go-oidc v2.2.1+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM=
|
||||
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
|
||||
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
|
||||
github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
|
||||
github.com/fatedier/beego v0.0.0-20171024143340-6c6a4f5bd5eb h1:wCrNShQidLmvVWn/0PikGmpdP0vtQmnvyRg3ZBEhczw=
|
||||
github.com/fatedier/beego v0.0.0-20171024143340-6c6a4f5bd5eb/go.mod h1:wx3gB6dbIfBRcucp94PI9Bt3I0F2c/MyNEWuhzpWiwk=
|
||||
github.com/fatedier/frp v0.34.1 h1:8J0ASuKVqo/IQubIVkMnuuflzhNT661PexUgeye/zUE=
|
||||
github.com/fatedier/frp v0.34.1/go.mod h1:y3PpthszJ+S5HB2J5kcXqoLr5rtgdmMa0RuvnGqGfik=
|
||||
github.com/fatedier/golib v0.1.1-0.20200901083111-1f870741e185 h1:2p4W5xYizIYwhiGQgeHOQcRD2O84j0tjD40P6gUCRrk=
|
||||
github.com/fatedier/golib v0.1.1-0.20200901083111-1f870741e185/go.mod h1:MUs+IH/MGJNz5Cj2JVJBPZBKw2exON7LzO3HrJHmGiQ=
|
||||
github.com/fatedier/kcp-go v2.0.4-0.20190803094908-fe8645b0a904+incompatible/go.mod h1:YpCOaxj7vvMThhIQ9AfTOPW2sfztQR5WDfs7AflSy4s=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/fatedier/frp v0.52.3 h1:YElvJIQ3wXAloJTp7JOmLTpnm/+IyLmzNgeDNqQFI9Q=
|
||||
github.com/fatedier/frp v0.52.3/go.mod h1:M0mqGPc0daWLB9Ziv91rlwUIpxpb/oNDiOAx8NN5i3E=
|
||||
github.com/fatedier/golib v0.1.1-0.20230725122706-dcbaee8eef40 h1:BVdpWT6viE/mpuRa6txNyRNjtHa1Efrii9Du6/gHfJ0=
|
||||
github.com/fatedier/golib v0.1.1-0.20230725122706-dcbaee8eef40/go.mod h1:Lmi9U4VfvdRvonSMh1FgXVy1hCXycVyJk4E9ktokknE=
|
||||
github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
|
||||
github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA=
|
||||
github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/gin-contrib/i18n v1.0.0 h1:e5uEOmaAr09Iyr4vuWuvvpByjmvxGDO7iSkmiFpSsk0=
|
||||
github.com/gin-contrib/i18n v1.0.0/go.mod h1:yyyTArpVZeXCFT/kbLbD5CS192+OZ8Y+angnJjvnB98=
|
||||
github.com/gin-contrib/sessions v0.0.5 h1:CATtfHmLMQrMNpJRgzjWXD7worTh7g7ritsQfmF+0jE=
|
||||
github.com/gin-contrib/sessions v0.0.5/go.mod h1:vYAuaUPqie3WUSsft6HUlCjlwwoJQs97miaG2+7neKY=
|
||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg=
|
||||
github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
|
||||
github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0=
|
||||
github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg=
|
||||
github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc=
|
||||
github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||
@@ -67,126 +38,53 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.14.1 h1:9c50NUPC30zyuKprjL3vNZ0m5oG+jU0zvx4AqHGnv4k=
|
||||
github.com/go-playground/validator/v10 v10.14.1/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
|
||||
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
|
||||
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY=
|
||||
github.com/googleapis/gnostic v0.1.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY=
|
||||
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8=
|
||||
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
||||
github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ=
|
||||
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
|
||||
github.com/gorilla/sessions v1.2.1 h1:DHd3rPN5lE3Ts3D8rKkQ8x/0kqfeNmBAaiSi+o7FsgI=
|
||||
github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
|
||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg=
|
||||
github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
||||
github.com/klauspost/reedsolomon v1.9.1/go.mod h1:CwCi+NUr9pqSVktrkN+Ondf06rkhYZ/pcNv7fu+8Un4=
|
||||
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
|
||||
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
|
||||
github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
|
||||
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
|
||||
github.com/nicksnyder/go-i18n/v2 v2.2.1 h1:aOzRCdwsJuoExfZhoiXHy4bjruwCMdt5otbYojM/PaA=
|
||||
github.com/nicksnyder/go-i18n/v2 v2.2.1/go.mod h1:fF2++lPHlo+/kPaj3nB0uxtPwzlPm+BlgwGX7MkeGj0=
|
||||
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
||||
github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||
github.com/onsi/ginkgo v1.12.3/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
|
||||
github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
|
||||
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||
github.com/pelletier/go-toml/v2 v2.0.9 h1:uH2qQXheeefCCkuBBSLi7jCiSmj3VRh2+Goq2N7Xxu0=
|
||||
github.com/pelletier/go-toml/v2 v2.0.9/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
|
||||
github.com/pires/go-proxyproto v0.0.0-20190111085350-4d51b51e3bfc/go.mod h1:6/gX3+E/IYGa0wMORlSMla999awQFdbaeQCHjSMKIzY=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4=
|
||||
github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||
github.com/prometheus/client_golang v1.4.1/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
|
||||
github.com/rakyll/statik v0.1.1/go.mod h1:OEi9wJV/fMUAGx1eNjq75DKDsJVuEv1U0oYdX6GX8Zs=
|
||||
github.com/rodaine/table v1.0.0/go.mod h1:YAUzwPOji0DUJNEvggdxyQcUAl4g3hDRcFlyjnnR51I=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/spf13/cobra v0.0.3 h1:ZlrZ4XsMRm04Fr5pSFxBgfND2EBVa1nLpiy1stUsX/8=
|
||||
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
|
||||
github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/samber/lo v1.38.1 h1:j2XEAqXKb09Am4ebOg31SpvzUTTs6EN3VfgeLUhPdXM=
|
||||
github.com/samber/lo v1.38.1/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA=
|
||||
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
|
||||
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
@@ -194,61 +92,29 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o
|
||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/templexxx/cpufeat v0.0.0-20170927014610-3794dfbfb047/go.mod h1:wM7WEvslTq+iOEAMDLSzhVuOt5BRZ05WirO+b09GHQU=
|
||||
github.com/templexxx/xor v0.0.0-20170926022130-0af8e873c554/go.mod h1:5XA7W9S6mni3h5uvOC75dA3m9CCCaS83lltmc0ukdi4=
|
||||
github.com/tjfoc/gmsm v0.0.0-20171124023159-98aa888b79d8/go.mod h1:XxO4hdhhrzAd+G4CjDqaOkd0hUzmtPR/d3EiBBMn/wc=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||
github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
|
||||
github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||
github.com/vaughan0/go-ini v0.0.0-20130923145212-a98ad7ee00ec/go.mod h1:owBmyHYMLkxyrugmfwE/DLJyW8Ro9mkphwuVErQ0iUw=
|
||||
github.com/xtaci/lossyconn v0.0.0-20190602105132-8df528c0c9ae/go.mod h1:gXtu8J62kEgmN++bm9BVICuT/e8yiLI2KFobd/TRFsE=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
||||
golang.org/x/arch v0.4.0 h1:A8WCeEWhLwPBKNbFi5Wv5UTCBx5zzubnXDlMOFAzFMc=
|
||||
golang.org/x/arch v0.4.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190228161510-8dd112bcdc25/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA=
|
||||
golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio=
|
||||
golang.org/x/exp v0.0.0-20221205204356-47842c84f3db h1:D/cFflL63o2KSLJIwjlcIt8PR064j/xsmdEJL/YvY/o=
|
||||
golang.org/x/exp v0.0.0-20221205204356-47842c84f3db/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190228165749-92fc7df08ae7/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50=
|
||||
golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA=
|
||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
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=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191022100944-742c48ecaeb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
@@ -259,63 +125,27 @@ golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
|
||||
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
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/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
|
||||
golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
|
||||
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
|
||||
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
|
||||
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/square/go-jose.v2 v2.4.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
k8s.io/apimachinery v0.18.3/go.mod h1:OaXp26zu/5J7p0f92ASynJa1pZo06YlV9fG7BoWbCko=
|
||||
k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
|
||||
k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
|
||||
k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
|
||||
k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6/go.mod h1:GRQhZsXIAJ1xR0C9bd8UpWHZ5plfAS9fzPjJuQ6JL3E=
|
||||
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
|
||||
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
|
||||
sigs.k8s.io/structured-merge-diff/v3 v3.0.0-20200116222232-67a7b8c61874/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw=
|
||||
sigs.k8s.io/structured-merge-diff/v3 v3.0.0/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw=
|
||||
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
|
||||
|
||||
17
package.sh
@@ -1,12 +1,19 @@
|
||||
#!/bin/bash
|
||||
version=$(cat cmd/frps-panel/cmd.go | grep 'const version' | egrep -o '[0-9.]+')
|
||||
cd ./release || exit
|
||||
rm -rf *.zip
|
||||
list=$(ls frps-multiuser-*)
|
||||
list=$(ls frps-panel-*)
|
||||
echo "$list"
|
||||
for binFile in $list
|
||||
do
|
||||
cp "$binFile" frps-multiuser
|
||||
zip -r "$binFile".zip frps-multiuser frps-multiuser.ini assets -x "*.git*" "*.idea*" "*.DS_Store" "*.contentFlavour"
|
||||
rm -rf "$binFile" frps-multiuser
|
||||
tmpFile=frps-panel
|
||||
newBinFile=$binFile
|
||||
if echo "$binFile" | grep -q -E "\.exe";then
|
||||
tmpFile=frps-panel.exe
|
||||
newBinFile=${newBinFile%%.exe*}
|
||||
fi
|
||||
cp "$binFile" "$tmpFile"
|
||||
zip -r "$newBinFile-$version".zip "$tmpFile" frps-panel.toml frps-tokens.toml assets -x "*.git*" "*.idea*" "*.DS_Store" "*.contentFlavour"
|
||||
rm -rf "$binFile" "$tmpFile"
|
||||
done
|
||||
rm -rf frps-multiuser.ini assets
|
||||
rm -rf frps-panel.toml frps-tokens.toml assets
|
||||
|
||||
104
pkg/server/controller/authorizer.go
Normal file
@@ -0,0 +1,104 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (c *HandleController) BasicAuth() gin.HandlerFunc {
|
||||
return func(context *gin.Context) {
|
||||
if trimString(c.CommonInfo.AdminUser) == "" || trimString(c.CommonInfo.AdminPwd) == "" {
|
||||
if context.Request.RequestURI == LoginUrl {
|
||||
context.Redirect(http.StatusTemporaryRedirect, LoginSuccessUrl)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
session := sessions.Default(context)
|
||||
auth := session.Get(AuthName)
|
||||
|
||||
if auth != nil {
|
||||
if c.CommonInfo.AdminKeepTime > 0 {
|
||||
cookie, _ := context.Request.Cookie(SessionName)
|
||||
if cookie != nil {
|
||||
//important thx https://blog.csdn.net/zhanghongxia8285/article/details/107321838/
|
||||
cookie.Expires = time.Now().Add(time.Second * time.Duration(c.CommonInfo.AdminKeepTime))
|
||||
http.SetCookie(context.Writer, cookie)
|
||||
}
|
||||
}
|
||||
|
||||
username, password, _ := parseBasicAuth(fmt.Sprintf("%v", auth))
|
||||
|
||||
usernameMatch := username == c.CommonInfo.AdminUser
|
||||
passwordMatch := password == c.CommonInfo.AdminPwd
|
||||
|
||||
if usernameMatch && passwordMatch {
|
||||
context.Next()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
isAjax := context.GetHeader("X-Requested-With") == "XMLHttpRequest"
|
||||
|
||||
if !isAjax && context.Request.RequestURI != LoginUrl {
|
||||
context.Redirect(http.StatusTemporaryRedirect, LoginUrl)
|
||||
} else {
|
||||
context.AbortWithStatus(http.StatusUnauthorized)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *HandleController) LoginAuth(username, password string, context *gin.Context) bool {
|
||||
if trimString(c.CommonInfo.AdminUser) == "" || trimString(c.CommonInfo.AdminPwd) == "" {
|
||||
return true
|
||||
}
|
||||
|
||||
session := sessions.Default(context)
|
||||
|
||||
sessionAuth := session.Get(AuthName)
|
||||
internalAuth := encodeBasicAuth(c.CommonInfo.AdminUser, c.CommonInfo.AdminPwd)
|
||||
|
||||
if sessionAuth == internalAuth {
|
||||
return true
|
||||
} else {
|
||||
basicAuth := encodeBasicAuth(username, password)
|
||||
if basicAuth == internalAuth {
|
||||
session.Set(AuthName, basicAuth)
|
||||
_ = session.Save()
|
||||
return true
|
||||
} else {
|
||||
session.Delete(AuthName)
|
||||
_ = session.Save()
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func ClearAuth(context *gin.Context) {
|
||||
session := sessions.Default(context)
|
||||
session.Delete(AuthName)
|
||||
_ = session.Save()
|
||||
}
|
||||
|
||||
func parseBasicAuth(auth string) (username, password string, ok bool) {
|
||||
c, err := base64.StdEncoding.DecodeString(auth)
|
||||
if err != nil {
|
||||
return "", "", false
|
||||
}
|
||||
cs := string(c)
|
||||
username, password, ok = strings.Cut(cs, ":")
|
||||
if !ok {
|
||||
return "", "", false
|
||||
}
|
||||
return username, password, true
|
||||
}
|
||||
|
||||
func encodeBasicAuth(username, password string) string {
|
||||
authString := fmt.Sprintf("%s:%s", username, password)
|
||||
return base64.StdEncoding.EncodeToString([]byte(authString))
|
||||
}
|
||||
@@ -1,101 +1,21 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
plugin "github.com/fatedier/frp/pkg/plugin/server"
|
||||
ginI18n "github.com/gin-contrib/i18n"
|
||||
"github.com/gin-gonic/gin"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
Success = 0
|
||||
ParamError = 1
|
||||
UserExist = 2
|
||||
SaveError = 3
|
||||
UserFormatError = 4
|
||||
TokenFormatError = 5
|
||||
)
|
||||
|
||||
var UserFormatReg = regexp.MustCompile("^\\w$")
|
||||
var TokenFormatReg = regexp.MustCompile("^[\\w!@#$%^&*()]+$")
|
||||
var TrimAllSpaceReg = regexp.MustCompile("[\\n\\t\\r\\s]")
|
||||
var TrimBreakLineReg = regexp.MustCompile("[\\n\\t\\r]")
|
||||
|
||||
type Response struct {
|
||||
Msg string `json:"msg"`
|
||||
}
|
||||
|
||||
type HTTPError struct {
|
||||
Code int
|
||||
Err error
|
||||
}
|
||||
|
||||
type CommonInfo struct {
|
||||
PluginAddr string
|
||||
PluginPort int
|
||||
User string
|
||||
Pwd string
|
||||
}
|
||||
|
||||
type TokenInfo struct {
|
||||
User string `json:"user" form:"user"`
|
||||
Token string `json:"token" form:"token"`
|
||||
Comment string `json:"comment" form:"comment"`
|
||||
Ports string `json:"ports" from:"ports"`
|
||||
Domains string `json:"domains" from:"domains"`
|
||||
Subdomains string `json:"subdomains" from:"subdomains"`
|
||||
Status bool `json:"status" form:"status"`
|
||||
}
|
||||
|
||||
type TokenResponse struct {
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Count int `json:"count"`
|
||||
Data []TokenInfo `json:"data"`
|
||||
}
|
||||
|
||||
type OperationResponse struct {
|
||||
Success bool `json:"success"`
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
type TokenSearch struct {
|
||||
TokenInfo
|
||||
Page int `form:"page"`
|
||||
Limit int `form:"limit"`
|
||||
}
|
||||
|
||||
type TokenUpdate struct {
|
||||
Before TokenInfo `json:"before"`
|
||||
After TokenInfo `json:"after"`
|
||||
}
|
||||
|
||||
type TokenRemove struct {
|
||||
Users []TokenInfo `json:"users"`
|
||||
}
|
||||
|
||||
type TokenDisable struct {
|
||||
TokenRemove
|
||||
}
|
||||
|
||||
type TokenEnable struct {
|
||||
TokenDisable
|
||||
}
|
||||
|
||||
func (e *HTTPError) Error() string {
|
||||
return e.Err.Error()
|
||||
}
|
||||
|
||||
type HandlerFunc func(ctx *gin.Context) (interface{}, error)
|
||||
|
||||
func (c *HandleController) MakeHandlerFunc() gin.HandlerFunc {
|
||||
return func(context *gin.Context) {
|
||||
var response plugin.Response
|
||||
@@ -103,19 +23,13 @@ func (c *HandleController) MakeHandlerFunc() gin.HandlerFunc {
|
||||
|
||||
request := plugin.Request{}
|
||||
if err := context.BindJSON(&request); err != nil {
|
||||
_ = context.Error(&HTTPError{
|
||||
Code: http.StatusBadRequest,
|
||||
Err: err,
|
||||
})
|
||||
_ = context.AbortWithError(http.StatusBadRequest, err)
|
||||
return
|
||||
}
|
||||
|
||||
jsonStr, err := json.Marshal(request.Content)
|
||||
if err != nil {
|
||||
_ = context.Error(&HTTPError{
|
||||
Code: http.StatusBadRequest,
|
||||
Err: err,
|
||||
})
|
||||
_ = context.AbortWithError(http.StatusBadRequest, err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -160,10 +74,55 @@ func (c *HandleController) MakeHandlerFunc() gin.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *HandleController) MakeManagerFunc() func(context *gin.Context) {
|
||||
func (c *HandleController) MakeLoginFunc() func(context *gin.Context) {
|
||||
return func(context *gin.Context) {
|
||||
if context.Request.Method == "GET" {
|
||||
if c.LoginAuth("", "", context) {
|
||||
if context.Request.RequestURI == LoginUrl {
|
||||
context.Redirect(http.StatusTemporaryRedirect, LoginSuccessUrl)
|
||||
}
|
||||
return
|
||||
}
|
||||
context.HTML(http.StatusOK, "login.html", gin.H{
|
||||
"version": c.Version,
|
||||
"FrpsPanel": ginI18n.MustGetMessage(context, "Frps Panel"),
|
||||
"Username": ginI18n.MustGetMessage(context, "Username"),
|
||||
"Password": ginI18n.MustGetMessage(context, "Password"),
|
||||
"Login": ginI18n.MustGetMessage(context, "Login"),
|
||||
"PleaseInputUsername": ginI18n.MustGetMessage(context, "Please input username"),
|
||||
"PleaseInputPassword": ginI18n.MustGetMessage(context, "Please input password"),
|
||||
})
|
||||
} else if context.Request.Method == "POST" {
|
||||
username := context.PostForm("username")
|
||||
password := context.PostForm("password")
|
||||
if c.LoginAuth(username, password, context) {
|
||||
context.JSON(http.StatusOK, gin.H{
|
||||
"success": true,
|
||||
"message": ginI18n.MustGetMessage(context, "Login success"),
|
||||
})
|
||||
} else {
|
||||
context.JSON(http.StatusOK, gin.H{
|
||||
"success": false,
|
||||
"message": ginI18n.MustGetMessage(context, "Username or password incorrect"),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *HandleController) MakeLogoutFunc() func(context *gin.Context) {
|
||||
return func(context *gin.Context) {
|
||||
ClearAuth(context)
|
||||
context.Redirect(http.StatusTemporaryRedirect, LogoutSuccessUrl)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *HandleController) MakeIndexFunc() func(context *gin.Context) {
|
||||
return func(context *gin.Context) {
|
||||
context.HTML(http.StatusOK, "index.html", gin.H{
|
||||
"UserManage": ginI18n.MustGetMessage(context, "User Manage"),
|
||||
"version": c.Version,
|
||||
"showExit": trimString(c.CommonInfo.AdminUser) != "" && trimString(c.CommonInfo.AdminPwd) != "",
|
||||
"FrpsPanel": ginI18n.MustGetMessage(context, "Frps Panel"),
|
||||
"User": ginI18n.MustGetMessage(context, "User"),
|
||||
"Token": ginI18n.MustGetMessage(context, "Token"),
|
||||
"Notes": ginI18n.MustGetMessage(context, "Notes"),
|
||||
@@ -187,6 +146,37 @@ func (c *HandleController) MakeManagerFunc() func(context *gin.Context) {
|
||||
"PleaseInputAllowedSubdomains": ginI18n.MustGetMessage(context, "Please input allowed subdomains"),
|
||||
"NotLimit": ginI18n.MustGetMessage(context, "Not limit"),
|
||||
"None": ginI18n.MustGetMessage(context, "None"),
|
||||
"ServerInfo": ginI18n.MustGetMessage(context, "Server Info"),
|
||||
"Users": ginI18n.MustGetMessage(context, "Users"),
|
||||
"Proxies": ginI18n.MustGetMessage(context, "Proxies"),
|
||||
"TrafficStatistics": ginI18n.MustGetMessage(context, "Traffic Statistics"),
|
||||
"Name": ginI18n.MustGetMessage(context, "Name"),
|
||||
"Type": ginI18n.MustGetMessage(context, "Type"),
|
||||
"Domains": ginI18n.MustGetMessage(context, "Domains"),
|
||||
"SubDomain": ginI18n.MustGetMessage(context, "SubDomain"),
|
||||
"Locations": ginI18n.MustGetMessage(context, "Locations"),
|
||||
"HostRewrite": ginI18n.MustGetMessage(context, "HostRewrite"),
|
||||
"Encryption": ginI18n.MustGetMessage(context, "Encryption"),
|
||||
"Compression": ginI18n.MustGetMessage(context, "Compression"),
|
||||
"Addr": ginI18n.MustGetMessage(context, "Addr"),
|
||||
"LastStart": ginI18n.MustGetMessage(context, "Last Start"),
|
||||
"LastClose": ginI18n.MustGetMessage(context, "Last Close"),
|
||||
"Version": ginI18n.MustGetMessage(context, "Version"),
|
||||
"BindPort": ginI18n.MustGetMessage(context, "Bind Port"),
|
||||
"KCPBindPort": ginI18n.MustGetMessage(context, "KCP Bind Port"),
|
||||
"QUICBindPort": ginI18n.MustGetMessage(context, "QUIC Bind Port"),
|
||||
"HTTPPort": ginI18n.MustGetMessage(context, "HTTP Port"),
|
||||
"HTTPSPort": ginI18n.MustGetMessage(context, "HTTPS Port"),
|
||||
"TCPMUXPort": ginI18n.MustGetMessage(context, "TCPMUX Port"),
|
||||
"SubdomainHost": ginI18n.MustGetMessage(context, "Subdomain Host"),
|
||||
"MaxPoolCount": ginI18n.MustGetMessage(context, "Max Pool Count"),
|
||||
"MaxPortsPerClient": ginI18n.MustGetMessage(context, "Max Ports Per Client"),
|
||||
"HeartBeatTimeout": ginI18n.MustGetMessage(context, "Heart Beat Timeout"),
|
||||
"AllowPorts": ginI18n.MustGetMessage(context, "Allow Ports"),
|
||||
"TLSOnly": ginI18n.MustGetMessage(context, "TLS Only"),
|
||||
"CurrentConnections": ginI18n.MustGetMessage(context, "Current Connections"),
|
||||
"ClientCounts": ginI18n.MustGetMessage(context, "Client Counts"),
|
||||
"ProxyCounts": ginI18n.MustGetMessage(context, "Proxy Counts"),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -214,11 +204,13 @@ func (c *HandleController) MakeLangFunc() func(context *gin.Context) {
|
||||
"OperateError": ginI18n.MustGetMessage(context, "Operate error"),
|
||||
"OperateFailed": ginI18n.MustGetMessage(context, "Operate failed"),
|
||||
"UserExist": ginI18n.MustGetMessage(context, "User exist"),
|
||||
"UserNotExist": ginI18n.MustGetMessage(context, "User not exist"),
|
||||
"UserFormatError": ginI18n.MustGetMessage(context, "User format error"),
|
||||
"TokenFormatError": ginI18n.MustGetMessage(context, "Token format error"),
|
||||
"ShouldCheckUser": ginI18n.MustGetMessage(context, "Please check at least one user"),
|
||||
"OperationConfirm": ginI18n.MustGetMessage(context, "Operation confirm"),
|
||||
"EmptyData": ginI18n.MustGetMessage(context, "Empty data"),
|
||||
"NotLimit": ginI18n.MustGetMessage(context, "Not limit"),
|
||||
"AllowedPorts": ginI18n.MustGetMessage(context, "Allowed ports"),
|
||||
"AllowedDomains": ginI18n.MustGetMessage(context, "Allowed domains"),
|
||||
"AllowedSubdomains": ginI18n.MustGetMessage(context, "Allowed subdomains"),
|
||||
@@ -227,6 +219,29 @@ func (c *HandleController) MakeLangFunc() func(context *gin.Context) {
|
||||
"SubdomainsInvalid": ginI18n.MustGetMessage(context, "Subdomains is invalid"),
|
||||
"CommentInvalid": ginI18n.MustGetMessage(context, "Comment is invalid"),
|
||||
"ParamError": ginI18n.MustGetMessage(context, "Param error"),
|
||||
"OtherError": ginI18n.MustGetMessage(context, "Other error"),
|
||||
"Name": ginI18n.MustGetMessage(context, "Name"),
|
||||
"Port": ginI18n.MustGetMessage(context, "Port"),
|
||||
"Connections": ginI18n.MustGetMessage(context, "Connections"),
|
||||
"TrafficIn": ginI18n.MustGetMessage(context, "Traffic In"),
|
||||
"TrafficOut": ginI18n.MustGetMessage(context, "Traffic Out"),
|
||||
"ClientVersion": ginI18n.MustGetMessage(context, "Client Version"),
|
||||
"TrafficStatistics": ginI18n.MustGetMessage(context, "Traffic Statistics"),
|
||||
"online": ginI18n.MustGetMessage(context, "online"),
|
||||
"offline": ginI18n.MustGetMessage(context, "offline"),
|
||||
"true": ginI18n.MustGetMessage(context, "true"),
|
||||
"false": ginI18n.MustGetMessage(context, "false"),
|
||||
"NetworkTraffic": ginI18n.MustGetMessage(context, "Network Traffic"),
|
||||
"today": ginI18n.MustGetMessage(context, "today"),
|
||||
"now": ginI18n.MustGetMessage(context, "now"),
|
||||
"Proxies": ginI18n.MustGetMessage(context, "Proxies"),
|
||||
"NotSet": ginI18n.MustGetMessage(context, "Not Set"),
|
||||
"Proxy": ginI18n.MustGetMessage(context, "Proxy"),
|
||||
"TokenInvalid": ginI18n.MustGetMessage(context, "Token invalid"),
|
||||
"Total": ginI18n.MustGetMessage(context, "Total"),
|
||||
"Items": ginI18n.MustGetMessage(context, "Items"),
|
||||
"Goto": ginI18n.MustGetMessage(context, "Go to"),
|
||||
"PerPage": ginI18n.MustGetMessage(context, "Per Page"),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -276,34 +291,10 @@ func (c *HandleController) MakeQueryTokensFunc() func(context *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
func filter(main TokenInfo, sub TokenInfo) bool {
|
||||
replaceSpaceUser := TrimAllSpaceReg.ReplaceAllString(sub.User, "")
|
||||
if len(replaceSpaceUser) != 0 {
|
||||
if !strings.Contains(main.User, replaceSpaceUser) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
replaceSpaceToken := TrimAllSpaceReg.ReplaceAllString(sub.Token, "")
|
||||
if len(replaceSpaceToken) != 0 {
|
||||
if !strings.Contains(main.Token, replaceSpaceToken) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
replaceSpaceComment := TrimAllSpaceReg.ReplaceAllString(sub.Comment, "")
|
||||
if len(replaceSpaceComment) != 0 {
|
||||
if !strings.Contains(main.Comment, replaceSpaceComment) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (c *HandleController) MakeAddTokenFunc() func(context *gin.Context) {
|
||||
return func(context *gin.Context) {
|
||||
info := TokenInfo{
|
||||
Status: true,
|
||||
Enable: true,
|
||||
}
|
||||
response := OperationResponse{
|
||||
Success: true,
|
||||
@@ -312,72 +303,34 @@ func (c *HandleController) MakeAddTokenFunc() func(context *gin.Context) {
|
||||
}
|
||||
err := context.BindJSON(&info)
|
||||
if err != nil {
|
||||
log.Printf("user add failed, param error : %v", err)
|
||||
response.Success = false
|
||||
response.Code = ParamError
|
||||
response.Message = "user add failed, param error "
|
||||
response.Message = fmt.Sprintf("user add failed, param error : %v", err)
|
||||
log.Printf(response.Message)
|
||||
context.JSON(http.StatusOK, &response)
|
||||
return
|
||||
}
|
||||
if !UserFormatReg.MatchString(info.User) {
|
||||
log.Printf("user add failed, user format error")
|
||||
response.Success = false
|
||||
response.Code = UserFormatError
|
||||
response.Message = fmt.Sprintf("user add failed, user format error")
|
||||
context.JSON(http.StatusOK, &response)
|
||||
|
||||
result := c.verifyToken(info, TOKEN_ADD)
|
||||
|
||||
if !result.Success {
|
||||
context.JSON(http.StatusOK, &result)
|
||||
return
|
||||
}
|
||||
if _, exist := c.Tokens[info.User]; exist {
|
||||
log.Printf("user add failed, user [%v] exist", info.User)
|
||||
response.Success = false
|
||||
response.Code = UserExist
|
||||
response.Message = fmt.Sprintf("user add failed, user [%s] exist ", info.User)
|
||||
context.JSON(http.StatusOK, &response)
|
||||
return
|
||||
}
|
||||
if !TokenFormatReg.MatchString(info.Token) {
|
||||
log.Printf("user add failed, token format error")
|
||||
response.Success = false
|
||||
response.Code = TokenFormatError
|
||||
response.Message = fmt.Sprintf("user add failed, token format error")
|
||||
context.JSON(http.StatusOK, &response)
|
||||
return
|
||||
}
|
||||
replaceSpaceToken := TrimAllSpaceReg.ReplaceAllString(info.Token, "")
|
||||
info.Token = replaceSpaceToken
|
||||
|
||||
info.Comment = cleanString(info.Comment)
|
||||
info.Ports = cleanPorts(info.Ports)
|
||||
info.Domains = cleanStrings(info.Domains)
|
||||
info.Subdomains = cleanStrings(info.Subdomains)
|
||||
|
||||
c.Tokens[info.User] = info
|
||||
|
||||
usersSection, _ := c.IniFile.GetSection("users")
|
||||
key, err := usersSection.NewKey(info.User, info.Token)
|
||||
key.Comment = info.Comment
|
||||
|
||||
replaceSpacePorts := TrimAllSpaceReg.ReplaceAllString(info.Ports, "")
|
||||
if len(replaceSpacePorts) != 0 {
|
||||
portsSection, _ := c.IniFile.GetSection("ports")
|
||||
key, err = portsSection.NewKey(info.User, replaceSpacePorts)
|
||||
key.Comment = fmt.Sprintf("user %s allowed ports", info.User)
|
||||
}
|
||||
|
||||
replaceSpaceDomains := TrimAllSpaceReg.ReplaceAllString(info.Domains, "")
|
||||
if len(replaceSpaceDomains) != 0 {
|
||||
domainsSection, _ := c.IniFile.GetSection("domains")
|
||||
key, err = domainsSection.NewKey(info.User, replaceSpaceDomains)
|
||||
key.Comment = fmt.Sprintf("user %s allowed domains", info.User)
|
||||
}
|
||||
|
||||
replaceSpaceSubdomains := TrimAllSpaceReg.ReplaceAllString(info.Subdomains, "")
|
||||
if len(replaceSpaceSubdomains) != 0 {
|
||||
subdomainsSection, _ := c.IniFile.GetSection("subdomains")
|
||||
key, err = subdomainsSection.NewKey(info.User, replaceSpaceSubdomains)
|
||||
key.Comment = fmt.Sprintf("user %s allowed subdomains", info.User)
|
||||
}
|
||||
|
||||
err = c.IniFile.SaveTo(c.ConfigFile)
|
||||
err = c.saveToken()
|
||||
if err != nil {
|
||||
log.Printf("add failed, error : %v", err)
|
||||
response.Success = false
|
||||
response.Code = SaveError
|
||||
response.Message = "user add failed"
|
||||
response.Message = fmt.Sprintf("user add failed, error : %v", err)
|
||||
log.Printf(response.Message)
|
||||
context.JSON(http.StatusOK, &response)
|
||||
return
|
||||
}
|
||||
@@ -396,88 +349,46 @@ func (c *HandleController) MakeUpdateTokensFunc() func(context *gin.Context) {
|
||||
update := TokenUpdate{}
|
||||
err := context.BindJSON(&update)
|
||||
if err != nil {
|
||||
log.Printf("update failed, param error : %v", err)
|
||||
response.Success = false
|
||||
response.Code = ParamError
|
||||
response.Message = "user update failed, param error "
|
||||
response.Message = fmt.Sprintf("update failed, param error : %v", err)
|
||||
log.Printf(response.Message)
|
||||
context.JSON(http.StatusOK, &response)
|
||||
return
|
||||
}
|
||||
|
||||
after := update.After
|
||||
before := update.Before
|
||||
after := update.After
|
||||
|
||||
usersSection, _ := c.IniFile.GetSection("users")
|
||||
key, err := usersSection.GetKey(before.User)
|
||||
comment := TrimBreakLineReg.ReplaceAllString(after.Comment, "")
|
||||
after.Comment = comment
|
||||
key.Comment = comment
|
||||
|
||||
if !TokenFormatReg.MatchString(after.Token) {
|
||||
log.Printf("update failed, token format error")
|
||||
if before.User != after.User {
|
||||
response.Success = false
|
||||
response.Code = TokenFormatError
|
||||
response.Message = "user update failed, token format error "
|
||||
response.Code = ParamError
|
||||
response.Message = fmt.Sprintf("update failed, user should be same : before -> %v, after -> %v", before.User, after.User)
|
||||
log.Printf(response.Message)
|
||||
context.JSON(http.StatusOK, &response)
|
||||
return
|
||||
}
|
||||
replaceSpaceToken := TrimAllSpaceReg.ReplaceAllString(after.Token, "")
|
||||
after.Token = replaceSpaceToken
|
||||
key.SetValue(replaceSpaceToken)
|
||||
|
||||
if before.Ports != after.Ports {
|
||||
portsSection, _ := c.IniFile.GetSection("ports")
|
||||
replaceSpacePorts := TrimAllSpaceReg.ReplaceAllString(after.Ports, "")
|
||||
after.Ports = replaceSpacePorts
|
||||
ports := strings.Split(replaceSpacePorts, ",")
|
||||
if len(replaceSpacePorts) != 0 {
|
||||
key, err = portsSection.NewKey(after.User, replaceSpacePorts)
|
||||
key.Comment = fmt.Sprintf("user %s allowed ports", after.User)
|
||||
c.Ports[after.User] = ports
|
||||
} else {
|
||||
portsSection.DeleteKey(after.User)
|
||||
delete(c.Ports, after.User)
|
||||
}
|
||||
result := c.verifyToken(after, TOKEN_UPDATE)
|
||||
|
||||
if !result.Success {
|
||||
context.JSON(http.StatusOK, &result)
|
||||
return
|
||||
}
|
||||
|
||||
if before.Domains != after.Domains {
|
||||
domainsSection, _ := c.IniFile.GetSection("domains")
|
||||
replaceSpaceDomains := TrimAllSpaceReg.ReplaceAllString(after.Domains, "")
|
||||
after.Domains = replaceSpaceDomains
|
||||
domains := strings.Split(replaceSpaceDomains, ",")
|
||||
if len(replaceSpaceDomains) != 0 {
|
||||
key, err = domainsSection.NewKey(after.User, replaceSpaceDomains)
|
||||
key.Comment = fmt.Sprintf("user %s allowed domains", after.User)
|
||||
c.Domains[after.User] = domains
|
||||
} else {
|
||||
domainsSection.DeleteKey(after.User)
|
||||
delete(c.Domains, after.User)
|
||||
}
|
||||
}
|
||||
|
||||
if before.Subdomains != after.Subdomains {
|
||||
subdomainsSection, _ := c.IniFile.GetSection("subdomains")
|
||||
replaceSpaceSubdomains := TrimAllSpaceReg.ReplaceAllString(after.Subdomains, "")
|
||||
after.Subdomains = replaceSpaceSubdomains
|
||||
subdomains := strings.Split(replaceSpaceSubdomains, ",")
|
||||
if len(replaceSpaceSubdomains) != 0 {
|
||||
key, err = subdomainsSection.NewKey(after.User, replaceSpaceSubdomains)
|
||||
key.Comment = fmt.Sprintf("user %s allowed subdomains", after.User)
|
||||
c.Subdomains[after.User] = subdomains
|
||||
} else {
|
||||
subdomainsSection.DeleteKey(after.User)
|
||||
delete(c.Subdomains, after.User)
|
||||
}
|
||||
}
|
||||
after.Comment = cleanString(after.Comment)
|
||||
after.Ports = cleanPorts(after.Ports)
|
||||
after.Domains = cleanStrings(after.Domains)
|
||||
after.Subdomains = cleanStrings(after.Subdomains)
|
||||
|
||||
c.Tokens[after.User] = after
|
||||
|
||||
err = c.IniFile.SaveTo(c.ConfigFile)
|
||||
err = c.saveToken()
|
||||
if err != nil {
|
||||
log.Printf("user update failed, error : %v", err)
|
||||
response.Success = false
|
||||
response.Code = SaveError
|
||||
response.Message = "user update failed"
|
||||
response.Message = fmt.Sprintf("user update failed, error : %v", err)
|
||||
log.Printf(response.Message)
|
||||
context.JSON(http.StatusOK, &response)
|
||||
return
|
||||
}
|
||||
@@ -496,44 +407,33 @@ func (c *HandleController) MakeRemoveTokensFunc() func(context *gin.Context) {
|
||||
remove := TokenRemove{}
|
||||
err := context.BindJSON(&remove)
|
||||
if err != nil {
|
||||
log.Printf("user remove failed, param error : %v", err)
|
||||
response.Success = false
|
||||
response.Code = ParamError
|
||||
response.Message = "user remove failed, param error "
|
||||
response.Message = fmt.Sprintf("user remove failed, param error : %v", err)
|
||||
log.Printf(response.Message)
|
||||
context.JSON(http.StatusOK, &response)
|
||||
return
|
||||
}
|
||||
|
||||
usersSection, _ := c.IniFile.GetSection("users")
|
||||
for _, user := range remove.Users {
|
||||
result := c.verifyToken(user, TOKEN_REMOVE)
|
||||
|
||||
if !result.Success {
|
||||
context.JSON(http.StatusOK, &result)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
for _, user := range remove.Users {
|
||||
delete(c.Tokens, user.User)
|
||||
usersSection.DeleteKey(user.User)
|
||||
}
|
||||
|
||||
portsSection, _ := c.IniFile.GetSection("ports")
|
||||
for _, user := range remove.Users {
|
||||
delete(c.Ports, user.User)
|
||||
portsSection.DeleteKey(user.User)
|
||||
}
|
||||
|
||||
domainsSection, _ := c.IniFile.GetSection("domains")
|
||||
for _, user := range remove.Users {
|
||||
delete(c.Domains, user.User)
|
||||
domainsSection.DeleteKey(user.User)
|
||||
}
|
||||
|
||||
subdomainsSection, _ := c.IniFile.GetSection("subdomains")
|
||||
for _, user := range remove.Users {
|
||||
delete(c.Subdomains, user.User)
|
||||
subdomainsSection.DeleteKey(user.User)
|
||||
}
|
||||
|
||||
err = c.IniFile.SaveTo(c.ConfigFile)
|
||||
err = c.saveToken()
|
||||
if err != nil {
|
||||
log.Printf("user remove failed, error : %v", err)
|
||||
response.Success = false
|
||||
response.Code = SaveError
|
||||
response.Message = "user remove failed"
|
||||
response.Message = fmt.Sprintf("user update failed, error : %v", err)
|
||||
log.Printf(response.Message)
|
||||
context.JSON(http.StatusOK, &response)
|
||||
return
|
||||
}
|
||||
@@ -552,38 +452,36 @@ func (c *HandleController) MakeDisableTokensFunc() func(context *gin.Context) {
|
||||
disable := TokenDisable{}
|
||||
err := context.BindJSON(&disable)
|
||||
if err != nil {
|
||||
log.Printf("disable failed, param error : %v", err)
|
||||
response.Success = false
|
||||
response.Code = ParamError
|
||||
response.Message = "disable failed, param error "
|
||||
response.Message = fmt.Sprintf("disable failed, param error : %v", err)
|
||||
log.Printf(response.Message)
|
||||
context.JSON(http.StatusOK, &response)
|
||||
return
|
||||
}
|
||||
|
||||
section, _ := c.IniFile.GetSection("disabled")
|
||||
for _, user := range disable.Users {
|
||||
section.DeleteKey(user.User)
|
||||
token := c.Tokens[user.User]
|
||||
token.Status = false
|
||||
c.Tokens[user.User] = token
|
||||
key, err := section.NewKey(user.User, "disable")
|
||||
if err != nil {
|
||||
log.Printf("disable failed, error : %v", err)
|
||||
response.Success = false
|
||||
response.Code = SaveError
|
||||
response.Message = "disable failed"
|
||||
context.JSON(http.StatusOK, &response)
|
||||
result := c.verifyToken(user, TOKEN_DISABLE)
|
||||
|
||||
if !result.Success {
|
||||
context.JSON(http.StatusOK, &result)
|
||||
return
|
||||
}
|
||||
key.Comment = fmt.Sprintf("disable user '%s'", user.User)
|
||||
}
|
||||
|
||||
err = c.IniFile.SaveTo(c.ConfigFile)
|
||||
for _, user := range disable.Users {
|
||||
token := c.Tokens[user.User]
|
||||
token.Enable = false
|
||||
c.Tokens[user.User] = token
|
||||
}
|
||||
|
||||
err = c.saveToken()
|
||||
|
||||
if err != nil {
|
||||
log.Printf("disable failed, error : %v", err)
|
||||
response.Success = false
|
||||
response.Code = SaveError
|
||||
response.Message = "disable failed"
|
||||
response.Message = fmt.Sprintf("disable failed, error : %v", err)
|
||||
log.Printf(response.Message)
|
||||
context.JSON(http.StatusOK, &response)
|
||||
return
|
||||
}
|
||||
@@ -602,23 +500,31 @@ func (c *HandleController) MakeEnableTokensFunc() func(context *gin.Context) {
|
||||
enable := TokenEnable{}
|
||||
err := context.BindJSON(&enable)
|
||||
if err != nil {
|
||||
log.Printf("enable failed, param error : %v", err)
|
||||
response.Success = false
|
||||
response.Code = ParamError
|
||||
response.Message = "enable failed, param error "
|
||||
response.Message = fmt.Sprintf("enable failed, param error : %v", err)
|
||||
log.Printf(response.Message)
|
||||
context.JSON(http.StatusOK, &response)
|
||||
return
|
||||
}
|
||||
|
||||
section, _ := c.IniFile.GetSection("disabled")
|
||||
for _, user := range enable.Users {
|
||||
section.DeleteKey(user.User)
|
||||
result := c.verifyToken(user, TOKEN_ENABLE)
|
||||
|
||||
if !result.Success {
|
||||
context.JSON(http.StatusOK, &result)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
for _, user := range enable.Users {
|
||||
token := c.Tokens[user.User]
|
||||
token.Status = true
|
||||
token.Enable = true
|
||||
c.Tokens[user.User] = token
|
||||
}
|
||||
|
||||
err = c.IniFile.SaveTo(c.ConfigFile)
|
||||
err = c.saveToken()
|
||||
|
||||
if err != nil {
|
||||
log.Printf("enable failed, error : %v", err)
|
||||
response.Success = false
|
||||
@@ -631,3 +537,73 @@ func (c *HandleController) MakeEnableTokensFunc() func(context *gin.Context) {
|
||||
context.JSON(http.StatusOK, &response)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *HandleController) MakeProxyFunc() func(context *gin.Context) {
|
||||
return func(context *gin.Context) {
|
||||
var client *http.Client
|
||||
var protocol string
|
||||
|
||||
if c.CommonInfo.DashboardTls {
|
||||
client = &http.Client{
|
||||
Transport: &http.Transport{
|
||||
TLSClientConfig: &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
protocol = "https://"
|
||||
} else {
|
||||
client = http.DefaultClient
|
||||
protocol = "http://"
|
||||
}
|
||||
|
||||
res := ProxyResponse{}
|
||||
host := c.CommonInfo.DashboardAddr
|
||||
port := c.CommonInfo.DashboardPort
|
||||
|
||||
host, _ = strings.CutPrefix(host, protocol)
|
||||
|
||||
requestUrl := protocol + host + ":" + strconv.Itoa(port) + context.Param("serverApi")
|
||||
request, _ := http.NewRequest("GET", requestUrl, nil)
|
||||
username := c.CommonInfo.DashboardUser
|
||||
password := c.CommonInfo.DashboardPwd
|
||||
if trimString(username) != "" && trimString(password) != "" {
|
||||
request.SetBasicAuth(username, password)
|
||||
log.Printf("Proxy to %s", requestUrl)
|
||||
}
|
||||
|
||||
response, err := client.Do(request)
|
||||
|
||||
if err != nil {
|
||||
res.Code = FrpServerError
|
||||
res.Success = false
|
||||
res.Message = err.Error()
|
||||
log.Print(err)
|
||||
context.JSON(http.StatusOK, &res)
|
||||
return
|
||||
}
|
||||
|
||||
res.Code = response.StatusCode
|
||||
body, err := io.ReadAll(response.Body)
|
||||
|
||||
if err != nil {
|
||||
res.Success = false
|
||||
res.Message = err.Error()
|
||||
} else {
|
||||
if res.Code == http.StatusOK {
|
||||
res.Success = true
|
||||
res.Data = string(body)
|
||||
res.Message = fmt.Sprintf("Proxy to %s success", requestUrl)
|
||||
} else {
|
||||
res.Success = false
|
||||
if res.Code == http.StatusNotFound {
|
||||
res.Message = fmt.Sprintf("Proxy to %s error: url not found", requestUrl)
|
||||
} else {
|
||||
res.Message = fmt.Sprintf("Proxy to %s error: %s", requestUrl, string(body))
|
||||
}
|
||||
}
|
||||
}
|
||||
log.Printf(res.Message)
|
||||
context.JSON(http.StatusOK, &res)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,51 +3,11 @@ package controller
|
||||
import (
|
||||
"fmt"
|
||||
plugin "github.com/fatedier/frp/pkg/plugin/server"
|
||||
"github.com/gin-gonic/gin"
|
||||
"gopkg.in/ini.v1"
|
||||
"log"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type HandleController struct {
|
||||
CommonInfo CommonInfo
|
||||
Tokens map[string]TokenInfo
|
||||
Ports map[string][]string
|
||||
Domains map[string][]string
|
||||
Subdomains map[string][]string
|
||||
ConfigFile string
|
||||
IniFile *ini.File
|
||||
}
|
||||
|
||||
func NewHandleController(config *HandleController) *HandleController {
|
||||
return config
|
||||
}
|
||||
|
||||
func (c *HandleController) Register(engine *gin.Engine) {
|
||||
engine.Delims("${", "}")
|
||||
engine.LoadHTMLGlob("./assets/templates/*")
|
||||
engine.POST("/handler", c.MakeHandlerFunc())
|
||||
|
||||
var group *gin.RouterGroup
|
||||
if len(c.CommonInfo.User) != 0 {
|
||||
group = engine.Group("/", gin.BasicAuthForRealm(gin.Accounts{
|
||||
c.CommonInfo.User: c.CommonInfo.Pwd,
|
||||
}, "Restricted"))
|
||||
} else {
|
||||
group = engine.Group("/")
|
||||
}
|
||||
group.Static("/static", "./assets/static")
|
||||
group.GET("/", c.MakeManagerFunc())
|
||||
group.GET("/lang", c.MakeLangFunc())
|
||||
group.GET("/tokens", c.MakeQueryTokensFunc())
|
||||
group.POST("/add", c.MakeAddTokenFunc())
|
||||
group.POST("/update", c.MakeUpdateTokensFunc())
|
||||
group.POST("/remove", c.MakeRemoveTokensFunc())
|
||||
group.POST("/disable", c.MakeDisableTokensFunc())
|
||||
group.POST("/enable", c.MakeEnableTokensFunc())
|
||||
}
|
||||
|
||||
func (c *HandleController) HandleLogin(content *plugin.LoginContent) plugin.Response {
|
||||
token := content.Metas["token"]
|
||||
user := content.User
|
||||
@@ -90,7 +50,7 @@ func (c *HandleController) JudgeToken(user string, token string) plugin.Response
|
||||
res.Reject = true
|
||||
res.RejectReason = "user or meta token can not be empty"
|
||||
} else if info, exist := c.Tokens[user]; exist {
|
||||
if !info.Status {
|
||||
if !info.Enable {
|
||||
res.Reject = true
|
||||
res.RejectReason = fmt.Sprintf("user [%s] is disabled", user)
|
||||
} else {
|
||||
@@ -117,8 +77,7 @@ func (c *HandleController) JudgePort(content *plugin.NewProxyContent) plugin.Res
|
||||
"tcp", "tcpmux", "udp", "http", "https",
|
||||
}
|
||||
proxyType := content.ProxyType
|
||||
|
||||
if StringIndexOf(proxyType, supportProxyTypes) == -1 {
|
||||
if !stringContains(proxyType, supportProxyTypes) {
|
||||
log.Printf("proxy type [%v] not support, plugin do nothing", proxyType)
|
||||
res.Unchange = true
|
||||
return res
|
||||
@@ -132,20 +91,21 @@ func (c *HandleController) JudgePort(content *plugin.NewProxyContent) plugin.Res
|
||||
portAllowed := true
|
||||
if proxyType == "tcp" || proxyType == "udp" {
|
||||
portAllowed = false
|
||||
if _, exist := c.Ports[user]; exist {
|
||||
for _, port := range c.Ports[user] {
|
||||
if strings.Contains(port, "-") {
|
||||
allowedRanges := strings.Split(port, "-")
|
||||
if token, exist := c.Tokens[user]; exist {
|
||||
for _, port := range token.Ports {
|
||||
if str, ok := port.(string); ok {
|
||||
if strings.Contains(str, "-") {
|
||||
allowedRanges := strings.Split(str, "-")
|
||||
if len(allowedRanges) != 2 {
|
||||
portErr = fmt.Errorf("user [%v] port range [%v] format error", user, port)
|
||||
break
|
||||
}
|
||||
start, err := strconv.Atoi(strings.TrimSpace(allowedRanges[0]))
|
||||
start, err := strconv.Atoi(trimString(allowedRanges[0]))
|
||||
if err != nil {
|
||||
portErr = fmt.Errorf("user [%v] port rang [%v] start port [%v] is not a number", user, port, allowedRanges[0])
|
||||
break
|
||||
}
|
||||
end, err := strconv.Atoi(strings.TrimSpace(allowedRanges[1]))
|
||||
end, err := strconv.Atoi(trimString(allowedRanges[1]))
|
||||
if err != nil {
|
||||
portErr = fmt.Errorf("user [%v] port rang [%v] end port [%v] is not a number", user, port, allowedRanges[0])
|
||||
break
|
||||
@@ -155,7 +115,11 @@ func (c *HandleController) JudgePort(content *plugin.NewProxyContent) plugin.Res
|
||||
break
|
||||
}
|
||||
} else {
|
||||
allowed, err := strconv.Atoi(port)
|
||||
if str == "" {
|
||||
portAllowed = true
|
||||
break
|
||||
}
|
||||
allowed, err := strconv.Atoi(str)
|
||||
if err != nil {
|
||||
portErr = fmt.Errorf("user [%v] allowed port [%v] is not a number", user, port)
|
||||
}
|
||||
@@ -164,6 +128,14 @@ func (c *HandleController) JudgePort(content *plugin.NewProxyContent) plugin.Res
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
allowed := port
|
||||
if allowed == userPort {
|
||||
portAllowed = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
portAllowed = true
|
||||
@@ -179,14 +151,18 @@ func (c *HandleController) JudgePort(content *plugin.NewProxyContent) plugin.Res
|
||||
domainAllowed := true
|
||||
if proxyType == "http" || proxyType == "https" || proxyType == "tcpmux" {
|
||||
if portAllowed {
|
||||
if _, exist := c.Domains[user]; exist {
|
||||
if token, exist := c.Tokens[user]; exist {
|
||||
if stringContains("", token.Domains) {
|
||||
domainAllowed = true
|
||||
} else {
|
||||
for _, userDomain := range userDomains {
|
||||
if StringIndexOf(userDomain, c.Domains[user]) == -1 {
|
||||
if !stringContains(userDomain, token.Domains) {
|
||||
domainAllowed = false
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if !domainAllowed {
|
||||
portErr = fmt.Errorf("user [%v] domain [%v] is not allowed", user, strings.Join(userDomains, ","))
|
||||
reject = true
|
||||
@@ -198,13 +174,17 @@ func (c *HandleController) JudgePort(content *plugin.NewProxyContent) plugin.Res
|
||||
if proxyType == "http" || proxyType == "https" {
|
||||
subdomainAllowed = false
|
||||
if portAllowed && domainAllowed {
|
||||
if _, exist := c.Subdomains[user]; exist {
|
||||
for _, subdomain := range c.Subdomains[user] {
|
||||
if token, exist := c.Tokens[user]; exist {
|
||||
if stringContains("", token.Subdomains) {
|
||||
subdomainAllowed = true
|
||||
} else {
|
||||
for _, subdomain := range token.Subdomains {
|
||||
if subdomain == userSubdomain {
|
||||
subdomainAllowed = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
subdomainAllowed = true
|
||||
}
|
||||
@@ -223,12 +203,3 @@ func (c *HandleController) JudgePort(content *plugin.NewProxyContent) plugin.Res
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func StringIndexOf(element string, data []string) int {
|
||||
for k, v := range data {
|
||||
if element == v {
|
||||
return k
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
54
pkg/server/controller/register.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
type HandleController struct {
|
||||
CommonInfo CommonInfo
|
||||
Tokens map[string]TokenInfo
|
||||
Version string
|
||||
ConfigFile string
|
||||
TokensFile string
|
||||
}
|
||||
|
||||
func NewHandleController(config *HandleController) *HandleController {
|
||||
return config
|
||||
}
|
||||
|
||||
func (c *HandleController) Register(rootDir string, engine *gin.Engine) {
|
||||
assets := filepath.Join(rootDir, "assets")
|
||||
_, err := os.Stat(assets)
|
||||
if err != nil && !os.IsExist(err) {
|
||||
assets = "./assets"
|
||||
}
|
||||
|
||||
engine.Delims("${", "}")
|
||||
engine.LoadHTMLGlob(filepath.Join(assets, "templates/*"))
|
||||
engine.POST("/handler", c.MakeHandlerFunc())
|
||||
engine.Static("/static", filepath.Join(assets, "static"))
|
||||
engine.GET("/lang.json", c.MakeLangFunc())
|
||||
engine.GET(LoginUrl, c.MakeLoginFunc())
|
||||
engine.POST(LoginUrl, c.MakeLoginFunc())
|
||||
engine.GET(LogoutUrl, c.MakeLogoutFunc())
|
||||
|
||||
var group *gin.RouterGroup
|
||||
if len(c.CommonInfo.AdminUser) != 0 {
|
||||
//group = engine.Group("/", gin.BasicAuthForRealm(gin.Accounts{
|
||||
// c.CommonInfo.User: c.CommonInfo.Pwd,
|
||||
//}, "Restricted"))
|
||||
group = engine.Group("/", c.BasicAuth())
|
||||
} else {
|
||||
group = engine.Group("/")
|
||||
}
|
||||
group.GET("/", c.MakeIndexFunc())
|
||||
group.GET("/tokens", c.MakeQueryTokensFunc())
|
||||
group.POST("/add", c.MakeAddTokenFunc())
|
||||
group.POST("/update", c.MakeUpdateTokensFunc())
|
||||
group.POST("/remove", c.MakeRemoveTokensFunc())
|
||||
group.POST("/disable", c.MakeDisableTokensFunc())
|
||||
group.POST("/enable", c.MakeEnableTokensFunc())
|
||||
group.GET("/proxy/*serverApi", c.MakeProxyFunc())
|
||||
}
|
||||
222
pkg/server/controller/utils.go
Normal file
@@ -0,0 +1,222 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/BurntSushi/toml"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func filter(main TokenInfo, sub TokenInfo) bool {
|
||||
replaceSpaceUser := trimAllSpace.ReplaceAllString(sub.User, "")
|
||||
if len(replaceSpaceUser) != 0 {
|
||||
if !strings.Contains(main.User, replaceSpaceUser) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
replaceSpaceToken := trimAllSpace.ReplaceAllString(sub.Token, "")
|
||||
if len(replaceSpaceToken) != 0 {
|
||||
if !strings.Contains(main.Token, replaceSpaceToken) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
replaceSpaceComment := trimAllSpace.ReplaceAllString(sub.Comment, "")
|
||||
if len(replaceSpaceComment) != 0 {
|
||||
if !strings.Contains(main.Comment, replaceSpaceComment) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func trimString(str string) string {
|
||||
return strings.TrimSpace(str)
|
||||
}
|
||||
|
||||
func (c *HandleController) verifyToken(token TokenInfo, operate int) OperationResponse {
|
||||
response := OperationResponse{
|
||||
Success: true,
|
||||
Code: Success,
|
||||
Message: "operate success",
|
||||
}
|
||||
|
||||
var (
|
||||
validateExist = false
|
||||
validateNotExist = false
|
||||
validateUser = false
|
||||
validateToken = false
|
||||
validateComment = false
|
||||
validatePorts = false
|
||||
validateDomains = false
|
||||
validateSubdomains = false
|
||||
)
|
||||
|
||||
if operate == TOKEN_ADD {
|
||||
validateExist = true
|
||||
validateUser = true
|
||||
validateToken = true
|
||||
validateComment = true
|
||||
validatePorts = true
|
||||
validateDomains = true
|
||||
validateSubdomains = true
|
||||
} else if operate == TOKEN_UPDATE {
|
||||
validateNotExist = true
|
||||
validateUser = true
|
||||
validateToken = true
|
||||
validateComment = true
|
||||
validatePorts = true
|
||||
validateDomains = true
|
||||
validateSubdomains = true
|
||||
} else if operate == TOKEN_ENABLE || operate == TOKEN_DISABLE || operate == TOKEN_REMOVE {
|
||||
validateNotExist = true
|
||||
}
|
||||
|
||||
if validateUser && !userFormat.MatchString(token.User) {
|
||||
response.Success = false
|
||||
response.Code = UserFormatError
|
||||
response.Message = fmt.Sprintf("operate failed, user [%s] format error", token.User)
|
||||
log.Printf(response.Message)
|
||||
return response
|
||||
}
|
||||
|
||||
if validateExist {
|
||||
if _, exist := c.Tokens[token.User]; exist {
|
||||
response.Success = false
|
||||
response.Code = UserExist
|
||||
response.Message = fmt.Sprintf("operate failed, user [%s] exist ", token.User)
|
||||
log.Printf(response.Message)
|
||||
return response
|
||||
}
|
||||
}
|
||||
|
||||
if validateNotExist {
|
||||
if _, exist := c.Tokens[token.User]; !exist {
|
||||
response.Success = false
|
||||
response.Code = UserNotExist
|
||||
response.Message = fmt.Sprintf("operate failed, user [%s] not exist ", token.User)
|
||||
log.Printf(response.Message)
|
||||
return response
|
||||
}
|
||||
}
|
||||
|
||||
if validateToken && !tokenFormat.MatchString(token.Token) {
|
||||
response.Success = false
|
||||
response.Code = TokenFormatError
|
||||
response.Message = fmt.Sprintf("operate failed, token [%s] format error", token.Token)
|
||||
log.Printf(response.Message)
|
||||
return response
|
||||
}
|
||||
|
||||
trimmedComment := trimString(token.Comment)
|
||||
if validateComment && trimmedComment != "" && commentFormat.MatchString(trimmedComment) {
|
||||
response.Success = false
|
||||
response.Code = CommentFormatError
|
||||
response.Message = fmt.Sprintf("operate failed, comment [%s] format error", token.Comment)
|
||||
log.Printf(response.Message)
|
||||
return response
|
||||
}
|
||||
|
||||
if validatePorts {
|
||||
for _, port := range token.Ports {
|
||||
if str, ok := port.(string); ok {
|
||||
trimmedPort := trimString(str)
|
||||
if trimmedPort != "" && !portsFormatSingle.MatchString(trimmedPort) && !portsFormatRange.MatchString(trimmedPort) {
|
||||
response.Success = false
|
||||
response.Code = PortsFormatError
|
||||
response.Message = fmt.Sprintf("operate failed, ports [%v] format error", token.Ports)
|
||||
log.Printf(response.Message)
|
||||
return response
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if validateDomains {
|
||||
for _, domain := range token.Domains {
|
||||
trimmedDomain := trimString(domain)
|
||||
if trimmedDomain != "" && !domainFormat.MatchString(trimmedDomain) {
|
||||
response.Success = false
|
||||
response.Code = DomainsFormatError
|
||||
response.Message = fmt.Sprintf("operate failed, domains [%v] format error", token.Domains)
|
||||
log.Printf(response.Message)
|
||||
return response
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if validateSubdomains {
|
||||
for _, subdomain := range token.Subdomains {
|
||||
trimmedSubdomain := trimString(subdomain)
|
||||
if trimmedSubdomain != "" && !subdomainFormat.MatchString(trimmedSubdomain) {
|
||||
response.Success = false
|
||||
response.Code = SubdomainsFormatError
|
||||
response.Message = fmt.Sprintf("operate failed, subdomains [%v] format error", token.Subdomains)
|
||||
log.Printf(response.Message)
|
||||
return response
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return response
|
||||
}
|
||||
|
||||
func cleanPorts(ports []any) []any {
|
||||
cleanedPorts := make([]any, len(ports))
|
||||
for i, port := range ports {
|
||||
if str, ok := port.(string); ok {
|
||||
cleanedPorts[i] = cleanString(str)
|
||||
} else {
|
||||
//float64, for JSON numbers
|
||||
cleanedPorts[i] = int(port.(float64))
|
||||
}
|
||||
}
|
||||
return cleanedPorts
|
||||
}
|
||||
|
||||
func cleanStrings(originalStrings []string) []string {
|
||||
cleanedStrings := make([]string, len(originalStrings))
|
||||
for i, str := range originalStrings {
|
||||
cleanedStrings[i] = cleanString(str)
|
||||
}
|
||||
return cleanedStrings
|
||||
}
|
||||
|
||||
func cleanString(originalString string) string {
|
||||
return trimString(originalString)
|
||||
}
|
||||
|
||||
func stringContains(element string, data []string) bool {
|
||||
for _, v := range data {
|
||||
if element == v {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func tokensList(tokens map[string]TokenInfo) Tokens {
|
||||
return Tokens{
|
||||
tokens,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *HandleController) saveToken() error {
|
||||
tokenFile, err := os.Create(c.TokensFile)
|
||||
if err != nil {
|
||||
log.Printf("error to crate file %v: %v", c.TokensFile, err)
|
||||
}
|
||||
|
||||
encoder := toml.NewEncoder(tokenFile)
|
||||
encoder.Indent = " "
|
||||
if err = encoder.Encode(tokensList(c.Tokens)); err != nil {
|
||||
log.Printf("error to encode tokens: %v", err)
|
||||
}
|
||||
if err = tokenFile.Close(); err != nil {
|
||||
log.Printf("error to close file %v: %v", c.TokensFile, err)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
136
pkg/server/controller/variables.go
Normal file
@@ -0,0 +1,136 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
)
|
||||
|
||||
const (
|
||||
Success int = iota
|
||||
ParamError
|
||||
UserExist
|
||||
UserNotExist
|
||||
SaveError
|
||||
UserFormatError
|
||||
TokenFormatError
|
||||
CommentFormatError
|
||||
PortsFormatError
|
||||
DomainsFormatError
|
||||
SubdomainsFormatError
|
||||
FrpServerError
|
||||
)
|
||||
|
||||
const (
|
||||
TOKEN_ADD int = iota
|
||||
TOKEN_UPDATE
|
||||
TOKEN_REMOVE
|
||||
TOKEN_ENABLE
|
||||
TOKEN_DISABLE
|
||||
)
|
||||
|
||||
const (
|
||||
SessionName = "GOSESSION"
|
||||
AuthName = "_PANEL_AUTH"
|
||||
LoginUrl = "/login"
|
||||
LoginSuccessUrl = "/"
|
||||
LogoutUrl = "/logout"
|
||||
LogoutSuccessUrl = "/login"
|
||||
)
|
||||
|
||||
var (
|
||||
userFormat = regexp.MustCompile("^\\w+$")
|
||||
tokenFormat = regexp.MustCompile("^[\\w!@#$%^&*()]+$")
|
||||
commentFormat = regexp.MustCompile("[\\n\\t\\r]")
|
||||
portsFormatSingle = regexp.MustCompile("^\\s*\\d{1,5}\\s*$")
|
||||
portsFormatRange = regexp.MustCompile("^\\s*\\d{1,5}\\s*-\\s*\\d{1,5}\\s*$")
|
||||
domainFormat = regexp.MustCompile("^([a-zA-Z0-9]+(-[a-zA-Z0-9]+)*\\.)+[a-zA-Z]{2,}$")
|
||||
subdomainFormat = regexp.MustCompile("^[a-zA-z0-9-]{1,20}$")
|
||||
trimAllSpace = regexp.MustCompile("[\\n\\t\\r\\s]")
|
||||
)
|
||||
|
||||
type Response struct {
|
||||
Msg string `json:"msg"`
|
||||
}
|
||||
|
||||
type HTTPError struct {
|
||||
Code int
|
||||
Err error
|
||||
}
|
||||
|
||||
type Common struct {
|
||||
Common CommonInfo
|
||||
}
|
||||
|
||||
type CommonInfo struct {
|
||||
PluginAddr string `toml:"plugin_addr"`
|
||||
PluginPort int `toml:"plugin_port"`
|
||||
AdminUser string `toml:"admin_user"`
|
||||
AdminPwd string `toml:"admin_pwd"`
|
||||
AdminKeepTime int `toml:"admin_keep_time"`
|
||||
TlsMode bool `toml:"tls_mode"`
|
||||
TlsCertFile string `toml:"tls_cert_file"`
|
||||
TlsKeyFile string `toml:"tls_key_file"`
|
||||
DashboardAddr string `toml:"dashboard_addr"`
|
||||
DashboardPort int `toml:"dashboard_port"`
|
||||
DashboardUser string `toml:"dashboard_user"`
|
||||
DashboardPwd string `toml:"dashboard_pwd"`
|
||||
DashboardTls bool
|
||||
}
|
||||
|
||||
type Tokens struct {
|
||||
Tokens map[string]TokenInfo `toml:"tokens"`
|
||||
}
|
||||
|
||||
type TokenInfo struct {
|
||||
User string `toml:"user" json:"user" form:"user"`
|
||||
Token string `toml:"token" json:"token" form:"token"`
|
||||
Comment string `toml:"comment" json:"comment" form:"comment"`
|
||||
Ports []any `toml:"ports" json:"ports" from:"ports"`
|
||||
Domains []string `toml:"domains" json:"domains" from:"domains"`
|
||||
Subdomains []string `toml:"subdomains" json:"subdomains" from:"subdomains"`
|
||||
Enable bool `toml:"enable" json:"enable" form:"enable"`
|
||||
}
|
||||
|
||||
type TokenResponse struct {
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Count int `json:"count"`
|
||||
Data []TokenInfo `json:"data"`
|
||||
}
|
||||
|
||||
type OperationResponse struct {
|
||||
Success bool `json:"success"`
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
type ProxyResponse struct {
|
||||
OperationResponse
|
||||
Data string `json:"data"`
|
||||
}
|
||||
|
||||
type TokenSearch struct {
|
||||
TokenInfo
|
||||
Page int `form:"page"`
|
||||
Limit int `form:"limit"`
|
||||
}
|
||||
|
||||
type TokenUpdate struct {
|
||||
Before TokenInfo `json:"before"`
|
||||
After TokenInfo `json:"after"`
|
||||
}
|
||||
|
||||
type TokenRemove struct {
|
||||
Users []TokenInfo `json:"users"`
|
||||
}
|
||||
|
||||
type TokenDisable struct {
|
||||
TokenRemove
|
||||
}
|
||||
|
||||
type TokenEnable struct {
|
||||
TokenDisable
|
||||
}
|
||||
|
||||
func (e *HTTPError) Error() string {
|
||||
return e.Err.Error()
|
||||
}
|
||||
@@ -5,14 +5,17 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"frps-multiuser/pkg/server/controller"
|
||||
"frps-panel/pkg/server/controller"
|
||||
ginI18n "github.com/gin-contrib/i18n"
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-contrib/sessions/cookie"
|
||||
"github.com/gin-gonic/gin"
|
||||
"golang.org/x/text/language"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -21,14 +24,26 @@ import (
|
||||
type Server struct {
|
||||
cfg controller.HandleController
|
||||
s *http.Server
|
||||
tls TLS
|
||||
done chan struct{}
|
||||
rootDir string
|
||||
}
|
||||
|
||||
func New(cfg controller.HandleController) (*Server, error) {
|
||||
type TLS struct {
|
||||
Enable bool
|
||||
Cert string
|
||||
Key string
|
||||
Protocol string
|
||||
}
|
||||
|
||||
func New(rootDir string, cfg controller.HandleController, tls TLS) (*Server, error) {
|
||||
s := &Server{
|
||||
cfg: cfg,
|
||||
done: make(chan struct{}),
|
||||
rootDir: rootDir,
|
||||
tls: tls,
|
||||
}
|
||||
|
||||
if err := s.init(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -41,10 +56,32 @@ func (s *Server) Run() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Printf("HTTP server listen on %s", l.Addr().String())
|
||||
log.Printf("%s server listen on %s", s.tls.Protocol, l.Addr().String())
|
||||
go func() {
|
||||
if s.tls.Enable {
|
||||
configDir := filepath.Dir(s.cfg.ConfigFile)
|
||||
|
||||
cert := filepath.Join(configDir, s.tls.Cert)
|
||||
_, err := os.Stat(cert)
|
||||
if err != nil && !os.IsExist(err) {
|
||||
cert = s.tls.Cert
|
||||
}
|
||||
|
||||
key := filepath.Join(configDir, s.tls.Key)
|
||||
_, err = os.Stat(key)
|
||||
if err != nil && !os.IsExist(err) {
|
||||
key = s.tls.Key
|
||||
}
|
||||
|
||||
if err = s.s.ServeTLS(l, cert, key); !errors.Is(http.ErrServerClosed, err) {
|
||||
log.Printf("error shutdown %s server: %v", s.tls.Protocol, err)
|
||||
_ = s.Stop()
|
||||
}
|
||||
} else {
|
||||
if err = s.s.Serve(l); !errors.Is(http.ErrServerClosed, err) {
|
||||
log.Printf("error shutdown HTTP server: %v", err)
|
||||
log.Printf("error shutdown %s server: %v", s.tls.Protocol, err)
|
||||
_ = s.Stop()
|
||||
}
|
||||
}
|
||||
}()
|
||||
<-s.done
|
||||
@@ -55,16 +92,17 @@ func (s *Server) Stop() error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
if err := s.s.Shutdown(ctx); err != nil {
|
||||
log.Fatalf("shutdown HTTP server error: %v", err)
|
||||
log.Fatalf("shutdown %s server error: %v", s.tls.Protocol, err)
|
||||
}
|
||||
log.Printf("HTTP server exited")
|
||||
log.Printf("%s server exited", s.tls.Protocol)
|
||||
|
||||
close(s.done)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Server) init() error {
|
||||
if err := s.initHTTPServer(); err != nil {
|
||||
log.Printf("init HTTP server error: %v", err)
|
||||
log.Printf("init %s server error: %v", s.tls.Protocol, err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
@@ -74,14 +112,10 @@ func LoadSupportLanguage(dir string) ([]language.Tag, error) {
|
||||
var tags []language.Tag
|
||||
|
||||
files, err := os.Open(dir)
|
||||
if err != nil {
|
||||
log.Printf("error opening directory: %v", err)
|
||||
return tags, err
|
||||
}
|
||||
|
||||
fileList, err := files.Readdir(-1)
|
||||
if err != nil {
|
||||
log.Printf("error reading directory: %v", err)
|
||||
log.Printf("error read lang directory: %v", err)
|
||||
return tags, err
|
||||
}
|
||||
|
||||
@@ -103,15 +137,21 @@ func LoadSupportLanguage(dir string) ([]language.Tag, error) {
|
||||
return tags, nil
|
||||
}
|
||||
|
||||
func GinI18nLocalize() gin.HandlerFunc {
|
||||
dir := "./assets/lang"
|
||||
tags, err := LoadSupportLanguage(dir)
|
||||
func GinI18nLocalize(rootDir string) gin.HandlerFunc {
|
||||
assets := filepath.Join(rootDir, "assets")
|
||||
_, err := os.Stat(assets)
|
||||
if err != nil && !os.IsExist(err) {
|
||||
assets = "./assets"
|
||||
}
|
||||
lang := filepath.Join(assets, "lang")
|
||||
tags, err := LoadSupportLanguage(lang)
|
||||
if err != nil {
|
||||
log.Panicf("language file is not found: %v", err)
|
||||
}
|
||||
|
||||
return ginI18n.Localize(
|
||||
ginI18n.WithBundle(&ginI18n.BundleCfg{
|
||||
RootPath: dir,
|
||||
RootPath: lang,
|
||||
AcceptLanguage: tags,
|
||||
DefaultLanguage: language.Chinese,
|
||||
FormatBundleFile: "json",
|
||||
@@ -133,10 +173,19 @@ func GinI18nLocalize() gin.HandlerFunc {
|
||||
func (s *Server) initHTTPServer() error {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
engine := gin.New()
|
||||
engine.Use(GinI18nLocalize())
|
||||
authStore := cookie.NewStore([]byte("frps-panel"))
|
||||
authStore.Options(sessions.Options{
|
||||
Secure: false,
|
||||
HttpOnly: false,
|
||||
SameSite: http.SameSiteDefaultMode,
|
||||
Path: "/",
|
||||
MaxAge: s.cfg.CommonInfo.AdminKeepTime,
|
||||
})
|
||||
engine.Use(sessions.Sessions(controller.SessionName, authStore))
|
||||
engine.Use(GinI18nLocalize(s.rootDir))
|
||||
s.s = &http.Server{
|
||||
Handler: engine,
|
||||
}
|
||||
controller.NewHandleController(&s.cfg).Register(engine)
|
||||
controller.NewHandleController(&s.cfg).Register(s.rootDir, engine)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 147 KiB After Width: | Height: | Size: 263 KiB |
|
Before Width: | Height: | Size: 129 KiB After Width: | Height: | Size: 228 KiB |
BIN
screenshots/login.png
Normal file
|
After Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 327 KiB After Width: | Height: | Size: 317 KiB |
BIN
screenshots/proxy list.png
Normal file
|
After Width: | Height: | Size: 224 KiB |
BIN
screenshots/proxy traffic statistics.png
Normal file
|
After Width: | Height: | Size: 285 KiB |
BIN
screenshots/server info.png
Normal file
|
After Width: | Height: | Size: 238 KiB |
|
Before Width: | Height: | Size: 143 KiB After Width: | Height: | Size: 166 KiB |