forked from KNEMC/KLALB
增加启动xtcp frpc功能
This commit is contained in:
+31
-52
@@ -1,86 +1,65 @@
|
|||||||
{
|
{
|
||||||
"name" : "KNECloud",
|
"name" : "KNECloud",
|
||||||
"services" : [ {
|
"services" : [ {
|
||||||
"name" : "KNE官网",
|
"name" : "KNE官网",
|
||||||
"protocol" : "HTTP",
|
"protocol" : "HTTP",
|
||||||
"localaddress" : "127.0.0.1:8081"
|
"localaddress" : "127.0.0.1:8081"
|
||||||
}, {
|
}, {
|
||||||
"name" : "KNE云盘",
|
"name" : "KNE云盘",
|
||||||
"protocol" : "HTTP",
|
"protocol" : "HTTP",
|
||||||
"localaddress" : "127.0.0.1:5212"
|
"localaddress" : "127.0.0.1:5212"
|
||||||
}, {
|
}, {
|
||||||
"name" : "服务器远程桌面",
|
"name" : "服务器远程桌面",
|
||||||
"protocol" : "RDP",
|
"protocol" : "RDP",
|
||||||
"localaddress" : "127.0.0.1:3389"
|
"localaddress" : "127.0.0.1:3389"
|
||||||
} ],
|
} ],
|
||||||
"tunnels" : [ {
|
"tunnels" : [ {
|
||||||
"name" : "Openfrp-直连线路",
|
"name" : "Openfrp-直连线路",
|
||||||
"remoteaddress" : "127.0.0.1:4566"
|
"remoteaddress" : "127.0.0.1:4566",
|
||||||
|
"frpc":[ "[common]",
|
||||||
|
"server_addr = 180.76.147.250",
|
||||||
|
"server_port = 8120",
|
||||||
|
"tcp_mux = true",
|
||||||
|
"protocol = tcp",
|
||||||
|
"dns_server = 223.5.5.5",
|
||||||
|
"user = bb28264e0abf3bcbec3a2180c5a279b8",
|
||||||
|
"token = I2KMo1HvRxuvurv2",
|
||||||
|
"[ts1xx]",
|
||||||
|
"type = xtcp",
|
||||||
|
"role = visitor",
|
||||||
|
"server_name = zl1",
|
||||||
|
"bind_addr = 127.0.0.1",
|
||||||
|
"bind_port = 4566",
|
||||||
|
"sk = knecloud"]
|
||||||
},{
|
},{
|
||||||
"name" : "Openfrp-直连线路",
|
"name" : "NULL-宿迁联通",
|
||||||
"remoteaddress" : "127.0.0.1:4566"
|
|
||||||
},{
|
|
||||||
"name" : "NULL-宿迁联通",
|
|
||||||
"remoteaddress" : "153.36.240.12:65529"
|
"remoteaddress" : "153.36.240.12:65529"
|
||||||
}, {
|
}, {
|
||||||
"name" : "Openfrp-韩国春川-1",
|
"name" : "Openfrp-北京多线-3",
|
||||||
"remoteaddress" : "kr-nc-bgp-1.openfrp.top:65529"
|
|
||||||
}, {
|
|
||||||
"name" : "Openfrp-北京多线-3",
|
|
||||||
"remoteaddress" : "cn-bj-bgp-3.openfrp.top:65529"
|
"remoteaddress" : "cn-bj-bgp-3.openfrp.top:65529"
|
||||||
}, {
|
}, {
|
||||||
"name" : "Openfrp-北京多线-7",
|
"name" : "Openfrp-北京多线-7",
|
||||||
"remoteaddress" : "180.76.147.250:65529"
|
"remoteaddress" : "180.76.147.250:65529"
|
||||||
}, {
|
}, {
|
||||||
"name" : "Openfrp-美国-8「BGP」",
|
"name" : "Sakurafrp-安徽电信-1",
|
||||||
"remoteaddress" : "us-los-bgp-8.openfrp.top:65529"
|
|
||||||
}, {
|
|
||||||
"name" : "Sakurafrp-安徽电信-1",
|
|
||||||
"remoteaddress" : "cn-ah-dx-1.natfrp.cloud:65529"
|
"remoteaddress" : "cn-ah-dx-1.natfrp.cloud:65529"
|
||||||
}, {
|
}, {
|
||||||
"name" : "Sakurafrp-十堰电信-1",
|
"name" : "Sakurafrp-南宁电信-1",
|
||||||
"remoteaddress" : "cn-sy-dx-1.natfrp.cloud:65529"
|
"remoteaddress" : "cn-nn-dx-1.natfrp.cloud:65529"
|
||||||
}, {
|
}, {
|
||||||
"name" : "Sakurafrp-武汉电信-1",
|
"name" : "Sakurafrp-武汉电信-1",
|
||||||
"remoteaddress" : "cn-wh-dx-1.natfrp.cloud:65529"
|
"remoteaddress" : "cn-wh-dx-1.natfrp.cloud:65529"
|
||||||
}, {
|
}, {
|
||||||
"name" : "Sakurafrp-枣庄BGP-10",
|
"name" : "Sakurafrp-枣庄BGP-10",
|
||||||
"remoteaddress" : "cn-zz-bgp-10.natfrp.cloud:23330"
|
"remoteaddress" : "cn-zz-bgp-10.natfrp.cloud:23330"
|
||||||
}, {
|
}, {
|
||||||
"name" : "Sakurafrp-枣庄BGP-7",
|
"name" : "Sakurafrp-枣庄BGP-7",
|
||||||
"remoteaddress" : "cn-zz-bgp-7.natfrp.cloud:33336"
|
"remoteaddress" : "cn-zz-bgp-7.natfrp.cloud:33336"
|
||||||
}, {
|
}, {
|
||||||
"name" : "HYHBX-深圳阿里-1",
|
"name" : "HYHBX-深圳阿里-1",
|
||||||
"remoteaddress" : "119.23.238.91:12413"
|
"remoteaddress" : "119.23.238.91:12413"
|
||||||
}, {
|
}, {
|
||||||
"name" : "HYHBX-上海腾讯-2",
|
"name" : "HYHBX-上海腾讯-2",
|
||||||
"remoteaddress" : "43.143.109.64:49965"
|
"remoteaddress" : "43.143.109.64:49965"
|
||||||
}, {
|
|
||||||
"name" : "XYZ-韩国首尔",
|
|
||||||
"remoteaddress" : "frp.104300.xyz:49965"
|
|
||||||
}, {
|
|
||||||
"name" : "aFrps-美国洛杉矶",
|
|
||||||
"remoteaddress" : "la.afrps.cn:49966"
|
|
||||||
}, {
|
|
||||||
"name" : "aFrps-新加坡",
|
|
||||||
"remoteaddress" : "sg.afrps.cn:49966"
|
|
||||||
}, {
|
|
||||||
"name" : "aFrps-美国芝加哥",
|
|
||||||
"remoteaddress" : "ch.afrps.cn:49966"
|
|
||||||
}, {
|
|
||||||
"name" : "aFrps-美国圣何塞",
|
|
||||||
"remoteaddress" : "sj.afrps.cn:49966"
|
|
||||||
} , {
|
|
||||||
"name" : "Freefrp-韩国首尔-0",
|
|
||||||
"remoteaddress" : "frp.freefrp.net:49965"
|
|
||||||
}, {
|
|
||||||
"name" : "Freefrp-韩国首尔-1",
|
|
||||||
"remoteaddress" : "frp1.freefrp.net:49965"
|
|
||||||
}, {
|
|
||||||
"name" : "Freefrp-韩国首尔-2",
|
|
||||||
"remoteaddress" : "frp2.freefrp.net:49965"
|
|
||||||
}, {
|
|
||||||
"name" : "Freefrp-韩国首尔-4",
|
|
||||||
"remoteaddress" : "frp4.freefrp.net:49965"
|
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
-86
@@ -1,86 +0,0 @@
|
|||||||
{
|
|
||||||
"name" : "KNECloud",
|
|
||||||
"services" : [ {
|
|
||||||
"name" : "KNE官网",
|
|
||||||
"protocol" : "HTTP",
|
|
||||||
"localaddress" : "127.0.0.1:8081"
|
|
||||||
}, {
|
|
||||||
"name" : "KNE云盘",
|
|
||||||
"protocol" : "HTTP",
|
|
||||||
"localaddress" : "127.0.0.1:5212"
|
|
||||||
}, {
|
|
||||||
"name" : "服务器远程桌面",
|
|
||||||
"protocol" : "RDP",
|
|
||||||
"localaddress" : "127.0.0.1:3389"
|
|
||||||
} ],
|
|
||||||
"tunnels" : [ {
|
|
||||||
"name" : "Openfrp-直连线路",
|
|
||||||
"remoteaddress" : "127.0.0.1:4566"
|
|
||||||
}, {
|
|
||||||
"name" : "Openfrp-直连线路",
|
|
||||||
"remoteaddress" : "127.0.0.1:4566"
|
|
||||||
},{
|
|
||||||
"name" : "NULL-宿迁联通",
|
|
||||||
"remoteaddress" : "153.36.240.12:65529"
|
|
||||||
}, {
|
|
||||||
"name" : "Openfrp-韩国春川-1",
|
|
||||||
"remoteaddress" : "kr-nc-bgp-1.openfrp.top:65529"
|
|
||||||
}, {
|
|
||||||
"name" : "Openfrp-北京多线-3",
|
|
||||||
"remoteaddress" : "cn-bj-bgp-3.openfrp.top:65529"
|
|
||||||
}, {
|
|
||||||
"name" : "Openfrp-北京多线-7",
|
|
||||||
"remoteaddress" : "180.76.147.250:65529"
|
|
||||||
}, {
|
|
||||||
"name" : "Openfrp-美国-8「BGP」",
|
|
||||||
"remoteaddress" : "us-los-bgp-8.openfrp.top:65529"
|
|
||||||
}, {
|
|
||||||
"name" : "Sakurafrp-安徽电信-1",
|
|
||||||
"remoteaddress" : "cn-ah-dx-1.natfrp.cloud:65529"
|
|
||||||
}, {
|
|
||||||
"name" : "Sakurafrp-十堰电信-1",
|
|
||||||
"remoteaddress" : "cn-sy-dx-1.natfrp.cloud:65529"
|
|
||||||
}, {
|
|
||||||
"name" : "Sakurafrp-武汉电信-1",
|
|
||||||
"remoteaddress" : "cn-wh-dx-1.natfrp.cloud:65529"
|
|
||||||
}, {
|
|
||||||
"name" : "Sakurafrp-枣庄BGP-10",
|
|
||||||
"remoteaddress" : "cn-zz-bgp-10.natfrp.cloud:23330"
|
|
||||||
}, {
|
|
||||||
"name" : "Sakurafrp-枣庄BGP-7",
|
|
||||||
"remoteaddress" : "cn-zz-bgp-7.natfrp.cloud:33336"
|
|
||||||
}, {
|
|
||||||
"name" : "HYHBX-深圳阿里-1",
|
|
||||||
"remoteaddress" : "119.23.238.91:12413"
|
|
||||||
}, {
|
|
||||||
"name" : "HYHBX-上海腾讯-2",
|
|
||||||
"remoteaddress" : "43.143.109.64:49965"
|
|
||||||
}, {
|
|
||||||
"name" : "XYZ-韩国首尔",
|
|
||||||
"remoteaddress" : "frp.104300.xyz:49965"
|
|
||||||
}, {
|
|
||||||
"name" : "aFrps-美国洛杉矶",
|
|
||||||
"remoteaddress" : "la.afrps.cn:49966"
|
|
||||||
}, {
|
|
||||||
"name" : "aFrps-新加坡",
|
|
||||||
"remoteaddress" : "sg.afrps.cn:49966"
|
|
||||||
}, {
|
|
||||||
"name" : "aFrps-美国芝加哥",
|
|
||||||
"remoteaddress" : "ch.afrps.cn:49966"
|
|
||||||
}, {
|
|
||||||
"name" : "aFrps-美国圣何塞",
|
|
||||||
"remoteaddress" : "sj.afrps.cn:49966"
|
|
||||||
} , {
|
|
||||||
"name" : "Freefrp-韩国首尔-0",
|
|
||||||
"remoteaddress" : "frp.freefrp.net:49965"
|
|
||||||
}, {
|
|
||||||
"name" : "Freefrp-韩国首尔-1",
|
|
||||||
"remoteaddress" : "frp1.freefrp.net:49965"
|
|
||||||
}, {
|
|
||||||
"name" : "Freefrp-韩国首尔-2",
|
|
||||||
"remoteaddress" : "frp2.freefrp.net:49965"
|
|
||||||
}, {
|
|
||||||
"name" : "Freefrp-韩国首尔-4",
|
|
||||||
"remoteaddress" : "frp4.freefrp.net:49965"
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"name" : "KNECloud",
|
||||||
|
"services" : [ {
|
||||||
|
"name" : "KNE官网",
|
||||||
|
"protocol" : "HTTP",
|
||||||
|
"localaddress" : "127.0.0.1:8081"
|
||||||
|
}, {
|
||||||
|
"name" : "KNE云盘",
|
||||||
|
"protocol" : "HTTP",
|
||||||
|
"localaddress" : "127.0.0.1:5212"
|
||||||
|
}, {
|
||||||
|
"name" : "服务器远程桌面",
|
||||||
|
"protocol" : "RDP",
|
||||||
|
"localaddress" : "127.0.0.1:3389"
|
||||||
|
} ],
|
||||||
|
"tunnels" : [ {
|
||||||
|
"name" : "Openfrp-韩国春川-1",
|
||||||
|
"remoteaddress" : "kr-nc-bgp-1.openfrp.top:65529"
|
||||||
|
}, {
|
||||||
|
"name" : "Openfrp-北京多线-3",
|
||||||
|
"remoteaddress" : "cn-bj-bgp-3.openfrp.top:65529"
|
||||||
|
}, {
|
||||||
|
"name" : "Openfrp-北京多线-7",
|
||||||
|
"remoteaddress" : "180.76.147.250:65529"
|
||||||
|
}, {
|
||||||
|
"name" : "Openfrp-美国-8「BGP」",
|
||||||
|
"remoteaddress" : "us-los-bgp-8.openfrp.top:65529"
|
||||||
|
}]
|
||||||
|
}
|
||||||
@@ -47,7 +47,7 @@ public class IOThreadManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Thread lt = ThreadTool.makeVThreadIfSupport("数据包计时重发线程", () -> {
|
Thread lt = ThreadTool.makeVThreadIfSupport("数据包计时重发线程", () -> {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
while (AB.get()) {
|
while (AB.get()) {
|
||||||
@@ -57,7 +57,7 @@ public class IOThreadManager {
|
|||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Thread ls = ThreadTool.makeVThreadIfSupport("本地发送线程", () -> {
|
Thread ls = ThreadTool.makeVThreadIfSupport("本地发送线程", () -> {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
while (AB.get()) {
|
while (AB.get()) {
|
||||||
@@ -77,7 +77,6 @@ public class IOThreadManager {
|
|||||||
sbk.number = 0;
|
sbk.number = 0;
|
||||||
sbk.command = 3;
|
sbk.command = 3;
|
||||||
klc.submitDataBlockNoDelay(sbk);
|
klc.submitDataBlockNoDelay(sbk);
|
||||||
e.printStackTrace();
|
|
||||||
}finally {
|
}finally {
|
||||||
try {
|
try {
|
||||||
tc.getDout().close();
|
tc.getDout().close();
|
||||||
@@ -86,7 +85,7 @@ public class IOThreadManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Thread lr = ThreadTool.makeVThreadIfSupport("本地接收线程", () -> {
|
Thread lr = ThreadTool.makeVThreadIfSupport("本地接收线程", () -> {
|
||||||
try {
|
try {
|
||||||
while (AB.get()) {
|
while (AB.get()) {
|
||||||
KLALBBlock ks = tc.packBlock();
|
KLALBBlock ks = tc.packBlock();
|
||||||
@@ -105,7 +104,6 @@ public class IOThreadManager {
|
|||||||
sbk.number = 0;
|
sbk.number = 0;
|
||||||
sbk.command = 3;
|
sbk.command = 3;
|
||||||
klc.submitDataBlockNoDelay(sbk);
|
klc.submitDataBlockNoDelay(sbk);
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
tc.getDin().close();
|
tc.getDin().close();
|
||||||
@@ -143,7 +141,7 @@ public class IOThreadManager {
|
|||||||
}
|
}
|
||||||
klc.getRemotetcps().add(tc);
|
klc.getRemotetcps().add(tc);
|
||||||
try {
|
try {
|
||||||
Thread rs = ThreadTool.makeVThreadIfSupport("远程发送线程", () -> {
|
Thread rs = ThreadTool.makeVThreadIfSupport("远程发送线程", () -> {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
while (true) {
|
while (true) {
|
||||||
@@ -151,17 +149,15 @@ public class IOThreadManager {
|
|||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Thread rr = ThreadTool.makeVThreadIfSupport("远程接收线程", () -> {
|
Thread rr = ThreadTool.makeVThreadIfSupport("远程接收线程", () -> {
|
||||||
try {
|
try {
|
||||||
while (true) {
|
while (true) {
|
||||||
klc.remoteReceive(tc);
|
klc.remoteReceive(tc);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
rs.interrupt();
|
rs.interrupt();
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
rs.start();
|
rs.start();
|
||||||
|
|||||||
@@ -10,12 +10,12 @@ import org.kne.cloud.network.mport.IPPort;
|
|||||||
public class KLALBBlock implements Comparable<KLALBBlock>{
|
public class KLALBBlock implements Comparable<KLALBBlock>{
|
||||||
private static AtomicLong sng=new AtomicLong(1);
|
private static AtomicLong sng=new AtomicLong(1);
|
||||||
|
|
||||||
public long sn;//每个数据包的唯一编号
|
public long sn;//每个数据包的唯一编号
|
||||||
public int cuid;//用于识别数据包的stream ID号
|
public int cuid;//用于识别数据包的stream ID号
|
||||||
public long number;//数据包的编号,用于排序
|
public long number;//数据包的编号,用于排序
|
||||||
public byte[]data;//数据内容
|
public byte[]data;//数据内容
|
||||||
public int command;//功能标记 0=PING 1=PONG 2=SYN 3=RST
|
public int command;//功能标记 0=PING 1=PONG 2=SYN 3=RST
|
||||||
public long pingtime;//PING计时器
|
public long pingtime;//PING计时器
|
||||||
public int cacheused;
|
public int cacheused;
|
||||||
|
|
||||||
public String lservice;
|
public String lservice;
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ public class KLALBCM {
|
|||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
if(args.length==0){
|
if(args.length==0){
|
||||||
System.out.println("命令行参数输入服务器任意一条线路的地址:端口可以下载服务器线路列表");
|
System.out.println("命令行参数输入服务器任意一条线路的地址:端口可以下载服务器线路列表");
|
||||||
System.out.println("命令行参数输入服务器名称即可启动负载均衡");
|
System.out.println("命令行参数输入服务器名称即可启动负载均衡");
|
||||||
}else if(args.length==1) {
|
}else if(args.length==1) {
|
||||||
if(args[0].equals("-gui")) {
|
if(args[0].equals("-gui")) {
|
||||||
KLALBClientGUI.main(args);
|
KLALBClientGUI.main(args);
|
||||||
@@ -27,33 +27,35 @@ public class KLALBCM {
|
|||||||
File pdis=KLALBIPList.getSLdir(args[0]);
|
File pdis=KLALBIPList.getSLdir(args[0]);
|
||||||
File f=new File(pdis,"iplist.json");
|
File f=new File(pdis,"iplist.json");
|
||||||
if(f.exists()) {
|
if(f.exists()) {
|
||||||
System.out.println("加载线路列表:"+f);
|
System.out.println("加载线路列表:"+f);
|
||||||
byte[] bytes;
|
|
||||||
try {
|
try {
|
||||||
KLALBIPList.updateIPList(args[0]);
|
KLALBIPList.updateIPList(args[0]);
|
||||||
bytes = Files.readAllBytes(Paths.get(f.toURI()));
|
STJson stj=new STJson(new String(Files.readAllBytes(Paths.get(f.toURI()))));
|
||||||
STJson stj=new STJson(new String(bytes));
|
|
||||||
KLALBClient kc= new KLALBClient();
|
KLALBClient kc= new KLALBClient();
|
||||||
kc.getTls().addAll(stj.getTunnels());
|
kc.getTls().addAll(stj.getTunnels());
|
||||||
kc.connectTunnel();
|
kc.connectTunnel();
|
||||||
List<ServiceElement> lse=stj.getServices();
|
|
||||||
|
ProxyJson pj=new ProxyJson(new File(pdis,"services.json"), stj);
|
||||||
|
kc.getPet().addAll(pj.getPls());
|
||||||
|
kc.listenProxy();
|
||||||
|
/* List<ServiceElement> lse=stj.getServices();
|
||||||
for (Iterator<ServiceElement> iterator = lse.iterator(); iterator.hasNext();) {
|
for (Iterator<ServiceElement> iterator = lse.iterator(); iterator.hasNext();) {
|
||||||
ServiceElement serviceElement = (ServiceElement) iterator.next();
|
ServiceElement serviceElement = (ServiceElement) iterator.next();
|
||||||
ProxyIPPortProperties pippp=new ProxyIPPortProperties(pdis, serviceElement.name, "127.0.0.1", serviceElement.ipport.getPort());
|
ProxyIPPortProperties pippp=new ProxyIPPortProperties(pdis, serviceElement.name, "0.0.0.0", serviceElement.ipport.getPort());
|
||||||
try {
|
try {
|
||||||
kc.open(pippp.getBindPort(),serviceElement, pippp.getBindIP());
|
kc.open(pippp.getBindPort(),serviceElement, pippp.getBindIP());
|
||||||
}catch(BindException e) {
|
}catch(BindException e) {
|
||||||
System.out.println("打开端口失败:"+pippp.getBindIP()+" "+pippp.getBindPort());
|
System.out.println("打开端口失败:"+pippp.getBindIP()+" "+pippp.getBindPort());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
}catch (IOException e) {
|
}catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
System.out.println("线路列表不存在");
|
System.out.println("线路列表不存在");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ import java.util.UUID;
|
|||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import javax.swing.text.html.HTMLDocument.HTMLReader.PreAction;
|
||||||
|
|
||||||
import org.kne.cloud.network.mport.IPPort;
|
import org.kne.cloud.network.mport.IPPort;
|
||||||
import org.kne.cloud.network.mport.ServiceElement;
|
import org.kne.cloud.network.mport.ServiceElement;
|
||||||
import org.kne.cloud.network.mport.ThreadTool;
|
import org.kne.cloud.network.mport.ThreadTool;
|
||||||
@@ -37,19 +39,19 @@ public class KLALBClient {
|
|||||||
private IOThreadManager iom=new IOThreadManager();
|
private IOThreadManager iom=new IOThreadManager();
|
||||||
private List<Tunnel> tls=new ArrayList<>();
|
private List<Tunnel> tls=new ArrayList<>();
|
||||||
private List<TCPListener> tcpl=new ArrayList<>();
|
private List<TCPListener> tcpl=new ArrayList<>();
|
||||||
|
private List<ProxyElement> pet=new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
|
private void open(ProxyElement pe) throws IOException {
|
||||||
public void open(int port, ServiceElement sel,String bindip) throws IOException {
|
TCPListener tl=new TCPListener(pe.getIpport().getPort(),pe.getIpport().getIp());
|
||||||
TCPListener tl=new TCPListener(port,bindip);
|
|
||||||
tl.setCon((s)->{
|
tl.setCon((s)->{
|
||||||
LocalTCPConnection tcc = null;
|
LocalTCPConnection tcc = null;
|
||||||
try {
|
try {
|
||||||
tcc = new LocalTCPConnection(s);
|
tcc = new LocalTCPConnection(s);
|
||||||
tcc.setServiceElement(sel);
|
tcc.setServiceElement(pe.getSe());
|
||||||
//System.out.println("TCP:"+tcc.getCuid()+"已连接");
|
//System.out.println("TCP:"+tcc.getCuid()+"已连接");
|
||||||
iom.handleLocal(tcc,true);
|
iom.handleLocal(tcc,true);
|
||||||
//System.out.println("TCP:"+tcc.getCuid()+"已关闭");
|
//System.out.println("TCP:"+tcc.getCuid()+"已关闭");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}finally {
|
}finally {
|
||||||
@@ -60,12 +62,22 @@ public class KLALBClient {
|
|||||||
});
|
});
|
||||||
tl.open();
|
tl.open();
|
||||||
tcpl.add(tl);
|
tcpl.add(tl);
|
||||||
System.out.println(sel.name+"映射已启动 端口:"+port+" 绑定地址:"+bindip);
|
System.out.println(pe.getSe().name+"映射已启动 端口:"+pe.getIpport().getPort()+" 绑定地址:"+pe.getIpport().getIp());
|
||||||
|
}
|
||||||
|
public void listenProxy() {
|
||||||
|
for (int i = 0; i < pet.size(); i++) {
|
||||||
|
ProxyElement pe=pet.get(i);
|
||||||
|
try {
|
||||||
|
open(pe);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public void connectTunnel() {
|
public void connectTunnel() {
|
||||||
for (int i = 0; i < tls.size(); i++) {
|
for (int i = 0; i < tls.size(); i++) {
|
||||||
Tunnel tll=tls.get(i);
|
Tunnel tll=tls.get(i);
|
||||||
ThreadTool.makeVThreadIfSupport("隧道监视线程", ()->{
|
ThreadTool.makeVThreadIfSupport("隧道监视线程", ()->{
|
||||||
int re=0;
|
int re=0;
|
||||||
RemoteTCPConnection tc=null;
|
RemoteTCPConnection tc=null;
|
||||||
while(iom.isOpen()) {
|
while(iom.isOpen()) {
|
||||||
@@ -84,10 +96,10 @@ public class KLALBClient {
|
|||||||
throw new EOFException();
|
throw new EOFException();
|
||||||
}
|
}
|
||||||
re=0;
|
re=0;
|
||||||
System.out.println(tll+":连接成功");
|
System.out.println(tll+":连接成功");
|
||||||
tll.setState(true);
|
tll.setState(true);
|
||||||
iom.handleRemote(tc);
|
iom.handleRemote(tc);
|
||||||
System.out.println(tll+":连接断开");
|
System.out.println(tll+":连接断开");
|
||||||
tll.setState(false);
|
tll.setState(false);
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -112,6 +124,9 @@ public class KLALBClient {
|
|||||||
public List<Tunnel> getTls() {
|
public List<Tunnel> getTls() {
|
||||||
return tls;
|
return tls;
|
||||||
}
|
}
|
||||||
|
public List<ProxyElement> getPet() {
|
||||||
|
return pet;
|
||||||
|
}
|
||||||
public List<ServiceElement> services=new ArrayList<ServiceElement>();
|
public List<ServiceElement> services=new ArrayList<ServiceElement>();
|
||||||
|
|
||||||
public List<ServiceElement> getServices() {
|
public List<ServiceElement> getServices() {
|
||||||
@@ -123,6 +138,9 @@ public class KLALBClient {
|
|||||||
TCPListener tl = (TCPListener) iterator.next();
|
TCPListener tl = (TCPListener) iterator.next();
|
||||||
tl.close();
|
tl.close();
|
||||||
}
|
}
|
||||||
|
tls.forEach((v)->{
|
||||||
|
v.destroyFrpc();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -85,13 +85,13 @@ public class KLALBClientGUI extends XFrame {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void componentShown(ComponentEvent e) {
|
public void componentShown(ComponentEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void componentResized(ComponentEvent e) {
|
public void componentResized(ComponentEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ public class KLALBClientGUI extends XFrame {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void componentHidden(ComponentEvent e) {
|
public void componentHidden(ComponentEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -116,21 +116,21 @@ public class KLALBClientGUI extends XFrame {
|
|||||||
JButton btnNewButton = new JButton("\u6DFB\u52A0");
|
JButton btnNewButton = new JButton("\u6DFB\u52A0");
|
||||||
btnNewButton.addActionListener(new ActionListener() {
|
btnNewButton.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
String s = JOptionPane.showInputDialog(KLALBClientGUI.this, "输入一条线路的地址");
|
String s = JOptionPane.showInputDialog(KLALBClientGUI.this, "输入一条线路的地址");
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
if (s.equals("")) {
|
if (s.equals("")) {
|
||||||
JOptionPane.showMessageDialog(KLALBClientGUI.this, "输入不能为空", "错误", JOptionPane.WARNING_MESSAGE);
|
JOptionPane.showMessageDialog(KLALBClientGUI.this, "输入不能为空", "错误", JOptionPane.WARNING_MESSAGE);
|
||||||
} else {
|
} else {
|
||||||
ProcessingFrame psf = new ProcessingFrame("正在下载线路列表");
|
ProcessingFrame psf = new ProcessingFrame("正在下载线路列表");
|
||||||
psf.setIconImage(bi);
|
psf.setIconImage(bi);
|
||||||
psf.getProgressBar().setIndeterminate(true);
|
psf.getProgressBar().setIndeterminate(true);
|
||||||
psf.setVisible(true);
|
psf.setVisible(true);
|
||||||
ThreadTool.makeVThreadIfSupport("线路列表获取", () -> {
|
ThreadTool.makeVThreadIfSupport("线路列表获取", () -> {
|
||||||
try {
|
try {
|
||||||
KLALBIPList.createIPList(s);
|
KLALBIPList.createIPList(s);
|
||||||
reloadCB();
|
reloadCB();
|
||||||
} catch (Exception e1) {
|
} catch (Exception e1) {
|
||||||
JOptionPane.showMessageDialog(KLALBClientGUI.this, e1.toString(), "错误",
|
JOptionPane.showMessageDialog(KLALBClientGUI.this, e1.toString(), "错误",
|
||||||
JOptionPane.ERROR_MESSAGE);
|
JOptionPane.ERROR_MESSAGE);
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
@@ -152,7 +152,7 @@ public class KLALBClientGUI extends XFrame {
|
|||||||
t=null;
|
t=null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
t=ThreadTool.makeVThreadIfSupport("客户端主线程", () -> {
|
t=ThreadTool.makeVThreadIfSupport("客户端主线程", () -> {
|
||||||
btnNewButton_1.setEnabled(false);
|
btnNewButton_1.setEnabled(false);
|
||||||
comboBox.setEnabled(false);
|
comboBox.setEnabled(false);
|
||||||
String s = (String) comboBox.getSelectedItem();
|
String s = (String) comboBox.getSelectedItem();
|
||||||
@@ -162,12 +162,10 @@ public class KLALBClientGUI extends XFrame {
|
|||||||
File pdis = KLALBIPList.getSLdir(s);
|
File pdis = KLALBIPList.getSLdir(s);
|
||||||
File f = new File(pdis, "iplist.json");
|
File f = new File(pdis, "iplist.json");
|
||||||
if (f.exists()) {
|
if (f.exists()) {
|
||||||
System.out.println("加载线路列表:" + f);
|
System.out.println("加载线路列表:" + f);;KLALBClient kc=null;
|
||||||
byte[] bytes;KLALBClient kc=null;
|
|
||||||
try {
|
try {
|
||||||
KLALBIPList.updateIPList(s);
|
KLALBIPList.updateIPList(s);
|
||||||
bytes = Files.readAllBytes(Paths.get(f.toURI()));
|
STJson stj=new STJson(new String(Files.readAllBytes(Paths.get(f.toURI()))));
|
||||||
STJson stj = new STJson(new String(bytes));
|
|
||||||
kc = new KLALBClient();
|
kc = new KLALBClient();
|
||||||
kc.getTls().addAll(stj.getTunnels());
|
kc.getTls().addAll(stj.getTunnels());
|
||||||
List<Tunnel>lt=kc.getTls();
|
List<Tunnel>lt=kc.getTls();
|
||||||
@@ -206,20 +204,13 @@ public class KLALBClientGUI extends XFrame {
|
|||||||
ysp.repaint();
|
ysp.repaint();
|
||||||
repaint();
|
repaint();
|
||||||
kc.connectTunnel();
|
kc.connectTunnel();
|
||||||
List<ServiceElement> lse = stj.getServices();
|
|
||||||
for (Iterator<ServiceElement> iterator = lse.iterator(); iterator.hasNext();) {
|
ProxyJson pj=new ProxyJson(new File(pdis,"services.json"), stj);
|
||||||
ServiceElement serviceElement = (ServiceElement) iterator.next();
|
kc.getPet().addAll(pj.getPls());
|
||||||
ProxyIPPortProperties pippp = new ProxyIPPortProperties(pdis, serviceElement.name,
|
kc.listenProxy();
|
||||||
"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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
btnNewButton_1.setForeground(Color.RED);
|
btnNewButton_1.setForeground(Color.RED);
|
||||||
btnNewButton_1.setText("停止");
|
btnNewButton_1.setText("停止");
|
||||||
btnNewButton_1.setEnabled(true);
|
btnNewButton_1.setEnabled(true);
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
@@ -234,7 +225,7 @@ public class KLALBClientGUI extends XFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (ConnectException e) {
|
} catch (ConnectException e) {
|
||||||
JOptionPane.showMessageDialog(KLALBClientGUI.this, e.getMessage(), "错误", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(KLALBClientGUI.this, e.getMessage(), "错误", JOptionPane.ERROR_MESSAGE);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
@@ -246,17 +237,17 @@ public class KLALBClientGUI extends XFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
System.out.println("线路列表不存在");
|
System.out.println("线路列表不存在");
|
||||||
}
|
}
|
||||||
btnNewButton_1.setForeground(Color.GREEN);
|
btnNewButton_1.setForeground(Color.GREEN);
|
||||||
btnNewButton_1.setText("启动");
|
btnNewButton_1.setText("启动");
|
||||||
btnNewButton_1.setEnabled(true);
|
btnNewButton_1.setEnabled(true);
|
||||||
comboBox.setEnabled(true);
|
comboBox.setEnabled(true);
|
||||||
});t.start();
|
});t.start();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
panel_1.add(btnNewButton_1, BorderLayout.EAST);
|
panel_1.add(btnNewButton_1, BorderLayout.EAST);
|
||||||
setTitle("KNE云网络负载均衡客户端");
|
setTitle("KNE云网络负载均衡客户端");
|
||||||
setSize(600, 370);
|
setSize(600, 370);
|
||||||
setLocationRelativeTo(null);
|
setLocationRelativeTo(null);
|
||||||
|
|
||||||
@@ -267,7 +258,7 @@ public class KLALBClientGUI extends XFrame {
|
|||||||
TrayIcon ti = new TrayIcon(bi);
|
TrayIcon ti = new TrayIcon(bi);
|
||||||
ti.setImageAutoSize(true);
|
ti.setImageAutoSize(true);
|
||||||
PopupMenu jpm = new PopupMenu();
|
PopupMenu jpm = new PopupMenu();
|
||||||
MenuItem mi = new MenuItem("退出");
|
MenuItem mi = new MenuItem("退出");
|
||||||
mi.addActionListener(new ActionListener() {
|
mi.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -276,7 +276,7 @@ public class KLALBCore {
|
|||||||
for (int i = 0; i < l.size(); i++) {
|
for (int i = 0; i < l.size(); i++) {
|
||||||
KLALBBlock block=l.get(i);
|
KLALBBlock block=l.get(i);
|
||||||
long timex = (System.nanoTime() - block.sendtime) / 1000000;
|
long timex = (System.nanoTime() - block.sendtime) / 1000000;
|
||||||
if (timex > 100*(1<<Math.min(8,block.resend))+1000*i) {
|
if (timex > 200*(1<<Math.min(8,block.resend))+1000*i) {
|
||||||
submitDataBlock(block);
|
submitDataBlock(block);
|
||||||
block.sendtime = System.nanoTime();
|
block.sendtime = System.nanoTime();
|
||||||
block.resend++;
|
block.resend++;
|
||||||
@@ -284,7 +284,7 @@ public class KLALBCore {
|
|||||||
l.remove(i);
|
l.remove(i);
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
System.out.println("³¬Ê±ÖØ´«£º"+block);
|
System.out.println("超时重传:"+block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class KLALBIPList {
|
|||||||
String json=KLALBIPList.searchTunnels(address);
|
String json=KLALBIPList.searchTunnels(address);
|
||||||
STJson stj=new STJson(json);
|
STJson stj=new STJson(json);
|
||||||
File f=new File(getSLdir(stj.getName()),"iplist.json");
|
File f=new File(getSLdir(stj.getName()),"iplist.json");
|
||||||
System.out.println("线路列表已保存到:"+f);
|
System.out.println("线路列表已保存到:"+f);
|
||||||
f.getParentFile().mkdirs();
|
f.getParentFile().mkdirs();
|
||||||
f.createNewFile();
|
f.createNewFile();
|
||||||
PrintStream ps=new PrintStream(f);
|
PrintStream ps=new PrintStream(f);
|
||||||
@@ -63,6 +63,6 @@ public class KLALBIPList {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new ConnectException("搜索地址失败");
|
throw new ConnectException("搜索地址失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ import org.kne.cloud.network.mport.ServiceElement;
|
|||||||
|
|
||||||
public class KLALBSM {
|
public class KLALBSM {
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
System.out.println("KNE云负载均衡调度软件服务端V0.1");
|
System.out.println("KNE云负载均衡调度软件服务端V0.1");
|
||||||
ServerPropties sp=new ServerPropties();
|
ServerPropties sp=new ServerPropties();
|
||||||
|
|
||||||
int remp=sp.getPort();
|
int remp=sp.getPort();
|
||||||
System.out.println("开放端口:"+remp);
|
System.out.println("开放端口:"+remp);
|
||||||
new KLALBServer(remp,new Supplier<String>() {
|
new KLALBServer(remp,new Supplier<String>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -37,7 +37,7 @@ public class KLALBSM {
|
|||||||
return sj;
|
return sj;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
System.out.println("提示:运行时输入reload可以重新加载配置文件,已经建立的TCP连接不受影响(暂不支持修改开放端口)");
|
System.out.println("提示:运行时输入reload可以重新加载配置文件,已经建立的TCP连接不受影响(暂不支持修改开放端口)");
|
||||||
Scanner scn2=new Scanner(System.in);
|
Scanner scn2=new Scanner(System.in);
|
||||||
while(true) {
|
while(true) {
|
||||||
String command=scn2.next();
|
String command=scn2.next();
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ public class KLALBServer {
|
|||||||
tcc.setTunnel(tll);
|
tcc.setTunnel(tll);
|
||||||
|
|
||||||
UUID uid=new UUID(din.readLong(),din.readLong());
|
UUID uid=new UUID(din.readLong(),din.readLong());
|
||||||
System.out.println(uid);
|
|
||||||
IOThreadManager nx = null;
|
IOThreadManager nx = null;
|
||||||
synchronized (tcpl) {
|
synchronized (tcpl) {
|
||||||
if(whm.containsKey(uid)) {
|
if(whm.containsKey(uid)) {
|
||||||
@@ -57,9 +56,14 @@ public class KLALBServer {
|
|||||||
IOThreadManager n1=nx;
|
IOThreadManager n1=nx;
|
||||||
nx.getCore().setAcceptSYN((b)->{
|
nx.getCore().setAcceptSYN((b)->{
|
||||||
try {
|
try {
|
||||||
|
STJson stj=new STJson(gjso.get());
|
||||||
|
if(!stj.checkSafety(b.lipport)) {
|
||||||
|
System.out.println("未授权的请求:"+b.lipport);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Socket soc=new Socket(b.lipport.getIp(),b.lipport.getPort());
|
Socket soc=new Socket(b.lipport.getIp(),b.lipport.getPort());
|
||||||
LocalTCPConnection ltc=new LocalTCPConnection(soc, b.cuid);
|
LocalTCPConnection ltc=new LocalTCPConnection(soc, b.cuid);
|
||||||
ThreadTool.makeVThreadIfSupport("局域网连接监视线程", ()->{
|
ThreadTool.makeVThreadIfSupport("局域网连接监视线程", ()->{
|
||||||
try {
|
try {
|
||||||
n1.handleLocal(ltc, false);
|
n1.handleLocal(ltc, false);
|
||||||
}finally {
|
}finally {
|
||||||
@@ -68,7 +72,7 @@ public class KLALBServer {
|
|||||||
}).start();
|
}).start();
|
||||||
return true;
|
return true;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("连接本地服务"+b.lipport+"失败,请检查你的本地服务");
|
System.out.println("连接本地服务"+b.lipport+"失败,请检查你的本地服务");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package org.kne.cloud.network.klalb;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import org.kne.cloud.network.mport.IPPort;
|
||||||
|
import org.kne.cloud.network.mport.ServiceElement;
|
||||||
|
|
||||||
|
public class ProxyElement {
|
||||||
|
private ServiceElement se;
|
||||||
|
private IPPort ipport;
|
||||||
|
public ServiceElement getSe() {
|
||||||
|
return se;
|
||||||
|
}
|
||||||
|
public IPPort getIpport() {
|
||||||
|
return ipport;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(ipport, se);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
ProxyElement other = (ProxyElement) obj;
|
||||||
|
return Objects.equals(ipport, other.ipport) && Objects.equals(se, other.se);
|
||||||
|
}
|
||||||
|
public ProxyElement(ServiceElement se, IPPort ipport) {
|
||||||
|
super();
|
||||||
|
this.se = se;
|
||||||
|
this.ipport = ipport;
|
||||||
|
}
|
||||||
|
public ProxyElement() {
|
||||||
|
}
|
||||||
|
public void setSe(ServiceElement se) {
|
||||||
|
this.se = se;
|
||||||
|
}
|
||||||
|
public void setIpport(IPPort ipport) {
|
||||||
|
this.ipport = ipport;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
package org.kne.cloud.network.klalb;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import org.kne.cloud.network.mport.IPPort;
|
||||||
|
import org.kne.cloud.network.mport.ServiceElement;
|
||||||
|
|
||||||
|
import com.google.gson.stream.JsonReader;
|
||||||
|
import com.google.gson.stream.JsonWriter;
|
||||||
|
|
||||||
|
public class ProxyJson {
|
||||||
|
private File f;
|
||||||
|
private List<ProxyElement> pls=new ArrayList<>();
|
||||||
|
public List<ProxyElement> getPls() {
|
||||||
|
return pls;
|
||||||
|
}
|
||||||
|
public ProxyJson(File f,STJson def) throws IOException {
|
||||||
|
super();
|
||||||
|
this.f = f;
|
||||||
|
if(!f.exists()||f.length()==0l) {
|
||||||
|
f.createNewFile();
|
||||||
|
JsonWriter jw=null;
|
||||||
|
try {
|
||||||
|
jw=new JsonWriter(new FileWriter(f));
|
||||||
|
jw.setIndent(" ");
|
||||||
|
jw.beginObject();
|
||||||
|
jw.name("services");
|
||||||
|
jw.beginArray();
|
||||||
|
for (Iterator<ServiceElement> iterator = def.getServices().iterator(); iterator.hasNext();) {
|
||||||
|
ServiceElement proxye = (ServiceElement) iterator.next();
|
||||||
|
jw.beginObject();
|
||||||
|
jw.name("name");
|
||||||
|
jw.value(proxye.name);
|
||||||
|
jw.name("protocol");
|
||||||
|
jw.value(proxye.protocol);
|
||||||
|
jw.name("localaddress");
|
||||||
|
jw.value(proxye.ipport.toString());
|
||||||
|
jw.name("bindaddress");
|
||||||
|
jw.value("0.0.0.0:"+proxye.ipport.getPort());
|
||||||
|
jw.endObject();
|
||||||
|
}
|
||||||
|
jw.endArray();
|
||||||
|
jw.endObject();
|
||||||
|
}finally{
|
||||||
|
if(jw!=null)
|
||||||
|
jw.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JsonReader jr=null;
|
||||||
|
try {
|
||||||
|
jr=new JsonReader(new FileReader(f));
|
||||||
|
jr.beginObject();
|
||||||
|
while(jr.hasNext()) {
|
||||||
|
String name=jr.nextName();
|
||||||
|
switch(name) {
|
||||||
|
case "services":
|
||||||
|
jr.beginArray();
|
||||||
|
while(jr.hasNext()) {
|
||||||
|
jr.beginObject();
|
||||||
|
ProxyElement pe=new ProxyElement();
|
||||||
|
ServiceElement se=new ServiceElement();
|
||||||
|
pe.setSe(se);
|
||||||
|
while(jr.hasNext()) {
|
||||||
|
String n3=jr.nextName();
|
||||||
|
switch(n3) {
|
||||||
|
case "name":
|
||||||
|
se.name=jr.nextString();
|
||||||
|
break;
|
||||||
|
case "protocol":
|
||||||
|
se.protocol=jr.nextString();
|
||||||
|
break;
|
||||||
|
case "localaddress":
|
||||||
|
se.ipport=new IPPort (jr.nextString());
|
||||||
|
break;
|
||||||
|
case "bindaddress":
|
||||||
|
pe.setIpport(new IPPort (jr.nextString()));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
jr.skipValue();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pls.add(pe);
|
||||||
|
jr.endObject();
|
||||||
|
}
|
||||||
|
jr.endArray();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
jr.skipValue();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jr.endObject();
|
||||||
|
}finally {
|
||||||
|
if(jr!=null)
|
||||||
|
jr.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -61,6 +61,16 @@ public class STJson {
|
|||||||
t.setName(sr.nextString());
|
t.setName(sr.nextString());
|
||||||
} else if (n2.equals("remoteaddress")) {
|
} else if (n2.equals("remoteaddress")) {
|
||||||
t.setIpport(new IPPort( sr.nextString()));
|
t.setIpport(new IPPort( sr.nextString()));
|
||||||
|
} else if (n2.equals("frpc")) {
|
||||||
|
StringBuilder sbd=new StringBuilder();
|
||||||
|
sr.beginArray();
|
||||||
|
while(sr.hasNext()) {
|
||||||
|
sbd.append(sr.nextString());
|
||||||
|
sbd.append('\r');
|
||||||
|
sbd.append('\n');
|
||||||
|
}
|
||||||
|
sr.endArray();
|
||||||
|
t.setFrpc(sbd.toString());
|
||||||
} else{
|
} else{
|
||||||
sr.skipValue();
|
sr.skipValue();
|
||||||
}
|
}
|
||||||
@@ -81,4 +91,14 @@ public class STJson {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean checkSafety(IPPort lipport) {
|
||||||
|
for (Iterator iterator = services.iterator(); iterator.hasNext();) {
|
||||||
|
ServiceElement serviceElement = (ServiceElement) iterator.next();
|
||||||
|
if(lipport.equals(serviceElement.ipport)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,21 +32,21 @@ public class TCPConnection {
|
|||||||
if (din != null)
|
if (din != null)
|
||||||
din.close();
|
din.close();
|
||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
// TODO 自动生成的 catch 块
|
// TODO 自动生成的 catch 块
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (dout != null)
|
if (dout != null)
|
||||||
dout.close();
|
dout.close();
|
||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
// TODO 自动生成的 catch 块
|
// TODO 自动生成的 catch 块
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (connect != null)
|
if (connect != null)
|
||||||
connect.close();
|
connect.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// TODO 自动生成的 catch 块
|
// TODO 自动生成的 catch 块
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
connect = null;
|
connect = null;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public class TCPListener {
|
|||||||
while(flag){
|
while(flag){
|
||||||
try {
|
try {
|
||||||
Socket soce=servers.accept();
|
Socket soce=servers.accept();
|
||||||
ThreadTool.makeVThreadIfSupport("śËżÚźŕĚýĎßłĚ",()->{
|
ThreadTool.makeVThreadIfSupport("端口监听线程",()->{
|
||||||
con.accept(soce);
|
con.accept(soce);
|
||||||
}).start();
|
}).start();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|||||||
@@ -32,11 +32,11 @@ public class TPanel extends JPanel{
|
|||||||
setLayout(new BorderLayout(0, 0));
|
setLayout(new BorderLayout(0, 0));
|
||||||
|
|
||||||
tname = new JLabel(name);
|
tname = new JLabel(name);
|
||||||
tname.setFont(new Font("ËÎÌå", Font.BOLD, 20));
|
tname.setFont(new Font("宋体", Font.BOLD, 20));
|
||||||
add(tname, BorderLayout.WEST);
|
add(tname, BorderLayout.WEST);
|
||||||
|
|
||||||
targ = new JLabel();
|
targ = new JLabel();
|
||||||
targ.setFont(new Font("ËÎÌå", Font.PLAIN, 13));
|
targ.setFont(new Font("宋体", Font.PLAIN, 13));
|
||||||
targ.setHorizontalAlignment(SwingConstants.TRAILING);
|
targ.setHorizontalAlignment(SwingConstants.TRAILING);
|
||||||
targ.setForeground(Color.YELLOW);
|
targ.setForeground(Color.YELLOW);
|
||||||
add(targ, BorderLayout.CENTER);
|
add(targ, BorderLayout.CENTER);
|
||||||
|
|||||||
@@ -2,10 +2,13 @@ package org.kne.cloud.network.klalb;
|
|||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
|
import java.io.BufferedReader;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
@@ -19,6 +22,7 @@ import java.util.Set;
|
|||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
@@ -30,6 +34,34 @@ import org.kne.cloud.network.mport.IPPort;
|
|||||||
public class Tunnel{
|
public class Tunnel{
|
||||||
private String name;
|
private String name;
|
||||||
private IPPort ipport;
|
private IPPort ipport;
|
||||||
|
private String frpc;
|
||||||
|
public String getFrpc() {
|
||||||
|
return frpc;
|
||||||
|
}
|
||||||
|
private Thread hook;
|
||||||
|
public void setFrpc(String frpc) {
|
||||||
|
this.frpc = frpc;
|
||||||
|
if(frpc!=null&&hook==null) {
|
||||||
|
hook=new Thread(()->{
|
||||||
|
finalize();
|
||||||
|
});
|
||||||
|
Runtime.getRuntime().addShutdownHook(hook);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void finalize() {
|
||||||
|
if(hook!=null) {
|
||||||
|
try {
|
||||||
|
Runtime.getRuntime().removeShutdownHook(hook);
|
||||||
|
}catch(Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
if(p!=null) {
|
||||||
|
System.out.println("frpc已关闭");
|
||||||
|
p.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
private boolean state=false;
|
private boolean state=false;
|
||||||
|
|
||||||
private TListener tlr;
|
private TListener tlr;
|
||||||
@@ -87,9 +119,62 @@ public class Tunnel{
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return getName()+"$"+getIpport()+" "+delay/1000000;
|
return getName()+"$"+getIpport()+" "+delay/1000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private volatile Process p=null;
|
||||||
public Socket connectClientSocket() throws UnknownHostException, IOException {
|
public Socket connectClientSocket() throws UnknownHostException, IOException {
|
||||||
|
if(frpc!=null) {
|
||||||
|
File f=new File("frpc");
|
||||||
|
f.mkdirs();
|
||||||
|
File inif=new File(f,"frpc.ini");
|
||||||
|
inif.createNewFile();
|
||||||
|
PrintStream ps=new PrintStream(inif);
|
||||||
|
ps.print(frpc);
|
||||||
|
ps.close();
|
||||||
|
AtomicBoolean ab=new AtomicBoolean(false);
|
||||||
|
Object lock=new Object();
|
||||||
|
if(p==null)
|
||||||
|
new Thread(()->{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
p = Runtime.getRuntime().exec("./frpc/frpc_windows_386.exe",null,f);
|
||||||
|
|
||||||
|
|
||||||
|
BufferedReader brd=new BufferedReader(new InputStreamReader( p.getInputStream()));
|
||||||
|
while(true) {
|
||||||
|
String r=brd.readLine();
|
||||||
|
if(r==null)
|
||||||
|
break;
|
||||||
|
System.err.println(r);
|
||||||
|
if(r.contains("start visitor success")) {
|
||||||
|
synchronized (lock) {
|
||||||
|
lock.notifyAll();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
ab.set(true);
|
||||||
|
synchronized (lock) {
|
||||||
|
lock.notifyAll();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
synchronized (lock) {
|
||||||
|
try {
|
||||||
|
lock.wait();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(ab.get()) {
|
||||||
|
throw new IOException("frpc ERROR");
|
||||||
|
}
|
||||||
|
}
|
||||||
Socket socket=new Socket();
|
Socket socket=new Socket();
|
||||||
// socket.bind(new InetSocketAddress(new Random().nextInt(65535)+1));
|
|
||||||
socket.connect(getIpport().getSocketAddress(), Consts.CONNECT_TIMEOUT);
|
socket.connect(getIpport().getSocketAddress(), Consts.CONNECT_TIMEOUT);
|
||||||
return socket;
|
return socket;
|
||||||
}
|
}
|
||||||
@@ -140,22 +225,27 @@ public class Tunnel{
|
|||||||
public AtomicLong getIM() {
|
public AtomicLong getIM() {
|
||||||
return im;
|
return im;
|
||||||
}
|
}
|
||||||
PrintStream ndbg=null;
|
/*PrintStream ndbg=null;
|
||||||
private void initcdbg() {
|
private void initcdbg() {
|
||||||
try {
|
try {
|
||||||
ndbg=new PrintStream(name+".csv");
|
ndbg=new PrintStream(name+".csv");
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
public void updateTraffics(long timems) {
|
public void updateTraffics(long timems) {
|
||||||
tlr.setTraffic(om.get(), im.get(), om.get()-om1, im.get()-im1);
|
tlr.setTraffic(om.get(), im.get(), om.get()-om1, im.get()-im1);
|
||||||
|
/*
|
||||||
if(ndbg==null)
|
if(ndbg==null)
|
||||||
initcdbg();
|
initcdbg();
|
||||||
ndbg.println((om.get()-om1)+ (im.get()-im1)+","+delay);
|
ndbg.println((om.get()-om1)+ (im.get()-im1)+","+delay);
|
||||||
|
*/
|
||||||
om1=om.get();
|
om1=om.get();
|
||||||
im1=im.get();
|
im1=im.get();
|
||||||
}
|
}
|
||||||
|
public void destroyFrpc() {
|
||||||
|
if(p!=null) {
|
||||||
|
p.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ public class PortMultiUse {
|
|||||||
}
|
}
|
||||||
Scanner scn=new Scanner(f);
|
Scanner scn=new Scanner(f);
|
||||||
int remp=scn.nextInt();
|
int remp=scn.nextInt();
|
||||||
System.out.println("端口复用程序V0.2");
|
System.out.println("端口复用程序V0.2");
|
||||||
System.out.println("开放端口:"+remp);
|
System.out.println("开放端口:"+remp);
|
||||||
while(scn.hasNext() ) {
|
while(scn.hasNext() ) {
|
||||||
String s=scn.next();
|
String s=scn.next();
|
||||||
ServiceElement se=new ServiceElement(s);
|
ServiceElement se=new ServiceElement(s);
|
||||||
@@ -32,7 +32,7 @@ public class PortMultiUse {
|
|||||||
}
|
}
|
||||||
scn.close();
|
scn.close();
|
||||||
new PortRelay(remp,services).start();
|
new PortRelay(remp,services).start();
|
||||||
System.out.println("提示:运行时输入reload可以重新加载配置文件,已经建立的TCP连接不受影响(暂不支持修改开放端口)");
|
System.out.println("提示:运行时输入reload可以重新加载配置文件,已经建立的TCP连接不受影响(暂不支持修改开放端口)");
|
||||||
Scanner scn2=new Scanner(System.in);
|
Scanner scn2=new Scanner(System.in);
|
||||||
while(true) {
|
while(true) {
|
||||||
String command=scn2.next();
|
String command=scn2.next();
|
||||||
@@ -56,16 +56,16 @@ public class PortMultiUse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void ept() {
|
private static void ept() {
|
||||||
System.out.println("请填写配置文件后再启动程序!");
|
System.out.println("请填写配置文件后再启动程序!");
|
||||||
System.out.println("格式:");
|
System.out.println("格式:");
|
||||||
System.out.println("开放端口");
|
System.out.println("开放端口");
|
||||||
System.out.println("服务协议1$服务地址1$服务端口1");
|
System.out.println("服务协议1$服务地址1$服务端口1");
|
||||||
System.out.println("服务协议2$服务地址2$服务端口2");
|
System.out.println("服务协议2$服务地址2$服务端口2");
|
||||||
System.out.println("......");
|
System.out.println("......");
|
||||||
System.out.println("服务协议n$服务地址n$服务端口n");
|
System.out.println("服务协议n$服务地址n$服务端口n");
|
||||||
System.out.println("默认服务地址$默认服务端口");
|
System.out.println("默认服务地址$默认服务端口");
|
||||||
System.out.println("");
|
System.out.println("");
|
||||||
System.out.println("按照顺序从上向下匹配,若都不是则匹配最后一个");
|
System.out.println("按照顺序从上向下匹配,若都不是则匹配最后一个");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class PortRelay {
|
|||||||
this.services = services;
|
this.services = services;
|
||||||
this.port = port;
|
this.port = port;
|
||||||
ssc=new TCPListener(port);
|
ssc=new TCPListener(port);
|
||||||
System.out.println("已打开端口:" + port);
|
System.out.println("已打开端口:" + port);
|
||||||
}
|
}
|
||||||
public void start() throws IOException {
|
public void start() throws IOException {
|
||||||
ssc.setCon((s)->{
|
ssc.setCon((s)->{
|
||||||
@@ -44,7 +44,7 @@ public class PortRelay {
|
|||||||
dinl=xdinl;
|
dinl=xdinl;
|
||||||
final DataOutputStream xdoutl =new DataOutputStream(sl.getOutputStream());
|
final DataOutputStream xdoutl =new DataOutputStream(sl.getOutputStream());
|
||||||
doutl=xdoutl;
|
doutl=xdoutl;
|
||||||
Thread tl=ThreadTool.makeVThreadIfSupport("远程->本地 转发线程", ()->{
|
Thread tl=ThreadTool.makeVThreadIfSupport("远程->本地 转发线程", ()->{
|
||||||
try {
|
try {
|
||||||
xdoutl.writeShort(n);
|
xdoutl.writeShort(n);
|
||||||
int len;
|
int len;
|
||||||
@@ -67,7 +67,7 @@ public class PortRelay {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Thread tr=ThreadTool.makeVThreadIfSupport("本地->远程 转发线程", ()->{
|
Thread tr=ThreadTool.makeVThreadIfSupport("本地->远程 转发线程", ()->{
|
||||||
try {
|
try {
|
||||||
int len;
|
int len;
|
||||||
byte[]b=new byte[8192];
|
byte[]b=new byte[8192];
|
||||||
@@ -80,7 +80,7 @@ public class PortRelay {
|
|||||||
try {
|
try {
|
||||||
xdinl.close();
|
xdinl.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// TODO 自动生成的 catch 块
|
// TODO 自动生成的 catch 块
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if(xdout!=null)
|
if(xdout!=null)
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class ServiceElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public ServiceElement() {
|
public ServiceElement() {
|
||||||
// TODO 自动生成的构造函数存根
|
// TODO 自动生成的构造函数存根
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class TCPListener {
|
|||||||
while(flag){
|
while(flag){
|
||||||
try {
|
try {
|
||||||
Socket soce=servers.accept();
|
Socket soce=servers.accept();
|
||||||
ThreadTool.makeVThreadIfSupport("śËżÚźŕĚýĎßłĚ",()->{
|
ThreadTool.makeVThreadIfSupport("端口监听线程",()->{
|
||||||
con.accept(soce);
|
con.accept(soce);
|
||||||
}).start();
|
}).start();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public class ThreadTool {
|
|||||||
}catch(Throwable e) {
|
}catch(Throwable e) {
|
||||||
//e.printStackTrace();
|
//e.printStackTrace();
|
||||||
if(first) {
|
if(first) {
|
||||||
System.out.println("请使用java19以上版本以提高性能!");
|
System.out.println("请使用java19以上版本以提高性能!");
|
||||||
first=false;
|
first=false;
|
||||||
}
|
}
|
||||||
return new Thread(r, name);
|
return new Thread(r, name);
|
||||||
|
|||||||
+31
-31
@@ -31,7 +31,7 @@ public class XFrame extends JFrame {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseReleased(MouseEvent e) {
|
public void mouseReleased(MouseEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,19 +51,19 @@ public class XFrame extends JFrame {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseExited(MouseEvent e) {
|
public void mouseExited(MouseEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseEntered(MouseEvent e) {
|
public void mouseEntered(MouseEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -172,7 +172,7 @@ public class XFrame extends JFrame {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseMoved(MouseEvent e) {
|
public void mouseMoved(MouseEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ public class XFrame extends JFrame {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseMoved(MouseEvent e) {
|
public void mouseMoved(MouseEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,7 +228,7 @@ public class XFrame extends JFrame {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseMoved(MouseEvent e) {
|
public void mouseMoved(MouseEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,7 +255,7 @@ public class XFrame extends JFrame {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseMoved(MouseEvent e) {
|
public void mouseMoved(MouseEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,7 +282,7 @@ public class XFrame extends JFrame {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseMoved(MouseEvent e) {
|
public void mouseMoved(MouseEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,7 +310,7 @@ public class XFrame extends JFrame {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseMoved(MouseEvent e) {
|
public void mouseMoved(MouseEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,7 +338,7 @@ public class XFrame extends JFrame {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseMoved(MouseEvent e) {
|
public void mouseMoved(MouseEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -378,25 +378,25 @@ public class XFrame extends JFrame {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mousePressed(MouseEvent e) {
|
public void mousePressed(MouseEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseReleased(MouseEvent e) {
|
public void mouseReleased(MouseEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseEntered(MouseEvent e) {
|
public void mouseEntered(MouseEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseExited(MouseEvent e) {
|
public void mouseExited(MouseEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -436,25 +436,25 @@ public class XFrame extends JFrame {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mousePressed(MouseEvent e) {
|
public void mousePressed(MouseEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseReleased(MouseEvent e) {
|
public void mouseReleased(MouseEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseEntered(MouseEvent e) {
|
public void mouseEntered(MouseEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseExited(MouseEvent e) {
|
public void mouseExited(MouseEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -474,31 +474,31 @@ public class XFrame extends JFrame {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseReleased(MouseEvent e) {
|
public void mouseReleased(MouseEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mousePressed(MouseEvent e) {
|
public void mousePressed(MouseEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseExited(MouseEvent e) {
|
public void mouseExited(MouseEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseEntered(MouseEvent e) {
|
public void mouseEntered(MouseEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
int s=XFrame.this.getExtendedState();
|
int s=XFrame.this.getExtendedState();
|
||||||
if(s!=JFrame.ICONIFIED) {
|
if(s!=JFrame.ICONIFIED) {
|
||||||
state=s;
|
state=s;
|
||||||
@@ -513,7 +513,7 @@ public class XFrame extends JFrame {
|
|||||||
titlelabel = new JLabel();
|
titlelabel = new JLabel();
|
||||||
sl_titlepanel.putConstraint(SpringLayout.WEST, titlelabel, 31, SpringLayout.WEST, titlepanel);
|
sl_titlepanel.putConstraint(SpringLayout.WEST, titlelabel, 31, SpringLayout.WEST, titlepanel);
|
||||||
sl_titlepanel.putConstraint(SpringLayout.EAST, titlelabel, -31, SpringLayout.EAST, titlepanel);
|
sl_titlepanel.putConstraint(SpringLayout.EAST, titlelabel, -31, SpringLayout.EAST, titlepanel);
|
||||||
titlelabel.setFont(new Font("宋体", Font.PLAIN, 16));
|
titlelabel.setFont(new Font("宋体", Font.PLAIN, 16));
|
||||||
sl_titlepanel.putConstraint(SpringLayout.NORTH, titlelabel, 0, SpringLayout.NORTH, titlepanel);
|
sl_titlepanel.putConstraint(SpringLayout.NORTH, titlelabel, 0, SpringLayout.NORTH, titlepanel);
|
||||||
sl_titlepanel.putConstraint(SpringLayout.SOUTH, titlelabel, 0, SpringLayout.SOUTH, titlepanel);
|
sl_titlepanel.putConstraint(SpringLayout.SOUTH, titlelabel, 0, SpringLayout.SOUTH, titlepanel);
|
||||||
titlelabel.setOpaque(false);
|
titlelabel.setOpaque(false);
|
||||||
@@ -528,13 +528,13 @@ public class XFrame extends JFrame {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void windowOpened(WindowEvent e) {
|
public void windowOpened(WindowEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void windowIconified(WindowEvent e) {
|
public void windowIconified(WindowEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -546,25 +546,25 @@ public class XFrame extends JFrame {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void windowDeactivated(WindowEvent e) {
|
public void windowDeactivated(WindowEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void windowClosing(WindowEvent e) {
|
public void windowClosing(WindowEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void windowClosed(WindowEvent e) {
|
public void windowClosed(WindowEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void windowActivated(WindowEvent e) {
|
public void windowActivated(WindowEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -102,13 +102,13 @@ settings.addContainerListener(new ContainerListener() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void componentMoved(ComponentEvent e) {
|
public void componentMoved(ComponentEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void componentHidden(ComponentEvent e) {
|
public void componentHidden(ComponentEvent e) {
|
||||||
// TODO 自动生成的方法存根
|
// TODO 自动生成的方法存根
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class UIEnv {
|
|||||||
} catch (FontFormatException e1) {
|
} catch (FontFormatException e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
// TODO 自动生成的 catch 块
|
// TODO 自动生成的 catch 块
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user