From 2ef1bc74695797d377b8971164018ac61c5bb069 Mon Sep 17 00:00:00 2001 From: yanghuanglin Date: Thu, 14 Dec 2023 11:44:10 +0800 Subject: [PATCH] fixed: current show info in Proxies --- assets/lang/en.json | 2 +- assets/lang/zh.json | 2 +- assets/static/js/index-proxy-list.js | 40 +++++++++++++--------------- assets/templates/index.html | 4 +-- pkg/server/controller/controller.go | 4 +-- pkg/server/controller/utils.go | 19 ++++++++++++- 6 files changed, 43 insertions(+), 28 deletions(-) diff --git a/assets/lang/en.json b/assets/lang/en.json index 9c794a8..976c0fb 100644 --- a/assets/lang/en.json +++ b/assets/lang/en.json @@ -53,7 +53,7 @@ "running": "running", "start error": "start error", "new": "new", - "Local Ip": "Local Ip", + "Local IP": "Local IP", "Local Port": "Local Port", "Operation": "Operation", "Confirm": "Confirm", diff --git a/assets/lang/zh.json b/assets/lang/zh.json index f86f11b..ec36db9 100644 --- a/assets/lang/zh.json +++ b/assets/lang/zh.json @@ -53,7 +53,7 @@ "running": "运行中", "start error": "错误", "new": "新连接", - "Local Ip": "本地IP", + "Local IP": "本地IP", "Local Port": "本地端口", "Operation": "操作", "Confirm": "确定", diff --git a/assets/static/js/index-proxy-list.js b/assets/static/js/index-proxy-list.js index 9921ed7..5a69df0 100644 --- a/assets/static/js/index-proxy-list.js +++ b/assets/static/js/index-proxy-list.js @@ -36,48 +36,46 @@ var loadProxyInfo = (function ($) { /** * render proxy list table - * @param data {Map>} proxy data + * @param data {[Map]} proxy data */ function renderProxyListTable(data) { - var dataList = []; - for (var key in data) { - var temp = data[key]; - temp.name = key; - temp.local_ip = temp.local_ip || '-'; - temp.local_port = temp.local_port || '-'; - temp.use_encryption = temp.use_encryption || false; - temp.use_compression = temp.use_compression || false; + data.forEach(function (temp){ + temp.name = temp.name || '-'; + temp.localIP = temp.localIP || '-'; + temp.localPort = temp.localPort || '-'; + temp.transport = temp.transport || {}; + temp.transport.useEncryption = temp.transport.useEncryption || false; + temp.transport.useCompression = temp.transport.useCompression || false; if (currentProxyType === 'http' || currentProxyType === 'https') { - temp.custom_domains = temp.custom_domains || '-'; + temp.customDomains = temp.customDomains || '-'; temp.subdomain = temp.subdomain || '-'; } - dataList.push(temp); - } + }); var $section = $('#content > section'); var cols = [ {type: 'checkbox'}, {field: 'name', title: i18n['Name'], sort: true}, {field: 'type', title: i18n['Type'], width: 110, sort: true}, - {field: 'local_ip', title: i18n['LocalIp'], width: 150, sort: true}, - {field: 'local_port', title: i18n['LocalPort'], width: 120, sort: true}, + {field: 'localIP', title: i18n['LocalIP'], width: 150, sort: true}, + {field: 'localPort', title: i18n['LocalPort'], width: 120, sort: true}, ]; if (currentProxyType === 'tcp' || currentProxyType === 'udp') { - cols.push({field: 'remote_port', title: i18n['RemotePort'], width: 130, sort: true}); + cols.push({field: 'remotePort', title: i18n['RemotePort'], width: 130, sort: true}); } else if (currentProxyType === 'http' || currentProxyType === 'https') { - cols.push({field: 'custom_domains', title: i18n['CustomDomains'], sort: true}); + cols.push({field: 'customDomains', title: i18n['CustomDomains'], sort: true}); cols.push({field: 'subdomain', title: i18n['Subdomain'], width: 150, sort: true}); } cols.push({ - field: 'use_encryption', title: i18n['UseEncryption'], width: 170, templet: function (d) { - return i18n[d.use_encryption] + field: 'useEncryption', title: i18n['UseEncryption'], width: 170, templet: function (d) { + return i18n[d.transport.useEncryption] }, sort: true }); cols.push({ - field: 'use_compression', title: i18n['UseCompression'], width: 170, templet: function (d) { - return i18n[d.use_compression] + field: 'useCompression', title: i18n['UseCompression'], width: 170, templet: function (d) { + return i18n[d.transport.useCompression] }, sort: true }); cols.push({title: i18n['Operation'], width: 150, toolbar: '#proxyListOperationTemplate'}); @@ -92,7 +90,7 @@ var loadProxyInfo = (function ($) { }, toolbar: '#proxyListToolbarTemplate', defaultToolbar: false, - data: dataList, + data: data, initSort: { field: 'name', type: 'asc' diff --git a/assets/templates/index.html b/assets/templates/index.html index 5befe01..579ffe8 100644 --- a/assets/templates/index.html +++ b/assets/templates/index.html @@ -163,9 +163,9 @@
- +
-
diff --git a/pkg/server/controller/controller.go b/pkg/server/controller/controller.go index 342a301..ef2ed9a 100644 --- a/pkg/server/controller/controller.go +++ b/pkg/server/controller/controller.go @@ -86,7 +86,7 @@ func (c *HandleController) MakeIndexFunc() func(context *gin.Context) { "Basic": ginI18n.MustGetMessage(context, "Basic"), "Extra": ginI18n.MustGetMessage(context, "Extra"), "ProxyName": ginI18n.MustGetMessage(context, "Proxy Name"), - "LocalIp": ginI18n.MustGetMessage(context, "Local Ip"), + "LocalIP": ginI18n.MustGetMessage(context, "Local IP"), "LocalPort": ginI18n.MustGetMessage(context, "Local Port"), "RemotePort": ginI18n.MustGetMessage(context, "Remote Port"), "CustomDomains": ginI18n.MustGetMessage(context, "Custom Domains"), @@ -116,7 +116,7 @@ func (c *HandleController) MakeLangFunc() func(context *gin.Context) { "running": ginI18n.MustGetMessage(context, "running"), "start error": ginI18n.MustGetMessage(context, "start error"), "new": ginI18n.MustGetMessage(context, "new"), - "LocalIp": ginI18n.MustGetMessage(context, "Local Ip"), + "LocalIP": ginI18n.MustGetMessage(context, "Local IP"), "LocalPort": ginI18n.MustGetMessage(context, "Local Port"), "RemotePort": ginI18n.MustGetMessage(context, "Remote Port"), "UseEncryption": ginI18n.MustGetMessage(context, "Use Encryption"), diff --git a/pkg/server/controller/utils.go b/pkg/server/controller/utils.go index 5918191..d512de3 100644 --- a/pkg/server/controller/utils.go +++ b/pkg/server/controller/utils.go @@ -18,6 +18,10 @@ func trimString(str string) string { return strings.TrimSpace(str) } +func equalIgnoreCase(source string, target string) bool { + return strings.ToUpper(source) == strings.ToUpper(target) +} + func sortSectionKeys(object ini.Section) []string { var keys []string for key := range object { @@ -139,5 +143,18 @@ func (c *HandleController) parseConfigure(content, proxyType string) (interface{ if err != nil { return nil, err } - return clientConfig, nil + + if proxyType == "none" { + return clientConfig, nil + } + + allProxies := clientConfig.Proxies + var filterProxies = make([]v1.ProxyConfigurer, 0) + for i := range allProxies { + if equalIgnoreCase(allProxies[i].Type, proxyType) { + filterProxies = append(filterProxies, allProxies[i].ProxyConfigurer) + } + } + + return filterProxies, nil }