增加流量控制

增加自动按延迟选择线路
This commit is contained in:
Administrator
2022-12-14 17:27:04 +08:00
parent 5d7324db0e
commit e93a5815b4
10 changed files with 431 additions and 71 deletions
@@ -16,6 +16,7 @@ import java.util.WeakHashMap;
import org.kne.cloud.network.mport.IPPort;
import org.kne.cloud.network.mport.ServiceElement;
import org.kne.cloud.network.mport.ThreadTool;
public class KLALBServer {
@@ -66,9 +67,30 @@ public class KLALBServer {
nx=whm.get(uid);
}else {
nx=new IOThreadManager();
IOThreadManager n1=nx;
nx.getCore().setAcceptSYN((b)->{
try {
Socket soc=new Socket(b.lipport.getIp(),b.lipport.getPort());
LocalTCPConnection ltc=new LocalTCPConnection(soc, b.cuid);
ThreadTool.makeVThreadIfSupport("局域网连接监视线程", ()->{
try {
n1.handleLocal(ltc, false);
}finally {
n1.close();
}
}).start();
return true;
} catch (IOException e) {
System.out.println("连接本地服务"+b.lipport+"失败,请检查你的本地服务");
e.printStackTrace();
}
return false;
});
whm.put(uid, nx);
}
}
tcc.getDout().write(0);
tcc.getDout().flush();
nx.handleRemote(tcc);
}catch(IOException e) {
e.printStackTrace();