18 Commits

Author SHA1 Message Date
杨黄林
cbd9611c3d Merge pull request #7 from mourenZhu/main
fix: JudgePort Function
2023-10-08 09:28:31 +08:00
zhumouren
8d54567c0f fix JudgePort Function
1: fix portAllowed judge
2: fix domainAllowed judge
3: fix subdomainAllowed judge
2023-10-07 14:46:27 +08:00
zhumouren
245f4fa32f fix proxyType judge in JudgePort Function 2023-10-07 11:58:39 +08:00
4a714dcd0e fix proxy to https issue 2023-09-27 14:05:25 +08:00
43d3ef275e fix proxy to https issue 2023-09-27 14:02:12 +08:00
d581a65002 update version code 2023-09-27 12:03:22 +08:00
f6d2362f48 fix dashboard_addr https issue 2023-09-27 12:01:29 +08:00
53ba8780ff update version code 2023-09-26 13:13:10 +08:00
0dc6d9bc12 solve http login issue 2023-09-26 13:11:38 +08:00
a8165c9b93 Merge remote-tracking branch 'origin/main' 2023-09-26 10:44:12 +08:00
bd83acef45 update readme 2023-09-26 10:44:01 +08:00
杨黄林
b18d06d83d remove cert 2023-09-26 00:39:24 +08:00
杨黄林
eef4390878 Merge remote-tracking branch 'origin/main' 2023-09-25 22:59:33 +08:00
杨黄林
621893872d update page color 2023-09-25 22:59:23 +08:00
8d61054332 update tips 2023-09-22 15:33:05 +08:00
7cf43c869a update tip 2023-09-22 15:31:17 +08:00
70bddc6c1b customize scrollbar background color 2023-09-21 15:00:36 +08:00
db0a36fc00 update 404 tips 2023-09-20 14:58:41 +08:00
11 changed files with 66 additions and 94 deletions

View File

@@ -85,7 +85,7 @@ dashboard_pwd = "admin"
enable = false enable = false
``` ```
3. 运行 frps-panel指定监听地址以及 token 存储文件路径。 3. 运行 frps-panel指定配置文件路径。
`./frps-panel -c ./frps-panel.toml` `./frps-panel -c ./frps-panel.toml`

View File

