mirror of
https://github.com/yhl452493373/frpc-panel.git
synced 2026-04-04 06:17:00 +08:00
fixed: current show info in Proxies
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
var loadProxyInfo = (function ($) {
|
||||
var i18n = {}, currentProxyType, currentTitle;
|
||||
//param names in Basic tab
|
||||
var basicParamNames = ['name', 'type', 'local_ip', 'local_port', 'custom_domains', 'subdomain', 'remote_port', 'use_encryption', 'use_compression'];
|
||||
var basicParamNamesIgnore = ['toml'];
|
||||
var basicParamNames = ['name', 'type', 'localIP', 'localPort', 'customDomains', 'subdomain', 'remotePort', 'useEncryption', 'useCompression'];
|
||||
var basicParamNamesMap = {
|
||||
useEncryption: 'transport.useEncryption',
|
||||
useCompression: 'transport.useCompression'
|
||||
}
|
||||
|
||||
/**
|
||||
* get proxy info
|
||||
@@ -39,7 +44,7 @@ var loadProxyInfo = (function ($) {
|
||||
* @param data {[Map<string,string>]} proxy data
|
||||
*/
|
||||
function renderProxyListTable(data) {
|
||||
data.forEach(function (temp){
|
||||
data.forEach(function (temp) {
|
||||
temp.name = temp.name || '-';
|
||||
temp.localIP = temp.localIP || '-';
|
||||
temp.localPort = temp.localPort || '-';
|
||||
@@ -157,12 +162,32 @@ var loadProxyInfo = (function ($) {
|
||||
var extraData = [];
|
||||
if (data != null) {
|
||||
var tempData = $.extend(true, {}, data);
|
||||
|
||||
basicParamNamesIgnore.forEach(function (basicName) {
|
||||
if (basicParamNamesMap.hasOwnProperty(basicName)) {
|
||||
try {
|
||||
eval('delete tempData.' + basicParamNamesMap[basicName])
|
||||
} catch (e) {
|
||||
}
|
||||
} else if (data.hasOwnProperty(basicName)) {
|
||||
delete tempData[basicName];
|
||||
}
|
||||
});
|
||||
|
||||
basicParamNames.forEach(function (basicName) {
|
||||
if (data.hasOwnProperty(basicName)) {
|
||||
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) {
|
||||
extraData.push({
|
||||
name: key,
|
||||
|
||||
@@ -165,14 +165,14 @@
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">${ .LocalIP }</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="local_ip" placeholder="${ .LocalIP }" autocomplete="off"
|
||||
<input type="text" name="localIP" placeholder="${ .LocalIP }" autocomplete="off"
|
||||
class="layui-input"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">${ .LocalPort }</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="local_port" placeholder="${ .LocalPort }" autocomplete="off"
|
||||
<input type="text" name="localPort" placeholder="${ .LocalPort }" autocomplete="off"
|
||||
class="layui-input"/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -180,7 +180,7 @@
|
||||
<div class="layui-form-item http https">
|
||||
<label class="layui-form-label">${ .CustomDomains }</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea name="custom_domains" placeholder="${ .CustomDomains }" autocomplete="off"
|
||||
<textarea name="customDomains" placeholder="${ .CustomDomains }" autocomplete="off"
|
||||
class="layui-textarea"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
@@ -196,7 +196,7 @@
|
||||
<div class="layui-form-item tcp udp">
|
||||
<label class="layui-form-label">${ .RemotePort }</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="remote_port" placeholder="${ .RemotePort }" autocomplete="off"
|
||||
<input type="text" name="remotePort" placeholder="${ .RemotePort }" autocomplete="off"
|
||||
class="layui-input"/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -206,7 +206,7 @@
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">${ .UseEncryption }</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="use_encryption" value="true" title="${ .true }">
|
||||
<input type="checkbox" name="useEncryption" value="true" title="${ .true }">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -214,7 +214,7 @@
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">${ .UseCompression }</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="use_compression" value="true" title="${ .true }">
|
||||
<input type="checkbox" name="useCompression" value="true" title="${ .true }">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"github.com/fatedier/frp/pkg/config"
|
||||
v1 "github.com/fatedier/frp/pkg/config/v1"
|
||||
"github.com/pelletier/go-toml/v2"
|
||||
"github.com/vaughan0/go-ini"
|
||||
"io"
|
||||
"log"
|
||||
@@ -137,6 +138,11 @@ func (c *HandleController) parseResponse(res *ProxyResponse, response *http.Resp
|
||||
log.Printf(res.Message)
|
||||
}
|
||||
|
||||
type MyProxy struct {
|
||||
Toml string `json:"toml"`
|
||||
*v1.ProxyBaseConfig
|
||||
}
|
||||
|
||||
func (c *HandleController) parseConfigure(content, proxyType string) (interface{}, error) {
|
||||
clientConfig := v1.ClientConfig{}
|
||||
err := config.LoadConfigure([]byte(content), &clientConfig)
|
||||
@@ -149,12 +155,51 @@ func (c *HandleController) parseConfigure(content, proxyType string) (interface{
|
||||
}
|
||||
|
||||
allProxies := clientConfig.Proxies
|
||||
var filterProxies = make([]v1.ProxyConfigurer, 0)
|
||||
var filterProxies = make([]MyProxy, 0)
|
||||
for i := range allProxies {
|
||||
if equalIgnoreCase(allProxies[i].Type, proxyType) {
|
||||
filterProxies = append(filterProxies, allProxies[i].ProxyConfigurer)
|
||||
baseConfig := allProxies[i].GetBaseConfig()
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user