forked from KNEMC/KLALB
提高性能
This commit is contained in:
@@ -16,7 +16,28 @@ import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.kne.cloud.network.mport.IPPort;
|
||||
import org.kne.cloud.network.mport.ServiceElement;
|
||||
import org.kne.cloud.network.mport.ThreadTool;
|
||||
|
||||
public class KLALBClient {
|
||||
private static Object olock=new Object();
|
||||
static {
|
||||
new Thread(()->{
|
||||
while(true) {
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
synchronized(olock) {
|
||||
olock.notifyAll();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
|
||||
private List<Tunnel> tls=new ArrayList<>();
|
||||
private TCPListener tcpl;
|
||||
private ServiceElement sel;
|
||||
@@ -45,8 +66,14 @@ public class KLALBClient {
|
||||
tc.getDout().flush();
|
||||
aig.incrementAndGet();
|
||||
System.out.println("隧道"+tll+"已连接,可用线路数量:"+ (kcp.getTcps().size()+1));
|
||||
try {
|
||||
kcp.handleSocket(tc);
|
||||
tc.close();
|
||||
|
||||
}catch(IOException e){
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
tc.close();
|
||||
}
|
||||
int n=kcp.getTcps().size();
|
||||
System.out.println("隧道"+tll+"已断开,可用线路数量:"+ n);
|
||||
if(n<=0) {
|
||||
@@ -67,10 +94,12 @@ public class KLALBClient {
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
synchronized(olock) {
|
||||
try {
|
||||
olock.wait();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
@@ -123,7 +152,7 @@ public class KLALBClient {
|
||||
}
|
||||
int s2=tcpc.getDin().readInt();
|
||||
System.out.println("隧道列表:");
|
||||
for (int i = 0; i < s2; i++) {
|
||||
for (int i = 0; i < s2; i++) {
|
||||
String str=tcpc.getDin().readUTF();
|
||||
System.out.println(str);
|
||||
tls.add(Tunnel.newTunnel(str));
|
||||
@@ -157,6 +186,7 @@ public class KLALBClient {
|
||||
kc.setSel(kc.getServices().get(scn.nextInt()));
|
||||
System.out.println("请输入你要映射的本地端口:");
|
||||
kc.open(scn.nextInt());
|
||||
System.out.println("服务已开启");
|
||||
while(true) {
|
||||
String s=scn.next();
|
||||
switch(s) {
|
||||
|
||||
Reference in New Issue
Block a user