From a518736cd0d3d8b6445486f42fc9d58f7752fb09 Mon Sep 17 00:00:00 2001 From: panjing <599194993@qq.com> Date: Wed, 15 Mar 2017 16:35:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=90=AF=E5=8A=A8=E6=97=B6?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=89=93=E5=BC=80=E5=AE=98=E7=BD=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/cn/wenat/LocalServer.java | 22 ++++------ .../src/main/java/cn/wenat/form/MainForm.java | 40 ++++++++++++++----- 2 files changed, 39 insertions(+), 23 deletions(-) diff --git a/wezoz-nat-client/src/main/java/cn/wenat/LocalServer.java b/wezoz-nat-client/src/main/java/cn/wenat/LocalServer.java index 2a643e0..b2cfca9 100644 --- a/wezoz-nat-client/src/main/java/cn/wenat/LocalServer.java +++ b/wezoz-nat-client/src/main/java/cn/wenat/LocalServer.java @@ -1,24 +1,18 @@ package cn.wenat; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import java.util.Timer; -import java.util.TimerTask; - +import cn.wenat.form.MainForm; +import cn.wenat.utils.HttpClientUtils; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import io.socket.client.IO; +import io.socket.client.IO.Options; +import io.socket.client.Socket; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.log4j.Logger; import org.json.JSONException; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; - -import cn.wenat.form.MainForm; -import cn.wenat.utils.HttpClientUtils; -import io.socket.client.IO; -import io.socket.client.IO.Options; -import io.socket.client.Socket; +import java.util.*; public class LocalServer { diff --git a/wezoz-nat-client/src/main/java/cn/wenat/form/MainForm.java b/wezoz-nat-client/src/main/java/cn/wenat/form/MainForm.java index 188ccbb..ca2035b 100644 --- a/wezoz-nat-client/src/main/java/cn/wenat/form/MainForm.java +++ b/wezoz-nat-client/src/main/java/cn/wenat/form/MainForm.java @@ -50,10 +50,8 @@ public class MainForm extends BaseForm { private JLabel label_3; private JLabel lblSpeed; - private JLabel lblPing; - public MainForm() { - setTitle("Wezoz NAT"); + setTitle("WeNAT-HTTP内网穿透"); this.setSize(546, 432); setLocationRelativeTo(null); @@ -73,7 +71,7 @@ public class MainForm extends BaseForm { try { String host = txtHost.getText(); server = new LocalServer(); - server.setServer("http://127.0.0.1:3001"); + server.setServer("http://wezoz.com:3001"); server.setForward(host); server.setDomain(txtDomain.getText()); server.setCallListener(new CallListener() { @@ -104,7 +102,7 @@ public class MainForm extends BaseForm { @Override public void speedCall(long speed) { lblSpeed.setText(formatNumber(speed)+"/s"); - + } @Override @@ -172,11 +170,11 @@ public class MainForm extends BaseForm { lblSpeed = new JLabel("0KB"); lblSpeed.setBounds(199, 92, 73, 16); panelSetting.add(lblSpeed); - + JLabel label_4 = new JLabel("延迟:"); label_4.setBounds(305, 92, 39, 16); panelSetting.add(label_4); - + lblPing = new JLabel("0ms"); lblPing.setBounds(342, 92, 123, 16); panelSetting.add(lblPing); @@ -184,7 +182,7 @@ public class MainForm extends BaseForm { txtConsole = new JTextArea() { /** - * + * */ private static final long serialVersionUID = 8749801166570350982L; @@ -198,7 +196,7 @@ public class MainForm extends BaseForm { super.append(str); } }; - txtConsole.setText("准备就绪\n"); + txtConsole.setText("官方网站:https://www.wezoz.com\n"); txtConsole.setBounds(19, 181, 437, 129); panelConsole = new JScrollPane(txtConsole, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); panelConsole.setLocation(20, 210); @@ -214,6 +212,30 @@ public class MainForm extends BaseForm { } }); change(); + //打开网站 + openBrowser(); + } + + private JLabel lblPing; + + private void openBrowser(){ + if(java.awt.Desktop.isDesktopSupported()){ + try{ + //创建一个URI实例,注意不是URL + java.net.URI uri=java.net.URI.create("https://www.wezoz.com"); + //获取当前系统桌面扩展 + java.awt.Desktop dp=java.awt.Desktop.getDesktop(); + //判断系统桌面是否支持要执行的功能 + if(dp.isSupported(java.awt.Desktop.Action.BROWSE)){ + //获取系统默认浏览器打开链接 + dp.browse(uri); + } + }catch(java.lang.NullPointerException e){ + //此为uri为空时抛出异常 + }catch(java.io.IOException e){ + //此为无法获取系统默认浏览器 + } + } } private String formatNumber(long traffic) {