mirror of
https://github.com/yhl452493373/frpc-panel.git
synced 2026-04-04 14:27:01 +08:00
support show proxy config of frpc 0.53
This commit is contained in:
@@ -217,12 +217,11 @@ section.client-info .text-row .text-col {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.proxy-popup .extra-param-tab-item .layui-form-item .layui-input-inline:nth-child(1) {
|
.proxy-popup .extra-param-tab-item .layui-form-item .layui-input-inline:nth-child(1) {
|
||||||
width: 150px;
|
width: 200px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.proxy-popup .extra-param-tab-item .layui-form-item .layui-input-inline:nth-child(3) {
|
.proxy-popup .extra-param-tab-item .layui-form-item .layui-input-inline:nth-child(3) {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
margin-right: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#searchForm input {
|
#searchForm input {
|
||||||
|
|||||||
@@ -1,11 +1,119 @@
|
|||||||
var loadProxyInfo = (function ($) {
|
var loadProxyInfo = (function ($) {
|
||||||
var i18n = {}, currentProxyType, currentTitle;
|
var i18n = {}, currentProxyType, currentTitle;
|
||||||
//param names in Basic tab
|
//param names in Basic tab
|
||||||
var basicParamNamesIgnore = ['toml'];
|
var basicParams = [
|
||||||
var basicParamNames = ['name', 'type', 'localIP', 'localPort', 'customDomains', 'subdomain', 'remotePort', 'useEncryption', 'useCompression'];
|
{
|
||||||
var basicParamNamesMap = {
|
name: 'name',
|
||||||
useEncryption: 'transport.useEncryption',
|
defaultValue: '-'
|
||||||
useCompression: 'transport.useCompression'
|
}, {
|
||||||
|
name: 'type',
|
||||||
|
defaultValue: '-'
|
||||||
|
}, {
|
||||||
|
name: 'localIP',
|
||||||
|
defaultValue: '-'
|
||||||
|
}, {
|
||||||
|
name: 'localPort',
|
||||||
|
defaultValue: '-'
|
||||||
|
}, {
|
||||||
|
name: 'customDomains',
|
||||||
|
defaultValue: '-'
|
||||||
|
}, {
|
||||||
|
name: 'subdomain',
|
||||||
|
defaultValue: '-'
|
||||||
|
}, {
|
||||||
|
name: 'remotePort',
|
||||||
|
defaultValue: '-'
|
||||||
|
}, {
|
||||||
|
name: 'transport.useEncryption',
|
||||||
|
defaultValue: 'true',
|
||||||
|
}, {
|
||||||
|
name: 'transport.useCompression',
|
||||||
|
defaultValue: 'true',
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* a.b.c = 1
|
||||||
|
* a.b.d = [2,3]
|
||||||
|
* to
|
||||||
|
* {a: {
|
||||||
|
* b: {
|
||||||
|
* c: 1
|
||||||
|
* d: "[2,3]"
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* @param obj json object
|
||||||
|
* @param names all names split from name string like 'a.b.c'
|
||||||
|
* @param value default value
|
||||||
|
*/
|
||||||
|
function expandJSON(obj, names, value) {
|
||||||
|
var currentIndex = this.index || 0;
|
||||||
|
var childrenIndex = (currentIndex + 1) > names.length ? null : (currentIndex + 1);
|
||||||
|
var currentName = names[currentIndex], currentValue = {};
|
||||||
|
var childrenName = childrenIndex == null ? null : names[childrenIndex];
|
||||||
|
if (obj.hasOwnProperty(currentName)) {
|
||||||
|
currentValue = obj[currentName];
|
||||||
|
} else {
|
||||||
|
obj[currentName] = currentValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (childrenName !== null) {
|
||||||
|
this.index = childrenIndex;
|
||||||
|
expandJSON(currentValue, names, value);
|
||||||
|
} else {
|
||||||
|
if (value != null) {
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
obj[currentName] = JSON.stringify(value);
|
||||||
|
} else {
|
||||||
|
obj[currentName] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.index = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {a: {
|
||||||
|
* b: {
|
||||||
|
* c: 1
|
||||||
|
* d: [2,3]
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* to
|
||||||
|
* {
|
||||||
|
* 'a.b.c': 1,
|
||||||
|
* 'a.b.d': '[2,3]'
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* @param obj json object
|
||||||
|
* @returns {*} flatted json key array
|
||||||
|
*/
|
||||||
|
function flatJSON(obj) {
|
||||||
|
var flat = function (obj, prentKey, flattedJSON) {
|
||||||
|
flattedJSON = flattedJSON || {};
|
||||||
|
prentKey = prentKey || '';
|
||||||
|
if (prentKey !== '')
|
||||||
|
prentKey = prentKey + '.';
|
||||||
|
for (var key in obj) {
|
||||||
|
var value = obj[key];
|
||||||
|
if (typeof value === 'object' && Object.prototype.toString.call(value) === '[object Object]') {
|
||||||
|
flat(value, prentKey + key, flattedJSON);
|
||||||
|
} else {
|
||||||
|
if (prentKey === 'plugin.ClientPluginOptions.')
|
||||||
|
prentKey = 'plugin.';
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
flattedJSON[prentKey + key] = JSON.stringify(value);
|
||||||
|
} else {
|
||||||
|
flattedJSON[prentKey + key] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return flattedJSON;
|
||||||
|
}
|
||||||
|
return flat(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -44,17 +152,25 @@ var loadProxyInfo = (function ($) {
|
|||||||
* @param data {[Map<string,string>]} proxy data
|
* @param data {[Map<string,string>]} proxy data
|
||||||
*/
|
*/
|
||||||
function renderProxyListTable(data) {
|
function renderProxyListTable(data) {
|
||||||
|
var proxies = [];
|
||||||
data.forEach(function (temp) {
|
data.forEach(function (temp) {
|
||||||
temp.name = temp.name || '-';
|
var proxy = temp.ProxyConfigurer;
|
||||||
temp.localIP = temp.localIP || '-';
|
basicParams.forEach(function (basicParam) {
|
||||||
temp.localPort = temp.localPort || '-';
|
var name = basicParam.name;
|
||||||
temp.transport = temp.transport || {};
|
var defaultValue = basicParam.defaultValue;
|
||||||
temp.transport.useEncryption = temp.transport.useEncryption || false;
|
var value = null;
|
||||||
temp.transport.useCompression = temp.transport.useCompression || false;
|
try {
|
||||||
if (currentProxyType === 'http' || currentProxyType === 'https') {
|
value = eval('proxy.' + name);
|
||||||
temp.customDomains = temp.customDomains || '-';
|
if (value == null) {
|
||||||
temp.subdomain = temp.subdomain || '-';
|
value = defaultValue;
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
value = defaultValue;
|
||||||
|
}
|
||||||
|
eval('proxy.' + name + ' = value');
|
||||||
|
|
||||||
|
});
|
||||||
|
proxies.push(proxy);
|
||||||
});
|
});
|
||||||
|
|
||||||
var $section = $('#content > section');
|
var $section = $('#content > section');
|
||||||
@@ -95,7 +211,7 @@ var loadProxyInfo = (function ($) {
|
|||||||
},
|
},
|
||||||
toolbar: '#proxyListToolbarTemplate',
|
toolbar: '#proxyListToolbarTemplate',
|
||||||
defaultToolbar: false,
|
defaultToolbar: false,
|
||||||
data: data,
|
data: proxies,
|
||||||
initSort: {
|
initSort: {
|
||||||
field: 'name',
|
field: 'name',
|
||||||
type: 'asc'
|
type: 'asc'
|
||||||
@@ -163,38 +279,31 @@ var loadProxyInfo = (function ($) {
|
|||||||
if (data != null) {
|
if (data != null) {
|
||||||
var tempData = $.extend(true, {}, data);
|
var tempData = $.extend(true, {}, data);
|
||||||
|
|
||||||
basicParamNamesIgnore.forEach(function (basicName) {
|
basicParams.forEach(function (basicName) {
|
||||||
if (basicParamNamesMap.hasOwnProperty(basicName)) {
|
var name = basicName.name;
|
||||||
try {
|
if (name.indexOf('.') !== -1) {
|
||||||
eval('delete tempData.' + basicParamNamesMap[basicName])
|
var names = name.split('.');
|
||||||
} catch (e) {
|
expandJSON(tempData, names, 0, basicName.defaultValue);
|
||||||
}
|
expandJSON(basicData, names, 0, null);
|
||||||
} else if (data.hasOwnProperty(basicName)) {
|
|
||||||
delete tempData[basicName];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eval('basicData.' + name + ' = ' + 'tempData.' + name);
|
||||||
|
eval('delete tempData.' + name)
|
||||||
});
|
});
|
||||||
|
|
||||||
basicParamNames.forEach(function (basicName) {
|
var flatted = flatJSON(tempData);
|
||||||
if (basicParamNamesMap.hasOwnProperty(basicName)) {
|
|
||||||
try {
|
|
||||||
basicData[basicName] = eval('tempData.' + basicParamNamesMap[basicName]);
|
|
||||||
eval('delete tempData.' + basicParamNamesMap[basicName])
|
|
||||||
} catch (e) {
|
|
||||||
basicData[basicName] = true;
|
|
||||||
}
|
|
||||||
} else if (data.hasOwnProperty(basicName)) {
|
|
||||||
basicData[basicName] = tempData[basicName];
|
|
||||||
delete tempData[basicName];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
for (var key in tempData) {
|
for (var key in flatted) {
|
||||||
|
var value = flatted[key];
|
||||||
|
if (value == null || value === '')
|
||||||
|
continue;
|
||||||
extraData.push({
|
extraData.push({
|
||||||
name: key,
|
name: key,
|
||||||
value: tempData[key]
|
value: value
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var html = document.getElementById('addProxyTemplate').innerHTML;
|
var html = document.getElementById('addProxyTemplate').innerHTML;
|
||||||
var content = layui.laytpl(html).render({
|
var content = layui.laytpl(html).render({
|
||||||
type: currentProxyType,
|
type: currentProxyType,
|
||||||
@@ -204,7 +313,7 @@ var loadProxyInfo = (function ($) {
|
|||||||
type: 1,
|
type: 1,
|
||||||
title: false,
|
title: false,
|
||||||
skin: 'proxy-popup',
|
skin: 'proxy-popup',
|
||||||
area: ['450px', '400px'],
|
area: ['550px', '400px'],
|
||||||
content: content,
|
content: content,
|
||||||
btn: [i18n['Confirm'], i18n['Cancel']],
|
btn: [i18n['Confirm'], i18n['Cancel']],
|
||||||
btn1: function (index) {
|
btn1: function (index) {
|
||||||
@@ -216,7 +325,6 @@ var loadProxyInfo = (function ($) {
|
|||||||
var value = $(this).find('input').last().val();
|
var value = $(this).find('input').last().val();
|
||||||
formData[name] = value;
|
formData[name] = value;
|
||||||
});
|
});
|
||||||
|
|
||||||
addOrUpdate(formData, index, update);
|
addOrUpdate(formData, index, update);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -227,7 +335,7 @@ var loadProxyInfo = (function ($) {
|
|||||||
//get and set old name for update form
|
//get and set old name for update form
|
||||||
var oldNameKey = layero.find('#oldName').attr('name');
|
var oldNameKey = layero.find('#oldName').attr('name');
|
||||||
basicData[oldNameKey] = basicData.name;
|
basicData[oldNameKey] = basicData.name;
|
||||||
layui.form.val('addProxyForm', basicData);
|
layui.form.val('addProxyForm', flatJSON(basicData));
|
||||||
proxyPopupSuccess();
|
proxyPopupSuccess();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -237,7 +345,7 @@ var loadProxyInfo = (function ($) {
|
|||||||
layui.form.render(null, 'addProxyForm');
|
layui.form.render(null, 'addProxyForm');
|
||||||
layui.form.on('input-affix(addition)', function (obj) {
|
layui.form.on('input-affix(addition)', function (obj) {
|
||||||
var $paramValue = $(obj.elem);
|
var $paramValue = $(obj.elem);
|
||||||
var $paramName = $paramValue.closest('.layui-form-item').find('input');
|
var $paramName = $paramValue.closest('.layui-form-item').find('input[type=text]');
|
||||||
var name = $paramName.first().val();
|
var name = $paramName.first().val();
|
||||||
var value = $paramValue.val();
|
var value = $paramValue.val();
|
||||||
var html = document.getElementById('extraParamAddedTemplate').innerHTML;
|
var html = document.getElementById('extraParamAddedTemplate').innerHTML;
|
||||||
|
|||||||
@@ -206,7 +206,8 @@
|
|||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label">${ .UseEncryption }</label>
|
<label class="layui-form-label">${ .UseEncryption }</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<input type="checkbox" name="useEncryption" value="true" title="${ .true }">
|
<input type="checkbox" name="transport.useEncryption" value="true"
|
||||||
|
title="${ .true }">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -214,7 +215,8 @@
|
|||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label">${ .UseCompression }</label>
|
<label class="layui-form-label">${ .UseCompression }</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<input type="checkbox" name="useCompression" value="true" title="${ .true }">
|
<input type="checkbox" name="transport.useCompression" value="true"
|
||||||
|
title="${ .true }">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/fatedier/frp/pkg/config"
|
"github.com/fatedier/frp/pkg/config"
|
||||||
v1 "github.com/fatedier/frp/pkg/config/v1"
|
v1 "github.com/fatedier/frp/pkg/config/v1"
|
||||||
"github.com/pelletier/go-toml/v2"
|
|
||||||
"github.com/vaughan0/go-ini"
|
"github.com/vaughan0/go-ini"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
@@ -155,51 +154,11 @@ func (c *HandleController) parseConfigure(content, proxyType string) (interface{
|
|||||||
}
|
}
|
||||||
|
|
||||||
allProxies := clientConfig.Proxies
|
allProxies := clientConfig.Proxies
|
||||||
var filterProxies = make([]MyProxy, 0)
|
var filterProxies = make([]v1.TypedProxyConfig, 0)
|
||||||
for i := range allProxies {
|
for i := range allProxies {
|
||||||
if equalIgnoreCase(allProxies[i].Type, proxyType) {
|
if equalIgnoreCase(allProxies[i].Type, proxyType) {
|
||||||
baseConfig := allProxies[i].GetBaseConfig()
|
filterProxies = append(filterProxies, allProxies[i])
|
||||||
marshal, _ := toml.Marshal(allProxies[i].ProxyConfigurer)
|
|
||||||
proxy := MyProxy{
|
|
||||||
string(marshal),
|
|
||||||
baseConfig,
|
|
||||||
}
|
|
||||||
filterProxies = append(filterProxies, proxy)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var ss = `
|
|
||||||
Name = 'ssh_random'
|
|
||||||
Type = 'tcp'
|
|
||||||
LocalIP = '192.168.31.100'
|
|
||||||
LocalPort = 22
|
|
||||||
RemotePort = 0
|
|
||||||
|
|
||||||
[Transport]
|
|
||||||
UseEncryption = false
|
|
||||||
UseCompression = false
|
|
||||||
BandwidthLimitMode = ''
|
|
||||||
ProxyProtocolVersion = ''
|
|
||||||
|
|
||||||
[Transport.BandwidthLimit]
|
|
||||||
|
|
||||||
[LoadBalancer]
|
|
||||||
Group = ''
|
|
||||||
GroupKey = ''
|
|
||||||
|
|
||||||
[HealthCheck]
|
|
||||||
Type = ''
|
|
||||||
TimeoutSeconds = 0
|
|
||||||
MaxFailed = 0
|
|
||||||
IntervalSeconds = 0
|
|
||||||
Path = ''
|
|
||||||
|
|
||||||
[Plugin]
|
|
||||||
Type = ''
|
|
||||||
|
|
||||||
`
|
|
||||||
v := v1.ProxyType("tcp")
|
|
||||||
r := v1.NewProxyConfigurerByType(v)
|
|
||||||
toml.Unmarshal([]byte(ss), r)
|
|
||||||
return filterProxies, nil
|
return filterProxies, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user