forked from KNEMC/KLALB
制作图形界面
This commit is contained in:
@@ -13,6 +13,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.kne.cloud.network.mport.IPPort;
|
||||
import org.kne.cloud.network.mport.ServiceElement;
|
||||
@@ -21,12 +22,12 @@ import org.kne.cloud.network.mport.ThreadTool;
|
||||
public class KLALBServer {
|
||||
|
||||
WeakHashMap<UUID, IOThreadManager> whm=new WeakHashMap<>();
|
||||
public KLALBServer(int port, Map<String,ServiceElement> services,List<Tunnel> tunnels) throws IOException {
|
||||
public KLALBServer(int port,Supplier<String> gjso) throws IOException {
|
||||
TCPListener tcpl=new TCPListener(port);
|
||||
tcpl.setCon((s)->{
|
||||
RemoteTCPConnection tcc=null;
|
||||
try {
|
||||
//s.setSoTimeout(10000);
|
||||
//s.setSoTimeout(10000);
|
||||
tcc=new RemoteTCPConnection(null,s);
|
||||
DataInputStream din=tcc.getDin();
|
||||
int val=din.readShort()&0xffff;
|
||||
@@ -35,21 +36,8 @@ public class KLALBServer {
|
||||
}
|
||||
int x=din.read();
|
||||
if(x==0) {
|
||||
synchronized (services) {
|
||||
tcc.getDout().writeInt(services.size());
|
||||
Collection<ServiceElement> cll=services.values();
|
||||
for (Iterator<ServiceElement> iterator = cll.iterator(); iterator.hasNext();) {
|
||||
ServiceElement tunnel = iterator.next();
|
||||
tcc.getDout().writeUTF(tunnel.toString());
|
||||
}
|
||||
}
|
||||
synchronized (tunnels) {
|
||||
int counts=tunnels.size();
|
||||
tcc.getDout().writeInt(counts);
|
||||
for (int i = 0; i < counts; i++) {
|
||||
tcc.getDout().writeUTF(tunnels.get(i).toString());
|
||||
}
|
||||
}
|
||||
String sj=gjso.get();
|
||||
tcc.getDout().writeUTF(sj);
|
||||
tcc.getDout().flush();
|
||||
return;
|
||||
}
|
||||
@@ -57,7 +45,7 @@ public class KLALBServer {
|
||||
String name = din.readUTF();
|
||||
String ip = din.readUTF();
|
||||
int portx=din.readInt();
|
||||
Tunnel tll=Tunnel.newTunnel(name, ip, portx);
|
||||
Tunnel tll=new Tunnel(name,new IPPort( ip, portx));
|
||||
tcc.setTunnel(tll);
|
||||
|
||||
UUID uid=new UUID(din.readLong(),din.readLong());
|
||||
|
||||
Reference in New Issue
Block a user