forked from KNEMC/KLALB
增加启动xtcp frpc功能
This commit is contained in:
@@ -85,13 +85,13 @@ public class KLALBClientGUI extends XFrame {
|
||||
|
||||
@Override
|
||||
public void componentShown(ComponentEvent e) {
|
||||
// TODO 自动生成的方法存根
|
||||
// TODO 自动生成的方法存根
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
// TODO 自动生成的方法存根
|
||||
// TODO 自动生成的方法存根
|
||||
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public class KLALBClientGUI extends XFrame {
|
||||
|
||||
@Override
|
||||
public void componentHidden(ComponentEvent e) {
|
||||
// TODO 自动生成的方法存根
|
||||
// TODO 自动生成的方法存根
|
||||
|
||||
}
|
||||
});
|
||||
@@ -116,21 +116,21 @@ public class KLALBClientGUI extends XFrame {
|
||||
JButton btnNewButton = new JButton("\u6DFB\u52A0");
|
||||
btnNewButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String s = JOptionPane.showInputDialog(KLALBClientGUI.this, "输入一条线路的地址");
|
||||
String s = JOptionPane.showInputDialog(KLALBClientGUI.this, "输入一条线路的地址");
|
||||
if (s != null) {
|
||||
if (s.equals("")) {
|
||||
JOptionPane.showMessageDialog(KLALBClientGUI.this, "输入不能为空", "错误", JOptionPane.WARNING_MESSAGE);
|
||||
JOptionPane.showMessageDialog(KLALBClientGUI.this, "输入不能为空", "错误", JOptionPane.WARNING_MESSAGE);
|
||||
} else {
|
||||
ProcessingFrame psf = new ProcessingFrame("正在下载线路列表");
|
||||
ProcessingFrame psf = new ProcessingFrame("正在下载线路列表");
|
||||
psf.setIconImage(bi);
|
||||
psf.getProgressBar().setIndeterminate(true);
|
||||
psf.setVisible(true);
|
||||
ThreadTool.makeVThreadIfSupport("线路列表获取", () -> {
|
||||
ThreadTool.makeVThreadIfSupport("线路列表获取", () -> {
|
||||
try {
|
||||
KLALBIPList.createIPList(s);
|
||||
reloadCB();
|
||||
} catch (Exception e1) {
|
||||
JOptionPane.showMessageDialog(KLALBClientGUI.this, e1.toString(), "错误",
|
||||
JOptionPane.showMessageDialog(KLALBClientGUI.this, e1.toString(), "错误",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
e1.printStackTrace();
|
||||
} finally {
|
||||
@@ -152,7 +152,7 @@ public class KLALBClientGUI extends XFrame {
|
||||
t=null;
|
||||
return;
|
||||
}
|
||||
t=ThreadTool.makeVThreadIfSupport("客户端主线程", () -> {
|
||||
t=ThreadTool.makeVThreadIfSupport("客户端主线程", () -> {
|
||||
btnNewButton_1.setEnabled(false);
|
||||
comboBox.setEnabled(false);
|
||||
String s = (String) comboBox.getSelectedItem();
|
||||
@@ -162,12 +162,10 @@ public class KLALBClientGUI extends XFrame {
|
||||
File pdis = KLALBIPList.getSLdir(s);
|
||||
File f = new File(pdis, "iplist.json");
|
||||
if (f.exists()) {
|
||||
System.out.println("加载线路列表:" + f);
|
||||
byte[] bytes;KLALBClient kc=null;
|
||||
System.out.println("加载线路列表:" + f);;KLALBClient kc=null;
|
||||
try {
|
||||
KLALBIPList.updateIPList(s);
|
||||
bytes = Files.readAllBytes(Paths.get(f.toURI()));
|
||||
STJson stj = new STJson(new String(bytes));
|
||||
STJson stj=new STJson(new String(Files.readAllBytes(Paths.get(f.toURI()))));
|
||||
kc = new KLALBClient();
|
||||
kc.getTls().addAll(stj.getTunnels());
|
||||
List<Tunnel>lt=kc.getTls();
|
||||
@@ -206,20 +204,13 @@ public class KLALBClientGUI extends XFrame {
|
||||
ysp.repaint();
|
||||
repaint();
|
||||
kc.connectTunnel();
|
||||
List<ServiceElement> lse = stj.getServices();
|
||||
for (Iterator<ServiceElement> iterator = lse.iterator(); iterator.hasNext();) {
|
||||
ServiceElement serviceElement = (ServiceElement) iterator.next();
|
||||
ProxyIPPortProperties pippp = new ProxyIPPortProperties(pdis, serviceElement.name,
|
||||
"0.0.0.0", serviceElement.ipport.getPort());
|
||||
try {
|
||||
kc.open(pippp.getBindPort(), serviceElement, pippp.getBindIP());
|
||||
} catch (BindException e) {
|
||||
System.out.println("打开端口失败:" + pippp.getBindIP() + " " + pippp.getBindPort());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
ProxyJson pj=new ProxyJson(new File(pdis,"services.json"), stj);
|
||||
kc.getPet().addAll(pj.getPls());
|
||||
kc.listenProxy();
|
||||
|
||||
btnNewButton_1.setForeground(Color.RED);
|
||||
btnNewButton_1.setText("停止");
|
||||
btnNewButton_1.setText("停止");
|
||||
btnNewButton_1.setEnabled(true);
|
||||
|
||||
while(true) {
|
||||
@@ -234,7 +225,7 @@ public class KLALBClientGUI extends XFrame {
|
||||
}
|
||||
|
||||
} catch (ConnectException e) {
|
||||
JOptionPane.showMessageDialog(KLALBClientGUI.this, e.getMessage(), "错误", JOptionPane.ERROR_MESSAGE);
|
||||
JOptionPane.showMessageDialog(KLALBClientGUI.this, e.getMessage(), "错误", JOptionPane.ERROR_MESSAGE);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InterruptedException e) {
|
||||
@@ -246,17 +237,17 @@ public class KLALBClientGUI extends XFrame {
|
||||
}
|
||||
|
||||
} else {
|
||||
System.out.println("线路列表不存在");
|
||||
System.out.println("线路列表不存在");
|
||||
}
|
||||
btnNewButton_1.setForeground(Color.GREEN);
|
||||
btnNewButton_1.setText("启动");
|
||||
btnNewButton_1.setText("启动");
|
||||
btnNewButton_1.setEnabled(true);
|
||||
comboBox.setEnabled(true);
|
||||
});t.start();
|
||||
}
|
||||
});
|
||||
panel_1.add(btnNewButton_1, BorderLayout.EAST);
|
||||
setTitle("KNE云网络负载均衡客户端");
|
||||
setTitle("KNE云网络负载均衡客户端");
|
||||
setSize(600, 370);
|
||||
setLocationRelativeTo(null);
|
||||
|
||||
@@ -267,7 +258,7 @@ public class KLALBClientGUI extends XFrame {
|
||||
TrayIcon ti = new TrayIcon(bi);
|
||||
ti.setImageAutoSize(true);
|
||||
PopupMenu jpm = new PopupMenu();
|
||||
MenuItem mi = new MenuItem("退出");
|
||||
MenuItem mi = new MenuItem("退出");
|
||||
mi.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
@@ -305,4 +296,4 @@ public class KLALBClientGUI extends XFrame {
|
||||
public static void main(String[] args) {
|
||||
new KLALBClientGUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user