mirror of
https://github.com/yhl452493373/frpc-panel.git
synced 2026-04-04 06:17:00 +08:00
optimze
This commit is contained in:
@@ -134,6 +134,7 @@ func (c *HandleController) MakeLangFunc() func(context *gin.Context) {
|
||||
"FrpClientError": ginI18n.MustGetMessage(context, "Frp Client Error"),
|
||||
"ProxyExist": ginI18n.MustGetMessage(context, "Proxy Exist"),
|
||||
"ProxyNotExist": ginI18n.MustGetMessage(context, "Proxy Not Exist"),
|
||||
"ClientTips": ginI18n.MustGetMessage(context, "Client Tips"),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -179,6 +180,7 @@ func (c *HandleController) MakeAddProxyFunc() func(context *gin.Context) {
|
||||
}
|
||||
|
||||
delete(proxy, NameKey)
|
||||
delete(proxy, OldNameKey)
|
||||
clientProxies[name] = proxy
|
||||
|
||||
res := c.UpdateFrpcConfig()
|
||||
@@ -380,6 +382,7 @@ func (c *HandleController) UpdateFrpcConfig() ProxyResponse {
|
||||
}
|
||||
|
||||
c.parseResponse(&res, response)
|
||||
|
||||
if res.Success {
|
||||
c.ReloadFrpcConfig(&res)
|
||||
}
|
||||
|
||||
@@ -80,31 +80,33 @@ func (c *HandleController) getClientResponse(request *http.Request, client *http
|
||||
return response, err
|
||||
}
|
||||
|
||||
func (c *HandleController) parseResponse(res *ProxyResponse, response *http.Response) string {
|
||||
func (c *HandleController) parseResponse(res *ProxyResponse, response *http.Response) {
|
||||
res.Code = response.StatusCode
|
||||
body, err := io.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
res.Success = false
|
||||
res.Message = err.Error()
|
||||
} else {
|
||||
bodyString := string(body)
|
||||
url := response.Request.URL
|
||||
if res.Code == http.StatusOK {
|
||||
res.Success = true
|
||||
res.Data = string(body)
|
||||
res.Data = bodyString
|
||||
res.Message = fmt.Sprintf("Proxy to %s success", url)
|
||||
} else {
|
||||
res.Success = false
|
||||
if res.Code == http.StatusNotFound {
|
||||
res.Message = fmt.Sprintf("Proxy to %s error: url not found", url)
|
||||
} else if res.Code == http.StatusBadRequest {
|
||||
res.Code = ReloadFail
|
||||
res.Message = bodyString
|
||||
} else {
|
||||
res.Message = fmt.Sprintf("Proxy to %s error: %s", url, string(body))
|
||||
res.Message = fmt.Sprintf("Proxy to %s error: %s", url, bodyString)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.Printf(res.Message)
|
||||
|
||||
return string(body)
|
||||
}
|
||||
|
||||
func (c *HandleController) parseConfigure(content, proxyType string) (interface{}, error) {
|
||||
|
||||
@@ -10,6 +10,7 @@ const (
|
||||
FrpClientError
|
||||
ProxyExist
|
||||
ProxyNotExist
|
||||
ReloadFail
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
Reference in New Issue
Block a user