diff --git a/assets/static/js/index-proxy-list.js b/assets/static/js/index-proxy-list.js index 5a69df0..f8310be 100644 --- a/assets/static/js/index-proxy-list.js +++ b/assets/static/js/index-proxy-list.js @@ -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]} 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, diff --git a/assets/templates/index.html b/assets/templates/index.html index 579ffe8..a9e452e 100644 --- a/assets/templates/index.html +++ b/assets/templates/index.html @@ -165,14 +165,14 @@
-
-
@@ -180,7 +180,7 @@
-
@@ -196,7 +196,7 @@
-
@@ -206,7 +206,7 @@
- +
@@ -214,7 +214,7 @@
- +
diff --git a/pkg/server/controller/utils.go b/pkg/server/controller/utils.go index d512de3..a672285 100644 --- a/pkg/server/controller/utils.go +++ b/pkg/server/controller/utils.go @@ -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 }