From 7f5d7e51de8ad5eb7a91d651d3e7abe1503f857b Mon Sep 17 00:00:00 2001 From: liyongpan Date: Fri, 20 Mar 2020 12:58:29 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=90=AF=E7=94=A8?= =?UTF-8?q?=E7=A6=81=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- proxy-server/webpages/i18n/lang_zh_CN.properties | 2 ++ proxy-server/webpages/lanproxy-config/html/lan/list.html | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/proxy-server/webpages/i18n/lang_zh_CN.properties b/proxy-server/webpages/i18n/lang_zh_CN.properties index 4e687a5c..ca659ca8 100644 --- a/proxy-server/webpages/i18n/lang_zh_CN.properties +++ b/proxy-server/webpages/i18n/lang_zh_CN.properties @@ -21,6 +21,8 @@ public.back=返回 public.notice.updatesuccess=更新成功 public.notice.addsuccess=添加成功 public.tips=提示 +public.enable=启用 +public.disable=禁用 client.list=客户端列表 client.name=客户端名称 diff --git a/proxy-server/webpages/lanproxy-config/html/lan/list.html b/proxy-server/webpages/lanproxy-config/html/lan/list.html index 83dbf0f7..f876e516 100644 --- a/proxy-server/webpages/lanproxy-config/html/lan/list.html +++ b/proxy-server/webpages/lanproxy-config/html/lan/list.html @@ -26,6 +26,8 @@ + + <%}%> @@ -45,6 +47,8 @@ $(".i18n-lan-options").html($.i18n.prop('public.options')); $(".mapping-edit").html($.i18n.prop('public.edit')); $(".mapping-delete").html($.i18n.prop('public.delete')); + $(".mapping-enable").html($.i18n.prop('public.enable')); + $(".mapping-disable").html($.i18n.prop('public.disable')); $(".mapping-config").click(function() { window.clientIndex = $(this).attr("data-index"); load_page("html/lan/list.html"); From c580801040943ee368320384b5c04e21847df609 Mon Sep 17 00:00:00 2001 From: liyongpan Date: Fri, 20 Mar 2020 17:22:12 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=90=AF=E7=94=A8?= =?UTF-8?q?=E7=A6=81=E7=94=A8=E8=BD=AC=E5=8F=91=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lanproxy/server/config/ProxyConfig.java | 10 +++++++ .../lanproxy-config/html/lan/add.html | 3 +- .../lanproxy-config/html/lan/list.html | 30 ++++++++++++++++++- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/proxy-server/src/main/java/org/fengfei/lanproxy/server/config/ProxyConfig.java b/proxy-server/src/main/java/org/fengfei/lanproxy/server/config/ProxyConfig.java index ef78feeb..268be348 100644 --- a/proxy-server/src/main/java/org/fengfei/lanproxy/server/config/ProxyConfig.java +++ b/proxy-server/src/main/java/org/fengfei/lanproxy/server/config/ProxyConfig.java @@ -373,6 +373,9 @@ public static class ClientProxyMapping { /** 备注名称 */ private String name; + /** 是否启用 */ + private Boolean enable; + public Integer getInetPort() { return inetPort; } @@ -397,6 +400,13 @@ public void setName(String name) { this.name = name; } + public Boolean getEnable() { + return enable; + } + + public void setEnable(Boolean enable) { + this.enable = enable; + } } /** diff --git a/proxy-server/webpages/lanproxy-config/html/lan/add.html b/proxy-server/webpages/lanproxy-config/html/lan/add.html index 2f8fa2fe..d1f7118e 100644 --- a/proxy-server/webpages/lanproxy-config/html/lan/add.html +++ b/proxy-server/webpages/lanproxy-config/html/lan/add.html @@ -63,7 +63,8 @@ clientList[clientIndex].proxyMappings.push({ name:name, inetPort:inetPort, - lan:lan + lan:lan, + enable:true }); api_invoke("/config/update", clientList, function(data) { diff --git a/proxy-server/webpages/lanproxy-config/html/lan/list.html b/proxy-server/webpages/lanproxy-config/html/lan/list.html index f876e516..233cf350 100644 --- a/proxy-server/webpages/lanproxy-config/html/lan/list.html +++ b/proxy-server/webpages/lanproxy-config/html/lan/list.html @@ -26,8 +26,11 @@ + <% if(!data[i].enable){ %> - + <% } else { %> + + <% }%> <%}%> @@ -74,6 +77,31 @@ }) }); }); + + $(".mapping-enable").click(function() { + var mappingIndex = $(this).attr("data-index"); + clientList[clientIndex].proxyMappings[mappingIndex].enable = true; + api_invoke("/config/update", clientList, function(data) { + if (data.code != 20000) { + layer.alert(data.message); + } else { + load_page("html/lan/list.html"); + } + }) + }); + + $(".mapping-disable").click(function() { + var mappingIndex = $(this).attr("data-index"); + clientList[clientIndex].proxyMappings[mappingIndex].enable = false; + api_invoke("/config/update", clientList, function(data) { + if (data.code != 20000) { + layer.alert(data.message); + } else { + load_page("html/lan/list.html"); + } + }) + }); + $(".back").click(function() { load_page("html/client/list.html"); }); From 7782f87af3233f4ec1c0c411d7e1990416738521 Mon Sep 17 00:00:00 2001 From: liyongpan Date: Fri, 20 Mar 2020 19:22:31 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=90=AF=E7=94=A8?= =?UTF-8?q?=E7=A6=81=E7=94=A8=E8=BD=AC=E5=8F=91=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lanproxy/server/ProxyChannelManager.java | 10 +++++++--- .../lanproxy/server/config/ProxyConfig.java | 17 ++++++++++++++++- .../webpages/i18n/lang_zh_CN.properties | 1 + .../webpages/lanproxy-config/html/lan/edit.html | 5 ++++- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/proxy-server/src/main/java/org/fengfei/lanproxy/server/ProxyChannelManager.java b/proxy-server/src/main/java/org/fengfei/lanproxy/server/ProxyChannelManager.java index d50150d4..32ccace1 100644 --- a/proxy-server/src/main/java/org/fengfei/lanproxy/server/ProxyChannelManager.java +++ b/proxy-server/src/main/java/org/fengfei/lanproxy/server/ProxyChannelManager.java @@ -65,6 +65,8 @@ public synchronized void onChanged() { List inetPorts = new ArrayList(ProxyConfig.getInstance().getClientInetPorts(clientKey)); Set inetPortSet = new HashSet(inetPorts); List channelInetPorts = new ArrayList(proxyChannel.attr(CHANNEL_PORT).get()); + ProxyConfig.Client cli = ProxyConfig.getInstance().getClients(clientKey); + if(cli == null) continue; synchronized (portCmdChannelMapping) { @@ -77,7 +79,7 @@ public synchronized void onChanged() { // 判断是否是同一个连接对象,有可能之前已经更换成其他client的连接了 if (proxyChannel == channel) { - if (!inetPortSet.contains(chanelInetPort)) { + if (!inetPortSet.contains(chanelInetPort) || !cli.isProxyEnable(chanelInetPort)) { // 移除新配置中不包含的端口 portCmdChannelMapping.remove(chanelInetPort); @@ -92,8 +94,10 @@ public synchronized void onChanged() { // 将新配置中增加的外网端口写入到映射配置中 for (int inetPort : inetPorts) { - portCmdChannelMapping.put(inetPort, proxyChannel); - proxyChannel.attr(CHANNEL_PORT).get().add(inetPort); + if(cli.isProxyEnable(inetPort)) { + portCmdChannelMapping.put(inetPort, proxyChannel); + proxyChannel.attr(CHANNEL_PORT).get().add(inetPort); + } } checkAndClearUserChannels(proxyChannel); diff --git a/proxy-server/src/main/java/org/fengfei/lanproxy/server/config/ProxyConfig.java b/proxy-server/src/main/java/org/fengfei/lanproxy/server/config/ProxyConfig.java index 268be348..672504c4 100644 --- a/proxy-server/src/main/java/org/fengfei/lanproxy/server/config/ProxyConfig.java +++ b/proxy-server/src/main/java/org/fengfei/lanproxy/server/config/ProxyConfig.java @@ -154,6 +154,13 @@ public List getClients() { return clients; } + public Client getClients(String clientKey) { + for (Client cli: clients) { + if(cli.getClientKey().equals(clientKey))return cli; + } + return null; + } + /** * 解析配置文件 */ @@ -202,7 +209,9 @@ public void update(String proxyMappingConfigJson) { throw new IllegalArgumentException("一个公网端口只能映射一个后端信息,不能重复: " + port); } - inetPortLanInfoMapping.put(port, mapping.getLan()); + if(mapping.getEnable()) { + inetPortLanInfoMapping.put(port, mapping.getLan()); + } } } @@ -354,6 +363,12 @@ public void setStatus(int status) { this.status = status; } + public Boolean isProxyEnable(int inetPort) { + for (ClientProxyMapping cli:proxyMappings) { + if(cli.getInetPort() == inetPort) return cli.getEnable(); + } + return false; + } } /** diff --git a/proxy-server/webpages/i18n/lang_zh_CN.properties b/proxy-server/webpages/i18n/lang_zh_CN.properties index ca659ca8..718f577c 100644 --- a/proxy-server/webpages/i18n/lang_zh_CN.properties +++ b/proxy-server/webpages/i18n/lang_zh_CN.properties @@ -46,6 +46,7 @@ lan.name=代理名称 lan.inetport=公网端口 lan.inetport.placeholder=请输入公网出口端口,请确保端口没有被其他程序占用 lan.ip=后端IP端口 +lan.enable=是否开启 lan.ip.placeholder=请输入后端代理信息,格式:127.0.0.1:80 lan.notice.inputname=请输入代理信息备注名称 lan.notice.inputinetport=请输入公网出口端口 diff --git a/proxy-server/webpages/lanproxy-config/html/lan/edit.html b/proxy-server/webpages/lanproxy-config/html/lan/edit.html index 8c223a56..afbf140a 100644 --- a/proxy-server/webpages/lanproxy-config/html/lan/edit.html +++ b/proxy-server/webpages/lanproxy-config/html/lan/edit.html @@ -65,10 +65,13 @@ return; } + var enable = clientList[clientIndex].proxyMappings[mappingIndex].enable; + clientList[clientIndex].proxyMappings[mappingIndex]= { name:name, inetPort:inetPort, - lan:lan + lan:lan, + enable:enable }; api_invoke("/config/update", clientList, function(data) { From abd505bc39264446794cd017d401f1637a010aed Mon Sep 17 00:00:00 2001 From: lipan465 Date: Sun, 22 Mar 2020 17:32:51 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0switch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lanproxy-config/html/lan/edit.html | 88 ++-- .../lanproxy-config/layui/css/layui.css | 4 +- .../layui/css/layui.mobile.css | 2 +- .../layui/css/modules/code.css | 2 +- .../css/modules/laydate/default/laydate.css | 4 +- .../layui/css/modules/layer/default/layer.css | 4 +- .../lanproxy-config/layui/font/iconfont.eot | Bin 33168 -> 46684 bytes .../lanproxy-config/layui/font/iconfont.svg | 394 ++++++++++++------ .../lanproxy-config/layui/font/iconfont.ttf | Bin 32992 -> 46508 bytes .../lanproxy-config/layui/font/iconfont.woff | Bin 21680 -> 30628 bytes .../layui/lay/modules/carousel.js | 4 +- .../lanproxy-config/layui/lay/modules/code.js | 2 +- .../layui/lay/modules/element.js | 4 +- .../lanproxy-config/layui/lay/modules/flow.js | 4 +- .../lanproxy-config/layui/lay/modules/form.js | 4 +- .../layui/lay/modules/jquery.js | 2 +- .../layui/lay/modules/laydate.js | 4 +- .../layui/lay/modules/layedit.js | 4 +- .../layui/lay/modules/layer.js | 4 +- .../layui/lay/modules/laypage.js | 4 +- .../layui/lay/modules/laytpl.js | 4 +- .../layui/lay/modules/mobile.js | 4 +- .../layui/lay/modules/table.js | 4 +- .../lanproxy-config/layui/lay/modules/tree.js | 4 +- .../layui/lay/modules/upload.js | 4 +- .../lanproxy-config/layui/lay/modules/util.js | 4 +- .../lanproxy-config/layui/layui.all.js | 6 +- .../webpages/lanproxy-config/layui/layui.js | 4 +- 28 files changed, 375 insertions(+), 193 deletions(-) diff --git a/proxy-server/webpages/lanproxy-config/html/lan/edit.html b/proxy-server/webpages/lanproxy-config/html/lan/edit.html index afbf140a..d90ca093 100644 --- a/proxy-server/webpages/lanproxy-config/html/lan/edit.html +++ b/proxy-server/webpages/lanproxy-config/html/lan/edit.html @@ -2,42 +2,64 @@
-
-
- -
- -
-
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
- -
- -
-
-
- -
- -
-
-
-
- - -
-
-
+ +
+ +
+
+
+
+ + +
+
+ +