mirror of
https://github.com/yhl452493373/frps-panel.git
synced 2026-04-04 06:16:59 +08:00
support skip tls for frps dashboard
This commit is contained in:
@@ -119,6 +119,7 @@ func ParseConfigFile(file string) (controller.HandleController, server.TLS, erro
|
|||||||
common.PluginPort = commonSection.Key("plugin_port").MustInt(7200)
|
common.PluginPort = commonSection.Key("plugin_port").MustInt(7200)
|
||||||
common.User = commonSection.Key("admin_user").Value()
|
common.User = commonSection.Key("admin_user").Value()
|
||||||
common.Pwd = commonSection.Key("admin_pwd").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.DashboardAddr = commonSection.Key("dashboard_addr").MustString("127.0.0.1")
|
||||||
common.DashboardPort = commonSection.Key("dashboard_port").MustInt(7500)
|
common.DashboardPort = commonSection.Key("dashboard_port").MustInt(7500)
|
||||||
common.DashboardUser = commonSection.Key("dashboard_user").Value()
|
common.DashboardUser = commonSection.Key("dashboard_user").Value()
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ dashboard_addr = 127.0.0.1
|
|||||||
dashboard_port = 7500
|
dashboard_port = 7500
|
||||||
dashboard_user = admin
|
dashboard_user = admin
|
||||||
dashboard_pwd = admin
|
dashboard_pwd = admin
|
||||||
|
; if your frps dashboard enable tls, change this to true
|
||||||
|
dashboard_tls = false
|
||||||
|
|
||||||
; user tokens
|
; user tokens
|
||||||
[users]
|
[users]
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package controller
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/tls"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
@@ -46,6 +47,7 @@ type CommonInfo struct {
|
|||||||
PluginPort int
|
PluginPort int
|
||||||
User string
|
User string
|
||||||
Pwd string
|
Pwd string
|
||||||
|
DashboardTLS bool
|
||||||
DashboardAddr string
|
DashboardAddr string
|
||||||
DashboardPort int
|
DashboardPort int
|
||||||
DashboardUser string
|
DashboardUser string
|
||||||
@@ -697,10 +699,27 @@ func (c *HandleController) MakeEnableTokensFunc() func(context *gin.Context) {
|
|||||||
|
|
||||||
func (c *HandleController) MakeProxyFunc() func(context *gin.Context) {
|
func (c *HandleController) MakeProxyFunc() func(context *gin.Context) {
|
||||||
return 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{}
|
res := ProxyResponse{}
|
||||||
host := c.CommonInfo.DashboardAddr
|
host := c.CommonInfo.DashboardAddr
|
||||||
port := c.CommonInfo.DashboardPort
|
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)
|
request, _ := http.NewRequest("GET", requestUrl, nil)
|
||||||
username := c.CommonInfo.DashboardUser
|
username := c.CommonInfo.DashboardUser
|
||||||
if len(strings.TrimSpace(username)) != 0 {
|
if len(strings.TrimSpace(username)) != 0 {
|
||||||
@@ -710,7 +729,8 @@ func (c *HandleController) MakeProxyFunc() func(context *gin.Context) {
|
|||||||
request.Header.Add("Authorization", authorization)
|
request.Header.Add("Authorization", authorization)
|
||||||
log.Printf("Proxy to %s with Authorization %s", requestUrl, 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 {
|
if err != nil {
|
||||||
res.Code = FrpServerError
|
res.Code = FrpServerError
|
||||||
|
|||||||
Reference in New Issue
Block a user