增加启动xtcp frpc功能

This commit is contained in:
Administrator
2023-01-01 16:20:40 +08:00
parent 1af088a29d
commit 62b22410a3
90 changed files with 11649 additions and 11459 deletions
@@ -25,6 +25,8 @@ import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
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.ServiceElement;
import org.kne.cloud.network.mport.ThreadTool;
@@ -37,19 +39,19 @@ public class KLALBClient {
private IOThreadManager iom=new IOThreadManager();
private List<Tunnel> tls=new ArrayList<>();
private List<TCPListener> tcpl=new ArrayList<>();
private List<ProxyElement> pet=new ArrayList<>();
public void open(int port, ServiceElement sel,String bindip) throws IOException {
TCPListener tl=new TCPListener(port,bindip);
private void open(ProxyElement pe) throws IOException {
TCPListener tl=new TCPListener(pe.getIpport().getPort(),pe.getIpport().getIp());
tl.setCon((s)->{
LocalTCPConnection tcc = null;
try {
tcc = new LocalTCPConnection(s);
tcc.setServiceElement(sel);
//System.out.println("TCP"+tcc.getCuid()+"已连接");
tcc.setServiceElement(pe.getSe());
//System.out.println("TCP"+tcc.getCuid()+"已连接");
iom.handleLocal(tcc,true);
//System.out.println("TCP"+tcc.getCuid()+"已关闭");
//System.out.println("TCP"+tcc.getCuid()+"已关闭");
} catch (IOException e) {
e.printStackTrace();
}finally {
@@ -60,12 +62,22 @@ public class KLALBClient {
});
tl.open();
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() {
for (int i = 0; i < tls.size(); i++) {
Tunnel tll=tls.get(i);
ThreadTool.makeVThreadIfSupport("隧道监视线程", ()->{
ThreadTool.makeVThreadIfSupport("隧道监视线程", ()->{
int re=0;
RemoteTCPConnection tc=null;
while(iom.isOpen()) {
@@ -84,10 +96,10 @@ public class KLALBClient {
throw new EOFException();
}
re=0;
System.out.println(tll+":连接成功");
System.out.println(tll+":连接成功");
tll.setState(true);
iom.handleRemote(tc);
System.out.println(tll+":连接断开");
System.out.println(tll+":连接断开");
tll.setState(false);
} catch (UnknownHostException e) {
e.printStackTrace();
@@ -112,6 +124,9 @@ public class KLALBClient {
public List<Tunnel> getTls() {
return tls;
}
public List<ProxyElement> getPet() {
return pet;
}
public List<ServiceElement> services=new ArrayList<ServiceElement>();
public List<ServiceElement> getServices() {
@@ -123,6 +138,9 @@ public class KLALBClient {
TCPListener tl = (TCPListener) iterator.next();
tl.close();
}
tls.forEach((v)->{
v.destroyFrpc();
});
}