@@ -1,3 +1,7 @@
::-webkit-scrollbar-thumb {
background: rgba(199, 199, 199, 0.8);
}
.layui-bg-blue { .layui-bg-blue {
background-color: #58b7ff !important; background-color: #58b7ff !important;
} }
@@ -29,6 +33,10 @@
border-color: #ff5722 !important; border-color: #ff5722 !important;
} }
.layui-laypage a:hover {
color: #409eff;
}
.layui-laypage .layui-laypage-curr .layui-laypage-em { .layui-laypage .layui-laypage-curr .layui-laypage-em {
background-color: #409eff; background-color: #409eff;
} }
@@ -132,6 +140,10 @@ section.proxy-list .proxy-info .layui-row .layui-row > div:first-child {
} }
@media (prefers-color-scheme: dark) { @media (prefers-color-scheme: dark) {
::-webkit-scrollbar-thumb {
background: rgba(107, 107, 107, 0.8);
}
.login-title, .login-title,
.login-title a { .login-title a {
color: #99a9bf !important; color: #99a9bf !important;
@@ -164,6 +176,10 @@ section.proxy-list .proxy-info .layui-row .layui-row > div:first-child {
box-shadow: none; box-shadow: none;
} }
.layui-laypage a:hover {
color: #4f80a1;
}
.layui-laypage .layui-laypage-curr .layui-laypage-em { .layui-laypage .layui-laypage-curr .layui-laypage-em {
background-color: #4f80a1; background-color: #4f80a1;
} }

View File

@@ -1,3 +1,13 @@
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-thumb {
border-radius: 4px;
transition: 0.3s ease-in-out;
}
html, body { html, body {
padding: 0; padding: 0;
word-break: break-all; word-break: break-all;

View File

@@ -12,7 +12,7 @@ import (
"strings" "strings"
) )
const version = "1.7.0" const version = "1.7.2"
var ( var (
showVersion bool showVersion bool
@@ -87,7 +87,7 @@ func parseConfigFile(configFile, tokensFile string) (controller.HandleController
} }
} }
common.Common.DashboardTls = strings.HasPrefix("https://", strings.ToLower(common.Common.DashboardAddr)) common.Common.DashboardTls = strings.HasPrefix(strings.ToLower(common.Common.DashboardAddr), "https://")
tls := server.TLS{ tls := server.TLS{
Enable: common.Common.TlsMode, Enable: common.Common.TlsMode,

View File

@@ -1,46 +0,0 @@
-----BEGIN CERTIFICATE-----
MIIDwDCCAqigAwIBAgIIYb+7dG3vm+swDQYJKoZIhvcNAQELBQAwejELMAkGA1UE
BhMCQ04xFzAVBgNVBAoTDktleU1hbmFnZXIub3JnMTEwLwYDVQQLEyhLZXlNYW5h
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keep_time = 0 admin_keep_time = 0
# enable tls # enable tls
tls_mode = true tls_mode = false
tls_cert_file = "cert.crt" #tls_cert_file = "cert.crt"
tls_key_file = "cert.key" #tls_key_file = "cert.key"
# frp dashboard info # frp dashboard info
dashboard_addr = "127.0.0.1" dashboard_addr = "127.0.0.1"

2
go.mod
View File

@@ -8,7 +8,6 @@ require (
github.com/gin-contrib/i18n v1.0.0 github.com/gin-contrib/i18n v1.0.0
github.com/gin-contrib/sessions v0.0.5 github.com/gin-contrib/sessions v0.0.5
github.com/gin-gonic/gin v1.9.1 github.com/gin-gonic/gin v1.9.1
github.com/pelletier/go-toml/v2 v2.0.9
github.com/spf13/cobra v0.0.3 github.com/spf13/cobra v0.0.3
golang.org/x/text v0.11.0 golang.org/x/text v0.11.0
) )
@@ -36,6 +35,7 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/nicksnyder/go-i18n/v2 v2.2.1 // indirect github.com/nicksnyder/go-i18n/v2 v2.2.1 // indirect
github.com/pelletier/go-toml/v2 v2.0.9 // indirect
github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/pflag v1.0.5 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect github.com/ugorji/go/codec v1.2.11 // indirect

View File

@@ -325,7 +325,7 @@ func (c *HandleController) MakeAddTokenFunc() func(context *gin.Context) {
if err != nil { if err != nil {
response.Success = false response.Success = false
response.Code = SaveError response.Code = SaveError
response.Message = fmt.Sprintf("add failed, error : %v", err) response.Message = fmt.Sprintf("user add failed, error : %v", err)
log.Printf(response.Message) log.Printf(response.Message)
context.JSON(http.StatusOK, &response) context.JSON(http.StatusOK, &response)
return return
@@ -556,6 +556,9 @@ func (c *HandleController) MakeProxyFunc() func(context *gin.Context) {
res := ProxyResponse{} res := ProxyResponse{}
host := c.CommonInfo.DashboardAddr host := c.CommonInfo.DashboardAddr
port := c.CommonInfo.DashboardPort port := c.CommonInfo.DashboardPort
host, _ = strings.CutPrefix(host, protocol)
requestUrl := protocol + host + ":" + strconv.Itoa(port) + context.Param("serverApi") requestUrl := protocol + host + ":" + strconv.Itoa(port) + context.Param("serverApi")
request, _ := http.NewRequest("GET", requestUrl, nil) request, _ := http.NewRequest("GET", requestUrl, nil)
username := c.CommonInfo.DashboardUser username := c.CommonInfo.DashboardUser
@@ -586,10 +589,14 @@ func (c *HandleController) MakeProxyFunc() func(context *gin.Context) {
if res.Code == http.StatusOK { if res.Code == http.StatusOK {
res.Success = true res.Success = true
res.Data = string(body) res.Data = string(body)
res.Message = "Proxy to " + requestUrl + " success" res.Message = fmt.Sprintf("Proxy to %s success", requestUrl)
} else { } else {
res.Success = false res.Success = false
res.Message = "Proxy to " + requestUrl + " error: " + string(body) if res.Code == http.StatusNotFound {
res.Message = fmt.Sprintf("Proxy to %s error: url not found", requestUrl)
} else {
res.Message = fmt.Sprintf("Proxy to %s error: %s", requestUrl, string(body))
}
} }
} }
log.Printf(res.Message) log.Printf(res.Message)

View File

@@ -77,7 +77,7 @@ func (c *HandleController) JudgePort(content *plugin.NewProxyContent) plugin.Res
"tcp", "tcpmux", "udp", "http", "https", "tcp", "tcpmux", "udp", "http", "https",
} }
proxyType := content.ProxyType proxyType := content.ProxyType
if stringContains(proxyType, supportProxyTypes) { if !stringContains(proxyType, supportProxyTypes) {
log.Printf("proxy type [%v] not support, plugin do nothing", proxyType) log.Printf("proxy type [%v] not support, plugin do nothing", proxyType)
res.Unchange = true res.Unchange = true
return res return res
@@ -115,6 +115,10 @@ func (c *HandleController) JudgePort(content *plugin.NewProxyContent) plugin.Res
break break
} }
} else { } else {
if str == "" {
portAllowed = true
break
}
allowed, err := strconv.Atoi(str) allowed, err := strconv.Atoi(str)
if err != nil { if err != nil {
portErr = fmt.Errorf("user [%v] allowed port [%v] is not a number", user, port) portErr = fmt.Errorf("user [%v] allowed port [%v] is not a number", user, port)
@@ -148,13 +152,17 @@ func (c *HandleController) JudgePort(content *plugin.NewProxyContent) plugin.Res
if proxyType == "http" || proxyType == "https" || proxyType == "tcpmux" { if proxyType == "http" || proxyType == "https" || proxyType == "tcpmux" {
if portAllowed { if portAllowed {
if token, exist := c.Tokens[user]; exist { if token, exist := c.Tokens[user]; exist {
if stringContains("", token.Domains) {
domainAllowed = true
} else {
for _, userDomain := range userDomains { for _, userDomain := range userDomains {
if stringContains(userDomain, token.Domains) { if !stringContains(userDomain, token.Domains) {
domainAllowed = false domainAllowed = false
break break
} }
} }
} }
}
if !domainAllowed { if !domainAllowed {
portErr = fmt.Errorf("user [%v] domain [%v] is not allowed", user, strings.Join(userDomains, ",")) portErr = fmt.Errorf("user [%v] domain [%v] is not allowed", user, strings.Join(userDomains, ","))
reject = true reject = true
@@ -167,12 +175,16 @@ func (c *HandleController) JudgePort(content *plugin.NewProxyContent) plugin.Res
subdomainAllowed = false subdomainAllowed = false
if portAllowed && domainAllowed { if portAllowed && domainAllowed {
if token, exist := c.Tokens[user]; exist { if token, exist := c.Tokens[user]; exist {
if stringContains("", token.Subdomains) {
subdomainAllowed = true
} else {
for _, subdomain := range token.Subdomains { for _, subdomain := range token.Subdomains {
if subdomain == userSubdomain { if subdomain == userSubdomain {
subdomainAllowed = true subdomainAllowed = true
break break
} }
} }
}
} else { } else {
subdomainAllowed = true subdomainAllowed = true
} }

View File

@@ -175,9 +175,9 @@ func (s *Server) initHTTPServer() error {
engine := gin.New() engine := gin.New()
authStore := cookie.NewStore([]byte("frps-panel")) authStore := cookie.NewStore([]byte("frps-panel"))
authStore.Options(sessions.Options{ authStore.Options(sessions.Options{
Secure: true, Secure: false,
HttpOnly: false, HttpOnly: false,
SameSite: 4, SameSite: http.SameSiteDefaultMode,
Path: "/", Path: "/",
MaxAge: s.cfg.CommonInfo.AdminKeepTime, MaxAge: s.cfg.CommonInfo.AdminKeepTime,
}) })