mirror of
https://github.com/yhl452493373/frps-panel.git
synced 2026-04-04 14:27:00 +08:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
15438835b1 | ||
|
|
34f27aa3aa | ||
|
|
9506c7b1b6 | ||
|
|
3b7c9311fe | ||
|
|
b92d9c061a | ||
|
|
b8a24f5751 | ||
|
|
7e2f59eba8 | ||
|
|
ef8b65cbf2 | ||
|
|
058756af0a | ||
|
|
ac10af1112 | ||
|
|
3528d6ed17 | ||
|
|
4f8583dfbe | ||
|
|
78e5c1e59c |
11
README.md
11
README.md
@@ -48,12 +48,18 @@ admin_user = admin
|
||||
;the password of manage ui,optional
|
||||
admin_pwd = admin
|
||||
|
||||
; frp server's dashboard config info, it's required and should be the same as frp server
|
||||
; otherwaise, this plugin cannot get server info
|
||||
; enable tls
|
||||
tls_mode = false
|
||||
; tls_cert_file = cert.crt
|
||||
; tls_key_file = cert.key
|
||||
|
||||
; frp dashboard info
|
||||
dashboard_addr = 127.0.0.1
|
||||
dashboard_port = 7500
|
||||
dashboard_user = admin
|
||||
dashboard_pwd = admin
|
||||
; if your frps dashboard enable tls, change this to true
|
||||
dashboard_tls = false
|
||||
|
||||
[users]
|
||||
;user user1 with meta_token 123
|
||||
@@ -169,3 +175,4 @@ If you have any issues or ideas, put it on [issues](https://github.com/yhl452493
|
||||
+ [fp-multiuser](https://github.com/gofrp/fp-multiuser)
|
||||
+ [layui](https://github.com/layui/layui)
|
||||
+ [layui-theme-dark](https://github.com/Sight-wcg/layui-theme-dark)
|
||||
+ [echarts](https://github.com/apache/echarts)
|
||||
|
||||
@@ -49,11 +49,18 @@ admin_user = admin
|
||||
;插件管理页面密码,与账号一起进行鉴权,可选
|
||||
admin_pwd = admin
|
||||
|
||||
; frps 面板页面是否启用https访问,如果为true,则只能通过https访问
|
||||
tls_mode = false
|
||||
; tls_cert_file = cert.crt
|
||||
; tls_key_file = cert.key
|
||||
|
||||
; frp服务器的看板页面信息,必须配置,且与frp服务器一致,否则无法获取服务器信息
|
||||
dashboard_addr = 127.0.0.1
|
||||
dashboard_port = 7500
|
||||
dashboard_user = admin
|
||||
dashboard_pwd = admin
|
||||
; 如果frps的dashboard启用了tls,则把这个选项置为true,否则无法获取服务器信息
|
||||
dashboard_tls = false
|
||||
|
||||
[users]
|
||||
;user1的meta_token为123
|
||||
@@ -169,3 +176,4 @@ ___如果要从外网访问管理界面, 需要把配置中的 `plugin_addr` 改
|
||||
+ [fp-multiuser](https://github.com/gofrp/fp-multiuser)
|
||||
+ [layui](https://github.com/layui/layui)
|
||||
+ [layui-theme-dark](https://github.com/Sight-wcg/layui-theme-dark)
|
||||
+ [echarts](https://github.com/apache/echarts)
|
||||
|
||||
@@ -89,5 +89,6 @@
|
||||
"Current Connections": "Current Connections",
|
||||
"Client Counts": "Client Counts",
|
||||
"Proxy Counts": "Proxy Counts",
|
||||
"Not Set": "Not Set"
|
||||
"Not Set": "Not Set",
|
||||
"Proxy": "Proxies"
|
||||
}
|
||||
@@ -89,5 +89,6 @@
|
||||
"Current Connections": "当前连接数",
|
||||
"Client Counts": "客户端总数",
|
||||
"Proxy Counts": "代理总数",
|
||||
"Not Set": "未配置"
|
||||
"Not Set": "未配置",
|
||||
"Proxy": "代理数量"
|
||||
}
|
||||
@@ -443,10 +443,6 @@
|
||||
border-left: 5px solid var(--lay-color-border-4)
|
||||
}
|
||||
|
||||
.layui-text pre > code:not(.layui-code) {
|
||||
background-color: var(--lay-color-bg-white)
|
||||
}
|
||||
|
||||
/* 字体颜色 */
|
||||
.layui-font-red {
|
||||
color: var(--lay-color-red-6) !important
|
||||
@@ -595,7 +591,7 @@
|
||||
}
|
||||
|
||||
/* 数字输入框动态点缀 */
|
||||
.layui-input-wrap .layui-input-number .layui-icon:first-child {
|
||||
.layui-input-wrap .layui-input-number .layui-icon-up {
|
||||
border-bottom-color: var(--lay-color-border-1)
|
||||
}
|
||||
|
||||
@@ -1042,6 +1038,7 @@
|
||||
background-color: var(--lay-color-bg-5)
|
||||
}
|
||||
|
||||
/* 单元格多行展开风格 */
|
||||
.layui-table-cell-c {
|
||||
background-color: var(--lay-color-gray-13);
|
||||
color: var(--lay-color-text-1);
|
||||
@@ -1052,6 +1049,25 @@
|
||||
border-color: var(--lay-color-secondary-hover);
|
||||
}
|
||||
|
||||
/* 单元格 TIPS 展开风格 */
|
||||
body .layui-table-tips .layui-layer-content {
|
||||
box-shadow: var(--lay-shadow-3)
|
||||
}
|
||||
|
||||
.layui-table-tips-main {
|
||||
background-color: var(--lay-color-bg-5);
|
||||
color: var(--lay-color-text-3)
|
||||
}
|
||||
|
||||
.layui-table-tips-c {
|
||||
background-color: var(--lay-color-gray-13);
|
||||
color: var(--lay-color-text-1)
|
||||
}
|
||||
|
||||
.layui-table-tips-c:hover {
|
||||
background-color: var(--lay-color-gray-10)
|
||||
}
|
||||
|
||||
/** 文件上传 **/
|
||||
.layui-upload-choose {
|
||||
color: var(--lay-color-gray-8)
|
||||
@@ -1411,7 +1427,7 @@
|
||||
.layui-code {
|
||||
border: 1px solid var(--lay-color-border-2);
|
||||
background-color: var(--lay-color-bg-white);
|
||||
color: var(--lay-color-black-5)
|
||||
color: var(--lay-color-text-2)
|
||||
}
|
||||
|
||||
/** 穿梭框 **/
|
||||
@@ -1634,37 +1650,58 @@
|
||||
/*code 不处理*/
|
||||
.layui-code-view {
|
||||
border: 1px solid var(--lay-color-border-1);
|
||||
}
|
||||
|
||||
.layui-code-view:not(.layui-code-hl) {
|
||||
background-color: var(--lay-color-bg-2);
|
||||
color: var(--lay-color-text-2);
|
||||
border-left-width: 6px;
|
||||
}
|
||||
|
||||
.layui-code-title {
|
||||
border-bottom: 1px solid var(--lay-color-border-2)
|
||||
}
|
||||
|
||||
.layui-code-title > .layui-code-about {
|
||||
color: #c5c5c5
|
||||
}
|
||||
|
||||
.layui-code-view > .layui-code-ol > li {
|
||||
border-left: 1px solid var(--lay-color-border-2);
|
||||
.layui-code-header {
|
||||
border-bottom: 1px solid var(--lay-color-border-1);
|
||||
background-color: var(--lay-color-bg-2)
|
||||
}
|
||||
|
||||
.layui-code-view > .layui-code-ul > li {
|
||||
background-color: var(--lay-color-bg-2)
|
||||
.layui-code-header > .layui-code-header-about {
|
||||
color: var(--lay-color-text-2);
|
||||
}
|
||||
|
||||
.layui-code-dark {
|
||||
border: 1px solid #3d3d3d;
|
||||
border-left-color: #656565;
|
||||
background-color: #3d3d3d;
|
||||
color: var(--lay-color-gray-8)
|
||||
.layui-code-view:not(.layui-code-hl) .layui-code-ln-side {
|
||||
border-color: var(--lay-color-border-1);
|
||||
background-color: var(--lay-color-bg-2);
|
||||
}
|
||||
|
||||
.layui-code-dark > .layui-code-ol > li, .layui-code-dark > .layui-code-ul > li {
|
||||
background-color: #3f3f3f
|
||||
.layui-code-nowrap > .layui-code-ln-side {
|
||||
background: none !important;
|
||||
}
|
||||
|
||||
.layui-code-fixbar > span {
|
||||
color: var(--lay-color-text-3);
|
||||
}
|
||||
|
||||
.layui-code-fixbar > span:hover {
|
||||
color: var(--lay-color-secondary-hover);
|
||||
}
|
||||
|
||||
.layui-code-theme-dark {
|
||||
border-color: rgb(126 122 122 / 15%);
|
||||
background-color: #1f1f1f;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.layui-code-theme-dark > .layui-code-ln-side {
|
||||
border-right-color: #2a2a2a;
|
||||
background: none;
|
||||
color: #6e7681;
|
||||
}
|
||||
|
||||
.layui-code-view.layui-code-hl > .layui-code-ln-side {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.layui-code-theme-dark.layui-code-hl,
|
||||
.layui-code-theme-dark.layui-code-hl > .layui-code-ln-side {
|
||||
border-color: rgb(126 122 122 / 15%);
|
||||
}
|
||||
|
||||
.layui-code-full {
|
||||
@@ -2183,12 +2220,4 @@
|
||||
.layui-slider-input .layui-input {
|
||||
background-color: var(--lay-color-bg-2);
|
||||
}
|
||||
|
||||
a {
|
||||
color: var(--lay-color-text-1)
|
||||
}
|
||||
|
||||
.layui-code, pre > code {
|
||||
background-color: var(--lay-color-bg-2)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ var loadServerInfo = (function ($) {
|
||||
var chart = echarts.init(chartDom);
|
||||
var option = {
|
||||
title: {
|
||||
text: i18n['Proxies'],
|
||||
text: i18n['Proxy'],
|
||||
subtext: i18n['now'],
|
||||
left: 'center',
|
||||
textStyle: {
|
||||
|
||||
@@ -227,10 +227,7 @@ var loadUserList = (function ($) {
|
||||
* set verify rule of layui.form
|
||||
*/
|
||||
(function setFormVerifyRule() {
|
||||
layui.form.set({
|
||||
verIncludeRequired: true,
|
||||
verify: verifyRules
|
||||
});
|
||||
layui.form.verify(verifyRules);
|
||||
})();
|
||||
|
||||
/**
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -13,7 +13,7 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
const version = "1.4.0"
|
||||
const version = "1.5.0"
|
||||
|
||||
var (
|
||||
showVersion bool
|
||||
@@ -40,23 +40,17 @@ var rootCmd = &cobra.Command{
|
||||
}
|
||||
rootDir := filepath.Dir(executable)
|
||||
|
||||
common, tokens, ports, domains, subdomains, iniFile, err := ParseConfigFile(configFile)
|
||||
config, tls, err := ParseConfigFile(configFile)
|
||||
if err != nil {
|
||||
log.Printf("fail to start frps-panel : %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
s, err := server.New(
|
||||
rootDir,
|
||||
controller.HandleController{
|
||||
CommonInfo: common,
|
||||
Tokens: tokens,
|
||||
Ports: ports,
|
||||
Domains: domains,
|
||||
Subdomains: subdomains,
|
||||
ConfigFile: configFile,
|
||||
IniFile: iniFile,
|
||||
Version: version,
|
||||
})
|
||||
config,
|
||||
tls,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -74,12 +68,16 @@ func Execute() {
|
||||
}
|
||||
}
|
||||
|
||||
func ParseConfigFile(file string) (controller.CommonInfo, map[string]controller.TokenInfo, map[string][]string, map[string][]string, map[string][]string, *ini.File, error) {
|
||||
func ParseConfigFile(file string) (controller.HandleController, server.TLS, error) {
|
||||
common := controller.CommonInfo{}
|
||||
users := make(map[string]controller.TokenInfo)
|
||||
ports := make(map[string][]string)
|
||||
domains := make(map[string][]string)
|
||||
subdomains := make(map[string][]string)
|
||||
tls := server.TLS{
|
||||
Enable: false,
|
||||
Protocol: "HTTP",
|
||||
}
|
||||
|
||||
iniFile, err := ini.LoadSources(ini.LoadOptions{
|
||||
Insensitive: false,
|
||||
@@ -95,27 +93,61 @@ func ParseConfigFile(file string) (controller.CommonInfo, map[string]controller.
|
||||
} else {
|
||||
log.Printf("fail to parse token file %s : %v", file, err)
|
||||
}
|
||||
return common, nil, nil, nil, nil, iniFile, err
|
||||
return controller.HandleController{
|
||||
CommonInfo: common,
|
||||
Tokens: nil,
|
||||
Ports: nil,
|
||||
Domains: nil,
|
||||
Subdomains: nil,
|
||||
IniFile: iniFile,
|
||||
}, tls, err
|
||||
}
|
||||
|
||||
commonSection, err := iniFile.GetSection("common")
|
||||
if err != nil {
|
||||
log.Printf("fail to get [common] section from file %s : %v", file, err)
|
||||
return common, nil, nil, nil, nil, iniFile, err
|
||||
return controller.HandleController{
|
||||
CommonInfo: common,
|
||||
Tokens: nil,
|
||||
Ports: nil,
|
||||
Domains: nil,
|
||||
Subdomains: nil,
|
||||
IniFile: iniFile,
|
||||
}, tls, err
|
||||
}
|
||||
common.PluginAddr = commonSection.Key("plugin_addr").MustString("0.0.0.0")
|
||||
common.PluginPort = commonSection.Key("plugin_port").MustInt(7200)
|
||||
common.User = commonSection.Key("admin_user").Value()
|
||||
common.Pwd = commonSection.Key("admin_pwd").Value()
|
||||
common.DashboardTLS = commonSection.Key("dashboard_tls").MustBool(false)
|
||||
common.DashboardAddr = commonSection.Key("dashboard_addr").MustString("127.0.0.1")
|
||||
common.DashboardPort = commonSection.Key("dashboard_port").MustInt(7500)
|
||||
common.DashboardUser = commonSection.Key("dashboard_user").Value()
|
||||
common.DashboardPwd = commonSection.Key("dashboard_pwd").Value()
|
||||
|
||||
tls.Enable = commonSection.Key("tls_mode").MustBool(false)
|
||||
tls.Cert = commonSection.Key("tls_cert_file").MustString("")
|
||||
tls.Key = commonSection.Key("tls_key_file").MustString("")
|
||||
if tls.Enable {
|
||||
tls.Protocol = "HTTPS"
|
||||
}
|
||||
if tls.Enable && (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.")
|
||||
}
|
||||
|
||||
portsSection, err := iniFile.GetSection("ports")
|
||||
if err != nil {
|
||||
log.Printf("fail to get [ports] section from file %s : %v", file, err)
|
||||
return common, nil, nil, nil, nil, iniFile, err
|
||||
return controller.HandleController{
|
||||
CommonInfo: common,
|
||||
Tokens: nil,
|
||||
Ports: nil,
|
||||
Domains: nil,
|
||||
Subdomains: nil,
|
||||
IniFile: iniFile,
|
||||
}, tls, err
|
||||
}
|
||||
for _, key := range portsSection.Keys() {
|
||||
user := key.Name()
|
||||
@@ -127,7 +159,14 @@ func ParseConfigFile(file string) (controller.CommonInfo, map[string]controller.
|
||||
domainsSection, err := iniFile.GetSection("domains")
|
||||
if err != nil {
|
||||
log.Printf("fail to get [domains] section from file %s : %v", file, err)
|
||||
return common, nil, nil, nil, nil, iniFile, err
|
||||
return controller.HandleController{
|
||||
CommonInfo: common,
|
||||
Tokens: nil,
|
||||
Ports: nil,
|
||||
Domains: nil,
|
||||
Subdomains: nil,
|
||||
IniFile: iniFile,
|
||||
}, tls, err
|
||||
}
|
||||
for _, key := range domainsSection.Keys() {
|
||||
user := key.Name()
|
||||
@@ -139,7 +178,14 @@ func ParseConfigFile(file string) (controller.CommonInfo, map[string]controller.
|
||||
subdomainsSection, err := iniFile.GetSection("subdomains")
|
||||
if err != nil {
|
||||
log.Printf("fail to get [subdomains] section from file %s : %v", file, err)
|
||||
return common, nil, nil, nil, nil, iniFile, err
|
||||
return controller.HandleController{
|
||||
CommonInfo: common,
|
||||
Tokens: nil,
|
||||
Ports: nil,
|
||||
Domains: nil,
|
||||
Subdomains: nil,
|
||||
IniFile: iniFile,
|
||||
}, tls, err
|
||||
}
|
||||
for _, key := range subdomainsSection.Keys() {
|
||||
user := key.Name()
|
||||
@@ -151,13 +197,27 @@ func ParseConfigFile(file string) (controller.CommonInfo, map[string]controller.
|
||||
usersSection, err := iniFile.GetSection("users")
|
||||
if err != nil {
|
||||
log.Printf("fail to get [users] section from file %s : %v", file, err)
|
||||
return common, nil, nil, nil, nil, iniFile, err
|
||||
return controller.HandleController{
|
||||
CommonInfo: common,
|
||||
Tokens: nil,
|
||||
Ports: nil,
|
||||
Domains: nil,
|
||||
Subdomains: nil,
|
||||
IniFile: iniFile,
|
||||
}, tls, err
|
||||
}
|
||||
|
||||
disabledSection, err := iniFile.GetSection("disabled")
|
||||
if err != nil {
|
||||
log.Printf("fail to get [disabled] section from file %s : %v", file, err)
|
||||
return common, nil, nil, nil, nil, iniFile, err
|
||||
return controller.HandleController{
|
||||
CommonInfo: common,
|
||||
Tokens: nil,
|
||||
Ports: nil,
|
||||
Domains: nil,
|
||||
Subdomains: nil,
|
||||
IniFile: iniFile,
|
||||
}, tls, err
|
||||
}
|
||||
|
||||
keys := usersSection.Keys()
|
||||
@@ -177,6 +237,14 @@ func ParseConfigFile(file string) (controller.CommonInfo, map[string]controller.
|
||||
}
|
||||
users[token.User] = token
|
||||
}
|
||||
|
||||
return common, users, ports, domains, subdomains, iniFile, nil
|
||||
return controller.HandleController{
|
||||
CommonInfo: common,
|
||||
Tokens: users,
|
||||
Ports: ports,
|
||||
Domains: domains,
|
||||
Subdomains: subdomains,
|
||||
ConfigFile: configFile,
|
||||
IniFile: iniFile,
|
||||
Version: version,
|
||||
}, tls, nil
|
||||
}
|
||||
|
||||
46
config/cert.crt
Normal file
46
config/cert.crt
Normal file
@@ -0,0 +1,46 @@
|
||||
-----BEGIN CERTIFICATE-----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6Yru85GZZk+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/tPL5XMBFwTTxPvf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
|
||||
tPc3hxJBZUpWSkyZ5YJmMIPvTkWdXrMVfsaVfkBl1bliEZClTo1SxnYW+TNBMR88
|
||||
6/5QecnIyrI0vvcY7z51TGkCgYB8CpYEc5Z9WHkUPG7PJY+V0uE2tSFnf9m5BDW5
|
||||
3jJoJzEIW8/JJB0J6ijgxzFP+fgwzGInxfvfKkrJpqenKaiPHUyvmSVDRHMqGzGJ
|
||||
12saSmzOb15qe1YB2CJ0QK6J5Q7HcYwT0dDqq5szqw7OSb7+e7u1POx3jpaXDadL
|
||||
PW4OhwKBgHcZWsXJUaKesNJbeGeRKmQHooSdrE69gika1HU7GYmTV3JwvAFrHSNF
|
||||
EGMMTmWc6nTh63ADO/f+dpAoJVOQM/OhEVVyfvlByLEFeieGegwyREWVYajW+6Dt
|
||||
Ztrafmyvn+r3yhWN9g+p1yQTeVLw23ir9cYhP8OqnL4d89c3o+r3
|
||||
-----END RSA PRIVATE KEY-----
|
||||
@@ -1,15 +1,23 @@
|
||||
; basic options
|
||||
[common]
|
||||
; frps panel config info
|
||||
plugin_addr = 127.0.0.1
|
||||
plugin_port = 7200
|
||||
admin_user = admin
|
||||
admin_pwd = admin
|
||||
plugin_addr = 127.0.0.1
|
||||
plugin_port = 7200
|
||||
admin_user = admin
|
||||
admin_pwd = admin
|
||||
|
||||
; enable tls
|
||||
tls_mode = false
|
||||
; tls_cert_file = cert.crt
|
||||
; tls_key_file = cert.key
|
||||
|
||||
; frp dashboard info
|
||||
dashboard_addr = 127.0.0.1
|
||||
dashboard_port = 7500
|
||||
dashboard_user = admin
|
||||
dashboard_pwd = admin
|
||||
dashboard_pwd = admin
|
||||
; if your frps dashboard enable tls, change this to true
|
||||
dashboard_tls = false
|
||||
|
||||
; user tokens
|
||||
[users]
|
||||
|
||||
10
package.sh
10
package.sh
@@ -5,8 +5,12 @@ list=$(ls frps-panel-*)
|
||||
echo "$list"
|
||||
for binFile in $list
|
||||
do
|
||||
cp "$binFile" frps-panel
|
||||
zip -r "$binFile".zip frps-panel frps-panel.ini assets -x "*.git*" "*.idea*" "*.DS_Store" "*.contentFlavour"
|
||||
rm -rf "$binFile" frps-panel
|
||||
tmpFile=frps-panel
|
||||
if echo "$binFile" | grep -q -E "\.exe";then
|
||||
tmpFile=frps-panel.exe
|
||||
fi
|
||||
cp "$binFile" "$tmpFile"
|
||||
zip -r "$binFile".zip "$tmpFile" frps-panel.ini assets -x "*.git*" "*.idea*" "*.DS_Store" "*.contentFlavour"
|
||||
rm -rf "$binFile" "$tmpFile"
|
||||
done
|
||||
rm -rf frps-panel.ini assets
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
@@ -46,6 +47,7 @@ type CommonInfo struct {
|
||||
PluginPort int
|
||||
User string
|
||||
Pwd string
|
||||
DashboardTLS bool
|
||||
DashboardAddr string
|
||||
DashboardPort int
|
||||
DashboardUser string
|
||||
@@ -289,6 +291,7 @@ func (c *HandleController) MakeLangFunc() func(context *gin.Context) {
|
||||
"now": ginI18n.MustGetMessage(context, "now"),
|
||||
"Proxies": ginI18n.MustGetMessage(context, "Proxies"),
|
||||
"NotSet": ginI18n.MustGetMessage(context, "Not Set"),
|
||||
"Proxy": ginI18n.MustGetMessage(context, "Proxy"),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -696,10 +699,27 @@ func (c *HandleController) MakeEnableTokensFunc() func(context *gin.Context) {
|
||||
|
||||
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 := "http://" + host + ":" + strconv.Itoa(port) + context.Param("serverApi")
|
||||
requestUrl := protocol + host + ":" + strconv.Itoa(port) + context.Param("serverApi")
|
||||
request, _ := http.NewRequest("GET", requestUrl, nil)
|
||||
username := c.CommonInfo.DashboardUser
|
||||
if len(strings.TrimSpace(username)) != 0 {
|
||||
@@ -709,7 +729,8 @@ func (c *HandleController) MakeProxyFunc() func(context *gin.Context) {
|
||||
request.Header.Add("Authorization", authorization)
|
||||
log.Printf("Proxy to %s with Authorization %s", requestUrl, authorization)
|
||||
}
|
||||
response, err := http.DefaultClient.Do(request)
|
||||
|
||||
response, err := client.Do(request)
|
||||
|
||||
if err != nil {
|
||||
res.Code = FrpServerError
|
||||
|
||||
@@ -22,16 +22,26 @@ import (
|
||||
type Server struct {
|
||||
cfg controller.HandleController
|
||||
s *http.Server
|
||||
tls TLS
|
||||
done chan struct{}
|
||||
rootDir string
|
||||
}
|
||||
|
||||
func New(rootDir string, cfg controller.HandleController) (*Server, error) {
|
||||
type TLS struct {
|
||||
Enable bool
|
||||
Cert string
|
||||
Key string
|
||||
Protocol string
|
||||
}
|
||||
|
||||
func New(rootDir string, cfg controller.HandleController, tls TLS) (*Server, error) {
|
||||
s := &Server{
|
||||
cfg: cfg,
|
||||
done: make(chan struct{}),
|
||||
rootDir: rootDir,
|
||||
tls: tls,
|
||||
}
|
||||
|
||||
if err := s.init(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -44,10 +54,32 @@ func (s *Server) Run() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Printf("HTTP server listen on %s", l.Addr().String())
|
||||
log.Printf("%s server listen on %s", s.tls.Protocol, l.Addr().String())
|
||||
go func() {
|
||||
if err = s.s.Serve(l); !errors.Is(http.ErrServerClosed, err) {
|
||||
log.Printf("error shutdown HTTP server: %v", err)
|
||||
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
|
||||
@@ -58,16 +90,17 @@ func (s *Server) Stop() error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
if err := s.s.Shutdown(ctx); err != nil {
|
||||
log.Fatalf("shutdown HTTP server error: %v", err)
|
||||
log.Fatalf("shutdown %s server error: %v", s.tls.Protocol, err)
|
||||
}
|
||||
log.Printf("HTTP server exited")
|
||||
log.Printf("%s server exited", s.tls.Protocol)
|
||||
|
||||
close(s.done)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Server) init() error {
|
||||
if err := s.initHTTPServer(); err != nil {
|
||||
log.Printf("init HTTP server error: %v", err)
|
||||
log.Printf("init %s server error: %v", s.tls.Protocol, err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user