mirror of
https://github.com/yhl452493373/frpc-panel.git
synced 2026-04-04 06:17:00 +08:00
first commit:add basic layout
This commit is contained in:
12
Makefile
Normal file
12
Makefile
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
export GO111MODULE=on
|
||||||
|
export CGO_ENABLED=0
|
||||||
|
export GOOS=linux
|
||||||
|
export GOARCH=amd64
|
||||||
|
|
||||||
|
build: frpc-panel
|
||||||
|
cp ./config/frpc-panel.toml ./bin/frpc-panel.toml
|
||||||
|
cp -r ./assets/ ./bin/assets/
|
||||||
|
|
||||||
|
frpc-panel:
|
||||||
|
rm -rf ./bin
|
||||||
|
go build -o ./bin/frpc-panel ./cmd/frpc-panel
|
||||||
24
Makefile.cross-compiles
Normal file
24
Makefile.cross-compiles
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
export GO111MODULE=on
|
||||||
|
LDFLAGS := -s -w
|
||||||
|
|
||||||
|
package: copy
|
||||||
|
sh ./package.sh
|
||||||
|
|
||||||
|
copy: build
|
||||||
|
cp ./config/frpc-panel.toml ./release/frpc-panel.toml
|
||||||
|
cp -r ./assets/ ./release/assets/
|
||||||
|
|
||||||
|
build:
|
||||||
|
env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o ./release/frpc-panel-darwin-amd64 ./cmd/frpc-panel
|
||||||
|
env CGO_ENABLED=0 GOOS=freebsd GOARCH=386 go build -ldflags "$(LDFLAGS)" -o ./release/frpc-panel-freebsd-386 ./cmd/frpc-panel
|
||||||
|
env CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o ./release/frpc-panel-freebsd-amd64 ./cmd/frpc-panel
|
||||||
|
env CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags "$(LDFLAGS)" -o ./release/frpc-panel-linux-386 ./cmd/frpc-panel
|
||||||
|
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o ./release/frpc-panel-linux-amd64 ./cmd/frpc-panel
|
||||||
|
env CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -ldflags "$(LDFLAGS)" -o ./release/frpc-panel-linux-arm ./cmd/frpc-panel
|
||||||
|
env CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -o ./release/frpc-panel-linux-arm64 ./cmd/frpc-panel
|
||||||
|
env CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags "$(LDFLAGS)" -o ./release/frpc-panel-windows-386.exe ./cmd/frpc-panel
|
||||||
|
env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o ./release/frpc-panel-windows-amd64.exe ./cmd/frpc-panel
|
||||||
|
env CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build -ldflags "$(LDFLAGS)" -o ./release/frpc-panel-linux-mips64 ./cmd/frpc-panel
|
||||||
|
env CGO_ENABLED=0 GOOS=linux GOARCH=mips64le go build -ldflags "$(LDFLAGS)" -o ./release/frpc-panel-linux-mips64le ./cmd/frpc-panel
|
||||||
|
env CGO_ENABLED=0 GOOS=linux GOARCH=mips GOMIPS=softfloat go build -ldflags "$(LDFLAGS)" -o ./release/frpc-panel-linux-mips ./cmd/frpc-panel
|
||||||
|
env CGO_ENABLED=0 GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build -ldflags "$(LDFLAGS)" -o ./release/frpc-panel-linux-mipsle ./cmd/frpc-panel
|
||||||
10
assets/lang/en.json
Normal file
10
assets/lang/en.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"Frpc Panel": "Frpc Panel",
|
||||||
|
"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"
|
||||||
|
}
|
||||||
10
assets/lang/zh.json
Normal file
10
assets/lang/zh.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"Frpc Panel": "Frpc 面板",
|
||||||
|
"Username": "用户名",
|
||||||
|
"Password": "密码",
|
||||||
|
"Login": "登录",
|
||||||
|
"Please input username": "请填写用户名",
|
||||||
|
"Please input password": "请填写密码",
|
||||||
|
"Login success": "登录成功",
|
||||||
|
"Username or password incorrect": "用户名或密码错误"
|
||||||
|
}
|
||||||
242
assets/static/css/color.css
Normal file
242
assets/static/css/color.css
Normal file
@@ -0,0 +1,242 @@
|
|||||||
|
.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 .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) {
|
||||||
|
.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 .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;
|
||||||
|
}
|
||||||
|
}
|
||||||
134
assets/static/css/index.css
Normal file
134
assets/static/css/index.css
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
#searchForm .layui-input-suffix,
|
||||||
|
#searchForm .layui-input-prefix {
|
||||||
|
line-height: 30px;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#addUserForm {
|
||||||
|
padding: 15px 15px 0 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#addUserForm .layui-form-item:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#addUserForm .layui-textarea {
|
||||||
|
min-height: 80px;
|
||||||
|
padding: 9px 10px;
|
||||||
|
resize: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.layui-form-label {
|
||||||
|
width: 140px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.layui-input-block {
|
||||||
|
margin-left: 170px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.layui-btn-sm {
|
||||||
|
line-height: 28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.layui-btn-xs {
|
||||||
|
line-height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.layui-btn-container {
|
||||||
|
height: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.layui-layer-btn > a[class^=layui-layer-btn] {
|
||||||
|
line-height: 28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.layui-table-page {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.version {
|
||||||
|
height: 24px;
|
||||||
|
line-height: 24px;
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
width: 100%;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
2223
assets/static/css/layui-theme-dark.css
Normal file
2223
assets/static/css/layui-theme-dark.css
Normal file
File diff suppressed because it is too large
Load Diff
30
assets/static/css/login.css
Normal file
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;
|
||||||
|
}
|
||||||
260
assets/static/js/index-proxy-list.js
Normal file
260
assets/static/js/index-proxy-list.js
Normal file
@@ -0,0 +1,260 @@
|
|||||||
|
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 || {
|
||||||
|
remote_port: 0,
|
||||||
|
use_encryption: false,
|
||||||
|
use_compression: false,
|
||||||
|
custom_domains: null,
|
||||||
|
subdomain: null,
|
||||||
|
locations: null,
|
||||||
|
host_header_rewrite: null
|
||||||
|
};
|
||||||
|
|
||||||
|
temp.client_version = temp.client_version || '-';
|
||||||
|
temp.conf.custom_domains = temp.conf.custom_domains || '-';
|
||||||
|
temp.conf.subdomain = temp.conf.subdomain || '-';
|
||||||
|
temp.conf.locations = temp.conf.locations || '-';
|
||||||
|
temp.conf.host_header_rewrite = temp.conf.host_header_rewrite || '-';
|
||||||
|
|
||||||
|
if (temp.conf.custom_domains !== '-') {
|
||||||
|
temp.conf.custom_domains = JSON.stringify(temp.conf.custom_domains);
|
||||||
|
}
|
||||||
|
if (proxyType === 'http') {
|
||||||
|
temp.conf.remote_port = http_port;
|
||||||
|
} else if (proxyType === 'https') {
|
||||||
|
temp.conf.remote_port = https_port;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
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.remote_port }}</span>'
|
||||||
|
},
|
||||||
|
{field: 'cur_conns', title: i18n['Connections'], minWidth: 140, width: '12%', sort: true},
|
||||||
|
{
|
||||||
|
field: 'today_traffic_in',
|
||||||
|
title: i18n['TrafficIn'],
|
||||||
|
minWidth: 140,
|
||||||
|
width: '12%',
|
||||||
|
sort: true,
|
||||||
|
templet: function (d) {
|
||||||
|
return size(d.today_traffic_in);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'today_traffic_out',
|
||||||
|
title: i18n['TrafficOut'],
|
||||||
|
minWidth: 140,
|
||||||
|
width: '12%',
|
||||||
|
sort: true,
|
||||||
|
templet: function (d) {
|
||||||
|
return size(d.today_traffic_out);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{field: 'client_version', 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: navigator.language.indexOf("zh") !== -1,
|
||||||
|
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.use_encryption;
|
||||||
|
var useCompression = datum.conf.use_compression;
|
||||||
|
datum.conf.use_encryption = i18n[useEncryption];
|
||||||
|
datum.conf.use_compression = 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.traffic_in.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.traffic_in.reverse(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: i18n['TrafficOut'],
|
||||||
|
type: 'bar',
|
||||||
|
data: data.traffic_out.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
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.proxy_counts = 0;
|
||||||
|
http_port = data.vhost_http_port;
|
||||||
|
https_port = data.vhost_https_port;
|
||||||
|
for (var proxy in data.proxy_type_count) {
|
||||||
|
data.proxy_counts = data.proxy_counts + data.proxy_type_count[proxy];
|
||||||
|
}
|
||||||
|
data.bind_port = data.bind_port || i18n['Disable'];
|
||||||
|
data.kcp_bind_port = data.kcp_bind_port || i18n['Disable'];
|
||||||
|
data.quic_bind_port = data.quic_bind_port || i18n['Disable'];
|
||||||
|
data.vhost_http_port = data.vhost_http_port || i18n['Disable'];
|
||||||
|
data.vhost_https_port = data.vhost_https_port || i18n['Disable'];
|
||||||
|
data.tcpmux_httpconnect_port = data.tcpmux_httpconnect_port || i18n['Disable'];
|
||||||
|
data.subdomain_host = data.subdomain_host || i18n['NotSet'];
|
||||||
|
data.max_pool_count = data.max_pool_count || i18n['NotSet'];
|
||||||
|
data.max_ports_per_client = data.max_ports_per_client || i18n['NotLimit'];
|
||||||
|
data.heart_beat_timeout = data.heart_beat_timeout || i18n['NotSet'];
|
||||||
|
data.allow_ports_str = data.allow_ports_str || i18n['NotLimit'];
|
||||||
|
data.tls_only = i18n[data.tls_only || 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.total_traffic_in, name: i18n['TrafficIn']},
|
||||||
|
{value: data.total_traffic_out, 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.proxy_type_count;
|
||||||
|
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.$);
|
||||||
730
assets/static/js/index-user-list.js
Normal file
730
assets/static/js/index-user-list.js
Normal file
@@ -0,0 +1,730 @@
|
|||||||
|
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: {
|
||||||
|
layout: navigator.language.indexOf("zh") === -1 ? ['first', 'prev', 'next', 'last'] : ['prev', 'page', 'next', 'skip', 'count', 'limit']
|
||||||
|
},
|
||||||
|
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.$)
|
||||||
50
assets/static/js/index.js
Normal file
50
assets/static/js/index.js
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
var http_port, https_port;
|
||||||
|
(function ($) {
|
||||||
|
$(function () {
|
||||||
|
function init() {
|
||||||
|
var langLoading = layui.layer.load()
|
||||||
|
$.getJSON('/lang.json').done(function (lang) {
|
||||||
|
$.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
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.$)
|
||||||
1
assets/static/lib/layui/css/layui.css
Normal file
1
assets/static/lib/layui/css/layui.css
Normal file
File diff suppressed because one or more lines are too long
BIN
assets/static/lib/layui/font/iconfont.eot
Normal file
BIN
assets/static/lib/layui/font/iconfont.eot
Normal file
Binary file not shown.
405
assets/static/lib/layui/font/iconfont.svg
Normal file
405
assets/static/lib/layui/font/iconfont.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 322 KiB |
BIN
assets/static/lib/layui/font/iconfont.ttf
Normal file
BIN
assets/static/lib/layui/font/iconfont.ttf
Normal file
Binary file not shown.
BIN
assets/static/lib/layui/font/iconfont.woff
Normal file
BIN
assets/static/lib/layui/font/iconfont.woff
Normal file
Binary file not shown.
BIN
assets/static/lib/layui/font/iconfont.woff2
Normal file
BIN
assets/static/lib/layui/font/iconfont.woff2
Normal file
Binary file not shown.
1
assets/static/lib/layui/layui.js
Normal file
1
assets/static/lib/layui/layui.js
Normal file
File diff suppressed because one or more lines are too long
81
assets/templates/index.html
Normal file
81
assets/templates/index.html
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>${ .FrpcPanel }</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/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>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="layui-layout layui-layout-admin">
|
||||||
|
<div class="layui-header layui-bg-blue">
|
||||||
|
<div class="layui-logo layui-bg-black">${ .FrpcPanel }</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="overview">Overview</a>
|
||||||
|
</li>
|
||||||
|
<li class="layui-nav-item">
|
||||||
|
<a href="javascript:void(0)" id="configure">Configure</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/yhl452493373/frpc-panel" target="_blank">${ .FrpcPanel } ${ .version }</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-body" id="content"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--概览信息模板-->
|
||||||
|
<script type="text/html" id="overviewTemplate">
|
||||||
|
<section class="overview">
|
||||||
|
|
||||||
|
</section>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!--代理列表-代理表格模板-->
|
||||||
|
<script type="text/html" id="proxyListTableTemplate">
|
||||||
|
<section class="proxy-list">
|
||||||
|
<table id="proxyListTable" lay-filter="proxyListTable"></table>
|
||||||
|
</section>
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
43
assets/templates/login.html
Normal file
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/frpc-panel" target="_blank">
|
||||||
|
<span class="title-text">${ .FrpcPanel }</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>
|
||||||
116
cmd/frpc-panel/cmd.go
Normal file
116
cmd/frpc-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 = "1.0.0"
|
||||||
|
|
||||||
|
var (
|
||||||
|
showVersion bool
|
||||||
|
configFile string
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
rootCmd.PersistentFlags().BoolVarP(&showVersion, "version", "v", false, "version of frpc-panel")
|
||||||
|
rootCmd.PersistentFlags().StringVarP(&configFile, "config", "c", "./frpc-panel.toml", "config file of frpc-panel")
|
||||||
|
}
|
||||||
|
|
||||||
|
var rootCmd = &cobra.Command{
|
||||||
|
Use: "frpc-panel",
|
||||||
|
Short: "frpc-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 frpc-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("https://", strings.ToLower(common.Common.DashboardAddr))
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
5
cmd/frpc-panel/main.go
Normal file
5
cmd/frpc-panel/main.go
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
Execute()
|
||||||
|
}
|
||||||
46
config/cert.crt
Normal file
46
config/cert.crt
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIDwDCCAqigAwIBAgIIYb+7dG3vm+swDQYJKoZIhvcNAQELBQAwejELMAkGA1UE
|
||||||
|
BhMCQ04xFzAVBgNVBAoTDktleU1hbmFnZXIub3JnMTEwLwYDVQQLEyhLZXlNYW5h
|
||||||
|
Z2VyIFRlc3QgUm9vdCAtIEZvciBUZXN0IFVzZSBPbmx5MR8wHQYDVQQDExZLZXlN
|
||||||
|
YW5hZ2VyIFRlc3QgUlNBIENBMB4XDTIzMDkxMTA5NTY0NloXDTI0MDkxMTA5NTY0
|
||||||
|
NlowJjELMAkGA1UEBhMCQ04xFzAVBgNVBAMTDmxvY2FsaG9zdDo3MjAwMIIBIjAN
|
||||||
|
BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqp/BNnNx4OGqJHNLN0GX8MDUO4PI
|
||||||
|
WJ9rq6by65i2RXd4t51yyOH68l/TNmfCXcUQ91SvBBD+P2dK2gkZOlprDOS3tO+G
|
||||||
|
sCTAAEf/tv1+N2ZqDUPKwaIH60seDJd2a3A97KtfySFVrCUrlTeB/tPL5XMBFwTT
|
||||||
|
xPvfV6RULAaK6lJGdrM9/k/vYfneE+ZY5Bo1b7kaqZLOz9LW3icarPGcFDIes/Lu
|
||||||
|
d3sCbpjza0bAKFy594vIdwqjRY4OHdubwXV3wV/AxgA0tQNyYADFwa3YeSvBsfFq
|
||||||
|
PortWOAYKrg86RJJ8ilQumNiEs6FSYnSatbjMkKh7q9EerJf/exlW1IzDQIDAQAB
|
||||||
|
o4GdMIGaMA4GA1UdDwEB/wQEAwIFoDAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYB
|
||||||
|
BQUHAwIwHQYDVR0OBBYEFJFGsaMxKCw1E2r2NC+PxdiI4p/VMB8GA1UdIwQYMBaA
|
||||||
|
FIBNaqqKRqtaWv5Us+XACf5jiY2rMCkGA1UdEQQiMCCCDmxvY2FsaG9zdDo3MjAw
|
||||||
|
gg4xMjcuMC4wLjE6NzIwMDANBgkqhkiG9w0BAQsFAAOCAQEAhuNAScvlzJKL4aAm
|
||||||
|
bPl6Yru85GZZk+QmL8tICT9rxfq5L/5RhZXuTIqBDLB+ETHq5yQdiUJTphMpq2i3
|
||||||
|
UZUzSMkUFokLROKWaENJz82RWYPUGNLqUO7vTIy2HGd4qOYjWDlHba7d9UIRTcKx
|
||||||
|
1pd4rqXRTka1rprmoBcSNgcFDcKmctgliOPFqa9V89xrWSznahNqRqdkvbzuuHFz
|
||||||
|
oZHKsTBzZ65Mk/E5+EdOYgEPg4kBfBMP7LXabUYCON1ArekRUHS1QJ0yCrzDpUxu
|
||||||
|
0XnFTHaoBtP2o7tqmRQk78/8UkqOkz8241p2Tl8n3YZDiJbrv6okTPe+c/m9xD37
|
||||||
|
2kwdDg==
|
||||||
|
-----END CERTIFICATE-----
|
||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIID2jCCAsKgAwIBAgIIcAbJXpLHgDkwDQYJKoZIhvcNAQELBQAwezELMAkGA1UE
|
||||||
|
BhMCQ04xFzAVBgNVBAoTDktleU1hbmFnZXIub3JnMTEwLwYDVQQLEyhLZXlNYW5h
|
||||||
|
Z2VyIFRlc3QgUm9vdCAtIEZvciBUZXN0IFVzZSBPbmx5MSAwHgYDVQQDExdLZXlN
|
||||||
|
YW5hZ2VyIFRlc3QgUm9vdCBDQTAeFw0yMzA5MTEwOTEzNTFaFw0zMzA5MTEwOTEz
|
||||||
|
NTFaMHoxCzAJBgNVBAYTAkNOMRcwFQYDVQQKEw5LZXlNYW5hZ2VyLm9yZzExMC8G
|
||||||
|
A1UECxMoS2V5TWFuYWdlciBUZXN0IFJvb3QgLSBGb3IgVGVzdCBVc2UgT25seTEf
|
||||||
|
MB0GA1UEAxMWS2V5TWFuYWdlciBUZXN0IFJTQSBDQTCCASIwDQYJKoZIhvcNAQEB
|
||||||
|
BQADggEPADCCAQoCggEBANfE1y7r94k5LeDncCnOfjItWXWWuNAzJFXsd0620cON
|
||||||
|
5jXCYfVGdRqPkpHtLml1OiMtnSyxxqIASCsxn+puvXPy12FJkTq8D5GtuuLk/8oI
|
||||||
|
iiGvFTbVR1C63ZwYQ/MOjMbmlICNVNFYDZfPbALLaZbvtd2q9xc/bq0zd9P6cfW4
|
||||||
|
GKZyGNwmrNukUtXkIdPIaUiNRiseHwwyR//bJh9GFhCw5jpVK5bnDT1PZYFKww0J
|
||||||
|
qv5kA9fCY/Xm635MfRsvNI+2RMOBhKgblWGmDCaJMOglgyao3AVK8ajrNrlAoTHC
|
||||||
|
9Lcm4dQc2p0KUVfRitLio2ANKM3oh8q2qHPFrAnvjzcCAwEAAaNjMGEwDgYDVR0P
|
||||||
|
AQH/BAQDAgGGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFIBNaqqKRqtaWv5U
|
||||||
|
s+XACf5jiY2rMB8GA1UdIwQYMBaAFEOl8mT1ZXKyUe00w/jyQQKMYUQAMA0GCSqG
|
||||||
|
SIb3DQEBCwUAA4IBAQCouCabkdzZKiGMKlrCE0y/eDNqBUwdERWD+Xrxhm/K13bg
|
||||||
|
gJJXZsWWr2/iumbWkc3N9W5J2gyFc+iO79VrVMzlq2Kfbhy5XY5gioC8n1BL4FPs
|
||||||
|
lmOGtO/8NubZhjTVrE/wH2iDcC9vfE5EAM/axnQXA1DjuEhyRnZe40lTXnA37vc1
|
||||||
|
f0hizePrPiMNpzJLZ9kj9pvOYRc7h+Oe04fz+iG5iSlJ/s4y81o0oOJkDLatfveC
|
||||||
|
+L2ZqbiagZTsBYiL68Y612n7UDH2tUpyE6hCxYlNb+hCMFLakRHfp/IHcz6oHxvV
|
||||||
|
kyJ5FwVvwn9fy4QOi/NsfASdb4AnyqRkJKNSlqWw
|
||||||
|
-----END CERTIFICATE-----
|
||||||
27
config/cert.key
Normal file
27
config/cert.key
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
-----BEGIN RSA PRIVATE KEY-----
|
||||||
|
MIIEowIBAAKCAQEAqp/BNnNx4OGqJHNLN0GX8MDUO4PIWJ9rq6by65i2RXd4t51y
|
||||||
|
yOH68l/TNmfCXcUQ91SvBBD+P2dK2gkZOlprDOS3tO+GsCTAAEf/tv1+N2ZqDUPK
|
||||||
|
waIH60seDJd2a3A97KtfySFVrCUrlTeB/tPL5XMBFwTTxPvfV6RULAaK6lJGdrM9
|
||||||
|
/k/vYfneE+ZY5Bo1b7kaqZLOz9LW3icarPGcFDIes/Lud3sCbpjza0bAKFy594vI
|
||||||
|
dwqjRY4OHdubwXV3wV/AxgA0tQNyYADFwa3YeSvBsfFqPortWOAYKrg86RJJ8ilQ
|
||||||
|
umNiEs6FSYnSatbjMkKh7q9EerJf/exlW1IzDQIDAQABAoIBAFcIGBEDQAI6eYQQ
|
||||||
|
PzyXO751TYxyAv6Zit1K0jw0cDzs3Omj6UnoYw3ArUbiFDWqcKYITyGe3WFP+dFP
|
||||||
|
tMucFWDFRaOITkaI6Fr8XsZjdT8jAVN00faFBM8TSOeZVrEk1qFjJP+9/ipJ53o8
|
||||||
|
jxWByU5npBWuw6qF432b98dhKvisW5Uu1hw8z935ld7uk3nF2mWAxzrTq8GE+Mn5
|
||||||
|
Ic0yDmxnd/6rgUuAVtfGMDsKCks7P0J4bvxIG8fDnWh40SwNffrlHZ1Fz/yqJCCl
|
||||||
|
tzkbQnX7lp4JGq1NkubgIchQ5pJzoqzWSShr72tyipjpTBIKDWT6TMapp0Y+veJX
|
||||||
|
jl4fXs0CgYEA2kBFyO+/BSjOLmlftvos1YqrJD9eSy9ydSY9jRF/6qX1AWbbmH2c
|
||||||
|
rIN+kLeQtoFP87BMpMU1qDhmqbXx+WLaMYU0RTB8oNhriUbXE2hs7ndGm/FS8yzu
|
||||||
|
wG0xHBT8Bm8WA/5/bmFbjUCA7eSKYczYrHFd/aaf5HKGtGFJx8jz4t8CgYEAyCKm
|
||||||
|
vqJ1WGK2Ql/hN1Gw3/rmyzgPqMgfq0gi7cQ3bRY/txK5vWHcDQdIywpxmmMWpkzy
|
||||||
|
UX3m9hMb2ao01riFngIhBJslong0ExLSv50bi9evCAL0dZCQFPaBCgjNoMRjofGq
|
||||||
|
SE0fJMDEOqcEt2fEAH8Fa4FUw9MKAypV++H7s5MCgYEA1gZpaN8Sp/CYIJNdNYao
|
||||||
|
KNDPe8BYq8pfp9pUSd57XpRYa4N+nU+xMMvSdgBNfWvaB9M/leV+9PQ6WPr/y9vQ
|
||||||
|
tPc3hxJBZUpWSkyZ5YJmMIPvTkWdXrMVfsaVfkBl1bliEZClTo1SxnYW+TNBMR88
|
||||||
|
6/5QecnIyrI0vvcY7z51TGkCgYB8CpYEc5Z9WHkUPG7PJY+V0uE2tSFnf9m5BDW5
|
||||||
|
3jJoJzEIW8/JJB0J6ijgxzFP+fgwzGInxfvfKkrJpqenKaiPHUyvmSVDRHMqGzGJ
|
||||||
|
12saSmzOb15qe1YB2CJ0QK6J5Q7HcYwT0dDqq5szqw7OSb7+e7u1POx3jpaXDadL
|
||||||
|
PW4OhwKBgHcZWsXJUaKesNJbeGeRKmQHooSdrE69gika1HU7GYmTV3JwvAFrHSNF
|
||||||
|
EGMMTmWc6nTh63ADO/f+dpAoJVOQM/OhEVVyfvlByLEFeieGegwyREWVYajW+6Dt
|
||||||
|
Ztrafmyvn+r3yhWN9g+p1yQTeVLw23ir9cYhP8OqnL4d89c3o+r3
|
||||||
|
-----END RSA PRIVATE KEY-----
|
||||||
21
config/frpc-panel.toml
Normal file
21
config/frpc-panel.toml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# basic options
|
||||||
|
[common]
|
||||||
|
# frps panel config info
|
||||||
|
plugin_addr = "127.0.0.1"
|
||||||
|
plugin_port = 7300
|
||||||
|
#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"
|
||||||
|
|
||||||
|
# frpc dashboard info
|
||||||
|
dashboard_addr = "127.0.0.1"
|
||||||
|
dashboard_port = 7400
|
||||||
|
dashboard_user = "admin"
|
||||||
|
dashboard_pwd = "admin"
|
||||||
|
|
||||||
48
go.mod
Normal file
48
go.mod
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
module frps-panel
|
||||||
|
|
||||||
|
go 1.21
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/BurntSushi/toml v1.0.0
|
||||||
|
github.com/fatedier/frp v0.34.1
|
||||||
|
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/pelletier/go-toml/v2 v2.0.9
|
||||||
|
github.com/spf13/cobra v0.0.3
|
||||||
|
golang.org/x/text v0.11.0
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/bytedance/sonic v1.10.0-rc3 // indirect
|
||||||
|
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/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/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.0.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
|
||||||
|
github.com/mattn/go-isatty v0.0.19 // indirect
|
||||||
|
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/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/net v0.12.0 // indirect
|
||||||
|
golang.org/x/sys v0.10.0 // indirect
|
||||||
|
google.golang.org/protobuf v1.31.0 // indirect
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
|
)
|
||||||
327
go.sum
Normal file
327
go.sum
Normal file
@@ -0,0 +1,327 @@
|
|||||||
|
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/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/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=
|
||||||
|
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||||
|
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||||
|
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/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/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8=
|
||||||
|
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
||||||
|
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||||
|
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/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/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/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/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=
|
||||||
|
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||||
|
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/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=
|
||||||
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
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/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/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=
|
||||||
19
package.sh
Normal file
19
package.sh
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
version=$(cat cmd/frpc-panel/cmd.go | grep 'const version' | egrep -o '[0-9.]+')
|
||||||
|
cd ./release || exit
|
||||||
|
rm -rf *.zip
|
||||||
|
list=$(ls frpc-panel-*)
|
||||||
|
echo "$list"
|
||||||
|
for binFile in $list
|
||||||
|
do
|
||||||
|
tmpFile=frpc-panel
|
||||||
|
newBinFile=$binFile
|
||||||
|
if echo "$binFile" | grep -q -E "\.exe";then
|
||||||
|
tmpFile=frpc-panel.exe
|
||||||
|
newBinFile=${newBinFile%%.exe*}
|
||||||
|
fi
|
||||||
|
cp "$binFile" "$tmpFile"
|
||||||
|
zip -r "$newBinFile-$version".zip "$tmpFile" frpc-panel.toml frpc-tokens.toml assets -x "*.git*" "*.idea*" "*.DS_Store" "*.contentFlavour"
|
||||||
|
rm -rf "$binFile" "$tmpFile"
|
||||||
|
done
|
||||||
|
rm -rf frpc-panel.toml frpc-tokens.toml assets
|
||||||
104
pkg/server/controller/authorizer.go
Normal file
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))
|
||||||
|
}
|
||||||
428
pkg/server/controller/controller.go
Normal file
428
pkg/server/controller/controller.go
Normal file
@@ -0,0 +1,428 @@
|
|||||||
|
package controller
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/tls"
|
||||||
|
"fmt"
|
||||||
|
ginI18n "github.com/gin-contrib/i18n"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"io"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"sort"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
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,
|
||||||
|
"FrpcPanel": ginI18n.MustGetMessage(context, "Frpc 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{
|
||||||
|
"version": c.Version,
|
||||||
|
"FrpcPanel": ginI18n.MustGetMessage(context, "Frpc Panel"),
|
||||||
|
"showExit": trimString(c.CommonInfo.AdminUser) != "" && trimString(c.CommonInfo.AdminPwd) != "",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *HandleController) MakeLangFunc() func(context *gin.Context) {
|
||||||
|
return func(context *gin.Context) {
|
||||||
|
context.JSON(http.StatusOK, gin.H{})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *HandleController) MakeQueryTokensFunc() func(context *gin.Context) {
|
||||||
|
return func(context *gin.Context) {
|
||||||
|
|
||||||
|
search := TokenSearch{}
|
||||||
|
search.Limit = 0
|
||||||
|
|
||||||
|
err := context.BindQuery(&search)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var tokenList []TokenInfo
|
||||||
|
for _, tokenInfo := range c.Tokens {
|
||||||
|
tokenList = append(tokenList, tokenInfo)
|
||||||
|
}
|
||||||
|
sort.Slice(tokenList, func(i, j int) bool {
|
||||||
|
return strings.Compare(tokenList[i].User, tokenList[j].User) < 0
|
||||||
|
})
|
||||||
|
|
||||||
|
var filtered []TokenInfo
|
||||||
|
for _, tokenInfo := range tokenList {
|
||||||
|
if filter(tokenInfo, search.TokenInfo) {
|
||||||
|
filtered = append(filtered, tokenInfo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if filtered == nil {
|
||||||
|
filtered = []TokenInfo{}
|
||||||
|
}
|
||||||
|
|
||||||
|
count := len(filtered)
|
||||||
|
if search.Limit > 0 {
|
||||||
|
start := max((search.Page-1)*search.Limit, 0)
|
||||||
|
end := min(search.Page*search.Limit, len(filtered))
|
||||||
|
filtered = filtered[start:end]
|
||||||
|
}
|
||||||
|
|
||||||
|
context.JSON(http.StatusOK, &TokenResponse{
|
||||||
|
Code: 0,
|
||||||
|
Msg: "query Tokens success",
|
||||||
|
Count: count,
|
||||||
|
Data: filtered,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *HandleController) MakeAddTokenFunc() func(context *gin.Context) {
|
||||||
|
return func(context *gin.Context) {
|
||||||
|
info := TokenInfo{
|
||||||
|
Enable: true,
|
||||||
|
}
|
||||||
|
response := OperationResponse{
|
||||||
|
Success: true,
|
||||||
|
Code: Success,
|
||||||
|
Message: "user add success",
|
||||||
|
}
|
||||||
|
err := context.BindJSON(&info)
|
||||||
|
if err != nil {
|
||||||
|
response.Success = false
|
||||||
|
response.Code = ParamError
|
||||||
|
response.Message = fmt.Sprintf("user add failed, param error : %v", err)
|
||||||
|
log.Printf(response.Message)
|
||||||
|
context.JSON(http.StatusOK, &response)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result := c.verifyToken(info, TOKEN_ADD)
|
||||||
|
|
||||||
|
if !result.Success {
|
||||||
|
context.JSON(http.StatusOK, &result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
err = c.saveToken()
|
||||||
|
if err != nil {
|
||||||
|
response.Success = false
|
||||||
|
response.Code = SaveError
|
||||||
|
response.Message = fmt.Sprintf("add failed, error : %v", err)
|
||||||
|
log.Printf(response.Message)
|
||||||
|
context.JSON(http.StatusOK, &response)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
context.JSON(0, &response)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *HandleController) MakeUpdateTokensFunc() func(context *gin.Context) {
|
||||||
|
return func(context *gin.Context) {
|
||||||
|
response := OperationResponse{
|
||||||
|
Success: true,
|
||||||
|
Code: Success,
|
||||||
|
Message: "user update success",
|
||||||
|
}
|
||||||
|
update := TokenUpdate{}
|
||||||
|
err := context.BindJSON(&update)
|
||||||
|
if err != nil {
|
||||||
|
response.Success = false
|
||||||
|
response.Code = ParamError
|
||||||
|
response.Message = fmt.Sprintf("update failed, param error : %v", err)
|
||||||
|
log.Printf(response.Message)
|
||||||
|
context.JSON(http.StatusOK, &response)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
before := update.Before
|
||||||
|
after := update.After
|
||||||
|
|
||||||
|
if before.User != after.User {
|
||||||
|
response.Success = false
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
result := c.verifyToken(after, TOKEN_UPDATE)
|
||||||
|
|
||||||
|
if !result.Success {
|
||||||
|
context.JSON(http.StatusOK, &result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
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.saveToken()
|
||||||
|
if err != nil {
|
||||||
|
response.Success = false
|
||||||
|
response.Code = SaveError
|
||||||
|
response.Message = fmt.Sprintf("user update failed, error : %v", err)
|
||||||
|
log.Printf(response.Message)
|
||||||
|
context.JSON(http.StatusOK, &response)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
context.JSON(http.StatusOK, &response)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *HandleController) MakeRemoveTokensFunc() func(context *gin.Context) {
|
||||||
|
return func(context *gin.Context) {
|
||||||
|
response := OperationResponse{
|
||||||
|
Success: true,
|
||||||
|
Code: Success,
|
||||||
|
Message: "user remove success",
|
||||||
|
}
|
||||||
|
remove := TokenRemove{}
|
||||||
|
err := context.BindJSON(&remove)
|
||||||
|
if err != nil {
|
||||||
|
response.Success = false
|
||||||
|
response.Code = ParamError
|
||||||
|
response.Message = fmt.Sprintf("user remove failed, param error : %v", err)
|
||||||
|
log.Printf(response.Message)
|
||||||
|
context.JSON(http.StatusOK, &response)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = c.saveToken()
|
||||||
|
if err != nil {
|
||||||
|
response.Success = false
|
||||||
|
response.Code = SaveError
|
||||||
|
response.Message = fmt.Sprintf("user update failed, error : %v", err)
|
||||||
|
log.Printf(response.Message)
|
||||||
|
context.JSON(http.StatusOK, &response)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
context.JSON(http.StatusOK, &response)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *HandleController) MakeDisableTokensFunc() func(context *gin.Context) {
|
||||||
|
return func(context *gin.Context) {
|
||||||
|
response := OperationResponse{
|
||||||
|
Success: true,
|
||||||
|
Code: Success,
|
||||||
|
Message: "remove success",
|
||||||
|
}
|
||||||
|
disable := TokenDisable{}
|
||||||
|
err := context.BindJSON(&disable)
|
||||||
|
if err != nil {
|
||||||
|
response.Success = false
|
||||||
|
response.Code = ParamError
|
||||||
|
response.Message = fmt.Sprintf("disable failed, param error : %v", err)
|
||||||
|
log.Printf(response.Message)
|
||||||
|
context.JSON(http.StatusOK, &response)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, user := range disable.Users {
|
||||||
|
result := c.verifyToken(user, TOKEN_DISABLE)
|
||||||
|
|
||||||
|
if !result.Success {
|
||||||
|
context.JSON(http.StatusOK, &result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, user := range disable.Users {
|
||||||
|
token := c.Tokens[user.User]
|
||||||
|
token.Enable = false
|
||||||
|
c.Tokens[user.User] = token
|
||||||
|
}
|
||||||
|
|
||||||
|
err = c.saveToken()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
response.Success = false
|
||||||
|
response.Code = SaveError
|
||||||
|
response.Message = fmt.Sprintf("disable failed, error : %v", err)
|
||||||
|
log.Printf(response.Message)
|
||||||
|
context.JSON(http.StatusOK, &response)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
context.JSON(http.StatusOK, &response)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *HandleController) MakeEnableTokensFunc() func(context *gin.Context) {
|
||||||
|
return func(context *gin.Context) {
|
||||||
|
response := OperationResponse{
|
||||||
|
Success: true,
|
||||||
|
Code: Success,
|
||||||
|
Message: "remove success",
|
||||||
|
}
|
||||||
|
enable := TokenEnable{}
|
||||||
|
err := context.BindJSON(&enable)
|
||||||
|
if err != nil {
|
||||||
|
response.Success = false
|
||||||
|
response.Code = ParamError
|
||||||
|
response.Message = fmt.Sprintf("enable failed, param error : %v", err)
|
||||||
|
log.Printf(response.Message)
|
||||||
|
context.JSON(http.StatusOK, &response)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, user := range enable.Users {
|
||||||
|
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.Enable = true
|
||||||
|
c.Tokens[user.User] = token
|
||||||
|
}
|
||||||
|
|
||||||
|
err = c.saveToken()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("enable failed, error : %v", err)
|
||||||
|
response.Success = false
|
||||||
|
response.Code = SaveError
|
||||||
|
response.Message = "enable failed"
|
||||||
|
context.JSON(http.StatusOK, &response)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
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 = "Proxy to " + requestUrl + " success"
|
||||||
|
} else {
|
||||||
|
res.Success = false
|
||||||
|
res.Message = "Proxy to " + requestUrl + " error: " + string(body)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.Printf(res.Message)
|
||||||
|
context.JSON(http.StatusOK, &res)
|
||||||
|
}
|
||||||
|
}
|
||||||
193
pkg/server/controller/handler.go
Normal file
193
pkg/server/controller/handler.go
Normal file
@@ -0,0 +1,193 @@
|
|||||||
|
package controller
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
plugin "github.com/fatedier/frp/pkg/plugin/server"
|
||||||
|
"log"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (c *HandleController) HandleLogin(content *plugin.LoginContent) plugin.Response {
|
||||||
|
token := content.Metas["token"]
|
||||||
|
user := content.User
|
||||||
|
return c.JudgeToken(user, token)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *HandleController) HandleNewProxy(content *plugin.NewProxyContent) plugin.Response {
|
||||||
|
token := content.User.Metas["token"]
|
||||||
|
user := content.User.User
|
||||||
|
judgeToken := c.JudgeToken(user, token)
|
||||||
|
if judgeToken.Reject {
|
||||||
|
return judgeToken
|
||||||
|
}
|
||||||
|
return c.JudgePort(content)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *HandleController) HandlePing(content *plugin.PingContent) plugin.Response {
|
||||||
|
token := content.User.Metas["token"]
|
||||||
|
user := content.User.User
|
||||||
|
return c.JudgeToken(user, token)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *HandleController) HandleNewWorkConn(content *plugin.NewWorkConnContent) plugin.Response {
|
||||||
|
token := content.User.Metas["token"]
|
||||||
|
user := content.User.User
|
||||||
|
return c.JudgeToken(user, token)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *HandleController) HandleNewUserConn(content *plugin.NewUserConnContent) plugin.Response {
|
||||||
|
token := content.User.Metas["token"]
|
||||||
|
user := content.User.User
|
||||||
|
return c.JudgeToken(user, token)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *HandleController) JudgeToken(user string, token string) plugin.Response {
|
||||||
|
var res plugin.Response
|
||||||
|
if len(c.Tokens) == 0 {
|
||||||
|
res.Unchange = true
|
||||||
|
} else if user == "" || token == "" {
|
||||||
|
res.Reject = true
|
||||||
|
res.RejectReason = "user or meta token can not be empty"
|
||||||
|
} else if info, exist := c.Tokens[user]; exist {
|
||||||
|
if !info.Enable {
|
||||||
|
res.Reject = true
|
||||||
|
res.RejectReason = fmt.Sprintf("user [%s] is disabled", user)
|
||||||
|
} else {
|
||||||
|
if info.Token != token {
|
||||||
|
res.Reject = true
|
||||||
|
res.RejectReason = fmt.Sprintf("invalid meta token for user [%s]", user)
|
||||||
|
} else {
|
||||||
|
res.Unchange = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
res.Reject = true
|
||||||
|
res.RejectReason = fmt.Sprintf("user [%s] not exist", user)
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *HandleController) JudgePort(content *plugin.NewProxyContent) plugin.Response {
|
||||||
|
var res plugin.Response
|
||||||
|
var portErr error
|
||||||
|
var reject = false
|
||||||
|
supportProxyTypes := []string{
|
||||||
|
"tcp", "tcpmux", "udp", "http", "https",
|
||||||
|
}
|
||||||
|
proxyType := content.ProxyType
|
||||||
|
if stringContains(proxyType, supportProxyTypes) {
|
||||||
|
log.Printf("proxy type [%v] not support, plugin do nothing", proxyType)
|
||||||
|
res.Unchange = true
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
user := content.User.User
|
||||||
|
userPort := content.RemotePort
|
||||||
|
userDomains := content.CustomDomains
|
||||||
|
userSubdomain := content.SubDomain
|
||||||
|
|
||||||
|
portAllowed := true
|
||||||
|
if proxyType == "tcp" || proxyType == "udp" {
|
||||||
|
portAllowed = false
|
||||||
|
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(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(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
|
||||||
|
}
|
||||||
|
if max(userPort, start) == userPort && min(userPort, end) == userPort {
|
||||||
|
portAllowed = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
allowed, err := strconv.Atoi(str)
|
||||||
|
if err != nil {
|
||||||
|
portErr = fmt.Errorf("user [%v] allowed port [%v] is not a number", user, port)
|
||||||
|
}
|
||||||
|
if allowed == userPort {
|
||||||
|
portAllowed = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
allowed := port
|
||||||
|
if allowed == userPort {
|
||||||
|
portAllowed = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
portAllowed = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !portAllowed {
|
||||||
|
if portErr == nil {
|
||||||
|
portErr = fmt.Errorf("user [%v] port [%v] is not allowed", user, userPort)
|
||||||
|
}
|
||||||
|
reject = true
|
||||||
|
}
|
||||||
|
|
||||||
|
domainAllowed := true
|
||||||
|
if proxyType == "http" || proxyType == "https" || proxyType == "tcpmux" {
|
||||||
|
if portAllowed {
|
||||||
|
if token, exist := c.Tokens[user]; exist {
|
||||||
|
for _, userDomain := range userDomains {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
subdomainAllowed := true
|
||||||
|
if proxyType == "http" || proxyType == "https" {
|
||||||
|
subdomainAllowed = false
|
||||||
|
if portAllowed && domainAllowed {
|
||||||
|
if token, exist := c.Tokens[user]; exist {
|
||||||
|
for _, subdomain := range token.Subdomains {
|
||||||
|
if subdomain == userSubdomain {
|
||||||
|
subdomainAllowed = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
subdomainAllowed = true
|
||||||
|
}
|
||||||
|
if !subdomainAllowed {
|
||||||
|
portErr = fmt.Errorf("user [%v] subdomain [%v] is not allowed", user, userSubdomain)
|
||||||
|
reject = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if reject {
|
||||||
|
res.Reject = true
|
||||||
|
res.RejectReason = portErr.Error()
|
||||||
|
} else {
|
||||||
|
res.Unchange = true
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
50
pkg/server/controller/register.go
Normal file
50
pkg/server/controller/register.go
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
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.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("/", 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
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
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()
|
||||||
|
}
|
||||||
191
pkg/server/server.go
Normal file
191
pkg/server/server.go
Normal file
@@ -0,0 +1,191 @@
|
|||||||
|
package server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"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"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Server struct {
|
||||||
|
cfg controller.HandleController
|
||||||
|
s *http.Server
|
||||||
|
tls TLS
|
||||||
|
done chan struct{}
|
||||||
|
rootDir string
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
return s, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) Run() error {
|
||||||
|
bindAddress := s.cfg.CommonInfo.PluginAddr + ":" + strconv.Itoa(s.cfg.CommonInfo.PluginPort)
|
||||||
|
l, err := net.Listen("tcp", bindAddress)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
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 %s server: %v", s.tls.Protocol, err)
|
||||||
|
_ = s.Stop()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
<-s.done
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
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 %s server error: %v", s.tls.Protocol, err)
|
||||||
|
}
|
||||||
|
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 %s server error: %v", s.tls.Protocol, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func LoadSupportLanguage(dir string) ([]language.Tag, error) {
|
||||||
|
var tags []language.Tag
|
||||||
|
|
||||||
|
files, err := os.Open(dir)
|
||||||
|
|
||||||
|
fileList, err := files.Readdir(-1)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("error read lang directory: %v", err)
|
||||||
|
return tags, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = files.Close()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, file := range fileList {
|
||||||
|
name, _ := strings.CutSuffix(file.Name(), ".json")
|
||||||
|
parsedLang, _ := language.Parse(name)
|
||||||
|
tags = append(tags, parsedLang)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(tags) == 0 {
|
||||||
|
return tags, fmt.Errorf("not found any language file in directory: %v", dir)
|
||||||
|
}
|
||||||
|
|
||||||
|
return tags, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
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: lang,
|
||||||
|
AcceptLanguage: tags,
|
||||||
|
DefaultLanguage: language.Chinese,
|
||||||
|
FormatBundleFile: "json",
|
||||||
|
UnmarshalFunc: json.Unmarshal,
|
||||||
|
}),
|
||||||
|
ginI18n.WithGetLngHandle(
|
||||||
|
func(context *gin.Context, defaultLng string) string {
|
||||||
|
header := context.GetHeader("Accept-Language")
|
||||||
|
lang, _, err := language.ParseAcceptLanguage(header)
|
||||||
|
if err != nil {
|
||||||
|
return defaultLng
|
||||||
|
}
|
||||||
|
return lang[0].String()
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) initHTTPServer() error {
|
||||||
|
gin.SetMode(gin.ReleaseMode)
|
||||||
|
engine := gin.New()
|
||||||
|
authStore := cookie.NewStore([]byte("frpc-panel"))
|
||||||
|
authStore.Options(sessions.Options{
|
||||||
|
Secure: true,
|
||||||
|
HttpOnly: false,
|
||||||
|
SameSite: 4,
|
||||||
|
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(s.rootDir, engine)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user