This commit is contained in:
杨黄林
2023-09-26 00:34:08 +08:00
parent d8f2c949ba
commit 0cae84a9f8
9 changed files with 52 additions and 22 deletions

View File

@@ -65,5 +65,6 @@
"Param Error": "Param error", "Param Error": "Param error",
"Frp Client Error": "Frp client error", "Frp Client Error": "Frp client error",
"Proxy Exist,": "Proxy name exist", "Proxy Exist,": "Proxy name exist",
"Proxy Not Exist": "Proxy name not exist" "Proxy Not Exist": "Proxy name not exist",
"Client Tips": "Client tips"
} }

View File

@@ -65,5 +65,6 @@
"Param Error": "参数错误", "Param Error": "参数错误",
"Frp Client Error": "Frp客户端错误", "Frp Client Error": "Frp客户端错误",
"Proxy Exist": "代理名称重复", "Proxy Exist": "代理名称重复",
"Proxy Not Exist": "代理名称不存在" "Proxy Not Exist": "代理名称不存在",
"Client Tips": "客户端提示"
} }

View File

@@ -81,11 +81,11 @@ section {
} }
.layui-form-label { .layui-form-label {
width: 100px; width: 120px;
} }
.layui-input-block { .layui-input-block {
margin-left: 130px; margin-left: 150px;
} }
.layui-btn-sm { .layui-btn-sm {

View File

@@ -46,6 +46,7 @@ var loadProxyInfo = (function ($) {
temp.local_ip = temp.local_ip || '-'; temp.local_ip = temp.local_ip || '-';
temp.local_port = temp.local_port || '-'; temp.local_port = temp.local_port || '-';
temp.use_encryption = temp.use_encryption || false; temp.use_encryption = temp.use_encryption || false;
temp.use_compression = temp.use_compression || false;
if (currentProxyType === 'http' || currentProxyType === 'https') { if (currentProxyType === 'http' || currentProxyType === 'https') {
temp.custom_domains = temp.custom_domains || '-'; temp.custom_domains = temp.custom_domains || '-';
temp.subdomain = temp.subdomain || '-'; temp.subdomain = temp.subdomain || '-';
@@ -180,7 +181,7 @@ var loadProxyInfo = (function ($) {
type: 1, type: 1,
title: false, title: false,
skin: 'proxy-popup', skin: 'proxy-popup',
area: ['400px', '400px'], area: ['450px', '400px'],
content: content, content: content,
btn: [i18n['Confirm'], i18n['Cancel']], btn: [i18n['Confirm'], i18n['Cancel']],
btn1: function (index) { btn1: function (index) {
@@ -254,13 +255,15 @@ var loadProxyInfo = (function ($) {
data: JSON.stringify(data), data: JSON.stringify(data),
success: function (result) { success: function (result) {
if (result.success) { if (result.success) {
layui.layer.close(index);
reloadTable(); reloadTable();
layui.layer.close(index); layui.layer.msg(i18n['OperateSuccess']);
layui.layer.msg(i18n['OperateSuccess'], function (index) {
layui.layer.close(index);
});
} else { } else {
errorMsg(result); errorMsg(result);
if (result.code === 5) {
layui.layer.close(index);
reloadTable();
}
} }
}, },
complete: function () { complete: function () {
@@ -278,10 +281,19 @@ var loadProxyInfo = (function ($) {
layui.layer.msg(i18n['ShouldCheckProxy']); layui.layer.msg(i18n['ShouldCheckProxy']);
return; return;
} }
data.forEach(function (temp) {
for (var key in temp) {
if (typeof temp[key] === 'boolean') {
temp[key] = temp[key] + '';
}
}
});
layui.layer.confirm(i18n['ConfirmRemoveProxy'], { layui.layer.confirm(i18n['ConfirmRemoveProxy'], {
title: i18n['OperationConfirm'], title: i18n['OperationConfirm'],
btn: [i18n['Confirm'], i18n['Cancel']] btn: [i18n['Confirm'], i18n['Cancel']]
}, function (index) { }, function (index) {
layui.layer.close(index);
var loading = layui.layer.load(); var loading = layui.layer.load();
$.post({ $.post({
url: '/remove', url: '/remove',
@@ -290,13 +302,15 @@ var loadProxyInfo = (function ($) {
data: JSON.stringify(data), data: JSON.stringify(data),
success: function (result) { success: function (result) {
if (result.success) { if (result.success) {
layui.layer.close(index);
reloadTable(); reloadTable();
layui.layer.close(index); layui.layer.msg(i18n['OperateSuccess']);
layui.layer.msg(i18n['OperateSuccess'], function (index) {
layui.layer.close(index);
});
} else { } else {
errorMsg(result); errorMsg(result);
if (result.code === 5) {
layui.layer.close(index);
reloadTable();
}
} }
}, },
complete: function () { complete: function () {
@@ -327,7 +341,15 @@ var loadProxyInfo = (function ($) {
reason = i18n['ProxyExist']; reason = i18n['ProxyExist'];
else if (result.code === 4) else if (result.code === 4)
reason = i18n['ProxyNotExist']; reason = i18n['ProxyNotExist'];
layui.layer.msg(i18n['OperateFailed'] + ',' + reason) if (result.code === 5) {
layui.layer.alert(result.message, {
title: i18n['ClientTips'],
maxWidth: 350,
btn: [i18n['Confirm']]
});
} else {
layui.layer.msg(i18n['OperateFailed'] + ',' + reason);
}
} }
return loadProxyInfo; return loadProxyInfo;

View File

@@ -39,7 +39,7 @@ var loadOverview = (function ($) {
var $section = $('#content > section'); var $section = $('#content > section');
var cols = [ var cols = [
{field: 'name', title: i18n['Name'], sort: true}, {field: 'name', title: i18n['Name'], sort: true},
{field: 'type', title: i18n['Type'], width: 100, sort: true}, {field: 'type', title: i18n['Type'], width: 110, sort: true},
{ {
field: 'local_addr', field: 'local_addr',
title: i18n['LocalAddress'], title: i18n['LocalAddress'],

View File

@@ -3,8 +3,8 @@
# frps panel config info # frps panel config info
plugin_addr = "0.0.0.0" plugin_addr = "0.0.0.0"
plugin_port = 7300 plugin_port = 7300
#admin_user = "admin" admin_user = "admin"
#admin_pwd = "admin" admin_pwd = "admin"
# specified login state keep time # specified login state keep time
admin_keep_time = 0 admin_keep_time = 0

View File

@@ -134,6 +134,7 @@ func (c *HandleController) MakeLangFunc() func(context *gin.Context) {
"FrpClientError": ginI18n.MustGetMessage(context, "Frp Client Error"), "FrpClientError": ginI18n.MustGetMessage(context, "Frp Client Error"),
"ProxyExist": ginI18n.MustGetMessage(context, "Proxy Exist"), "ProxyExist": ginI18n.MustGetMessage(context, "Proxy Exist"),
"ProxyNotExist": ginI18n.MustGetMessage(context, "Proxy Not 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, NameKey)
delete(proxy, OldNameKey)
clientProxies[name] = proxy clientProxies[name] = proxy
res := c.UpdateFrpcConfig() res := c.UpdateFrpcConfig()
@@ -380,6 +382,7 @@ func (c *HandleController) UpdateFrpcConfig() ProxyResponse {
} }
c.parseResponse(&res, response) c.parseResponse(&res, response)
if res.Success { if res.Success {
c.ReloadFrpcConfig(&res) c.ReloadFrpcConfig(&res)
} }

View File

@@ -80,31 +80,33 @@ func (c *HandleController) getClientResponse(request *http.Request, client *http
return response, err 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 res.Code = response.StatusCode
body, err := io.ReadAll(response.Body) body, err := io.ReadAll(response.Body)
if err != nil { if err != nil {
res.Success = false res.Success = false
res.Message = err.Error() res.Message = err.Error()
} else { } else {
bodyString := string(body)
url := response.Request.URL url := response.Request.URL
if res.Code == http.StatusOK { if res.Code == http.StatusOK {
res.Success = true res.Success = true
res.Data = string(body) res.Data = bodyString
res.Message = fmt.Sprintf("Proxy to %s success", url) res.Message = fmt.Sprintf("Proxy to %s success", url)
} else { } else {
res.Success = false res.Success = false
if res.Code == http.StatusNotFound { if res.Code == http.StatusNotFound {
res.Message = fmt.Sprintf("Proxy to %s error: url not found", url) 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 { } 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) log.Printf(res.Message)
return string(body)
} }
func (c *HandleController) parseConfigure(content, proxyType string) (interface{}, error) { func (c *HandleController) parseConfigure(content, proxyType string) (interface{}, error) {

View File

@@ -10,6 +10,7 @@ const (
FrpClientError FrpClientError
ProxyExist ProxyExist
ProxyNotExist ProxyNotExist
ReloadFail
) )
const ( const (