forked from KNEMC/KLALB
KLALB UDP TEST
This commit is contained in:
@@ -6,12 +6,15 @@ import java.net.ConnectException;
|
||||
import java.net.Inet6Address;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.NoRouteToHostException;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketAddress;
|
||||
import java.net.SocketException;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@@ -24,12 +27,22 @@ import java.util.UUID;
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.kne.cloud.network.mport.MultipurposeSocketAddress;
|
||||
import org.kne.cloud.network.mport.NetworkService;
|
||||
import org.kne.cloud.network.mport.ProxyProfileEntry;
|
||||
import org.kne.cloud.network.mport.ThreadTool;
|
||||
import javax.management.openmbean.ArrayType;
|
||||
import javax.net.ServerSocketFactory;
|
||||
import javax.net.SocketFactory;
|
||||
|
||||
import org.kne.cloud.network.MultipurposeSocketAddress;
|
||||
import org.kne.cloud.network.NetworkService;
|
||||
import org.kne.cloud.network.Proxy;
|
||||
import org.kne.cloud.network.SocketType;
|
||||
import org.kne.cloud.network.ThreadTool;
|
||||
import org.kne.debug.TimeDebugger;
|
||||
|
||||
import javassist.ClassPool;
|
||||
import javassist.CtClass;
|
||||
@@ -39,11 +52,20 @@ import javassist.bytecode.CodeAttribute;
|
||||
import javassist.bytecode.CodeIterator;
|
||||
|
||||
public class KLALBController {
|
||||
private LineManager lineManager;
|
||||
private SocketType socketType= new KLALBSocketType();
|
||||
public class KLALBSocketType extends SocketType{
|
||||
|
||||
public KLALBSocketType() {
|
||||
super(new KLALBVirtualSocketFactory(KLALBController.this), new KLALBVirtualServerSocketFactory(KLALBController.this));
|
||||
}
|
||||
|
||||
}
|
||||
public SocketType getSocketType() {
|
||||
return socketType;
|
||||
}
|
||||
|
||||
private Supplier<String> selflineTableSupplier=()->{return null;};
|
||||
|
||||
|
||||
|
||||
|
||||
public Supplier<String> getSelflineTableSupplier() {
|
||||
return selflineTableSupplier;
|
||||
@@ -53,149 +75,156 @@ public class KLALBController {
|
||||
this.selflineTableSupplier = selflineTableSupplier;
|
||||
}
|
||||
|
||||
public LineManager getLineManager() {
|
||||
if(lineManager==null)
|
||||
lineManager=createLineManager();
|
||||
return lineManager;
|
||||
}
|
||||
|
||||
protected LineManager createLineManager() {
|
||||
return new LineManager(this);
|
||||
}
|
||||
|
||||
private Inet6Address self;
|
||||
|
||||
public Inet6Address getSelf() {
|
||||
return self;
|
||||
}
|
||||
|
||||
private Map<Inet6Address, List<KLALBRemoteSocket>> routes = new ConcurrentHashMap<>();
|
||||
|
||||
protected Map<Inet6Address, List<KLALBRemoteSocket>> getRoutes() {
|
||||
return routes;
|
||||
private List<KLALBRemoteLine> lines=new ArrayList<>();
|
||||
//private ReadWriteLock lineslock=new ReentrantReadWriteLock();
|
||||
|
||||
public List<KLALBRemoteLine> getLines() {
|
||||
return lines;
|
||||
}
|
||||
|
||||
private void setLine(Inet6Address vaddr, KLALBRemoteSocket krs) {
|
||||
synchronized (routes) {
|
||||
List<KLALBRemoteSocket> al = routes.computeIfAbsent(vaddr, (vaddr2) -> {
|
||||
return new ArrayList<KLALBRemoteSocket>();
|
||||
});
|
||||
al.add(krs);
|
||||
}
|
||||
private PortBinder streamPortBinder=new PortBinder(this);
|
||||
|
||||
protected PortBinder getStreamPortBinder() {
|
||||
return streamPortBinder;
|
||||
}
|
||||
|
||||
private void removeLine(KLALBRemoteSocket krs) {
|
||||
synchronized (routes) {
|
||||
Iterator<Entry<Inet6Address, List<KLALBRemoteSocket>>> iter = routes.entrySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
Map.Entry<java.net.Inet6Address, java.util.List<org.kne.cloud.network.klalb.KLALBRemoteSocket>> entry = (Map.Entry<java.net.Inet6Address, java.util.List<org.kne.cloud.network.klalb.KLALBRemoteSocket>>) iter
|
||||
.next();
|
||||
entry.getValue().remove(krs);
|
||||
if (entry.getValue().isEmpty()) {
|
||||
iter.remove();
|
||||
}
|
||||
|
||||
public void reconnectImmediately() {
|
||||
synchronized (lines) {
|
||||
for (Iterator<KLALBRemoteLine> iterator = lines.iterator(); iterator.hasNext();) {
|
||||
KLALBRemoteLine klalbRemoteLine = (KLALBRemoteLine) iterator.next();
|
||||
klalbRemoteLine.reconnectImmediately();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private PacketReceiver prc=new PacketReceiver();
|
||||
private class PacketReceiver implements KLALBPacketConsumer{
|
||||
|
||||
public void addRemoteSocket(KLALBRemoteSocket krs) {
|
||||
krs.setController(this);
|
||||
CountDownLatch cdl = new CountDownLatch(1);
|
||||
krs.setPacketReceiver((rec) -> {
|
||||
@Override
|
||||
public void accept(KLALBRemoteLine krs, KLALBPacket rec) {
|
||||
try {
|
||||
if (rec instanceof SYNTPacket) {
|
||||
SYNTPacket synt = (SYNTPacket) rec;
|
||||
KLALBVirtualSocketImpl kvi = bindmap.get(synt.getDport());
|
||||
if (kvi != null) {
|
||||
if (kvi.isListening()) {
|
||||
kvi.getPackReceiver().accept(krs.getRemoteVaddr(), synt);
|
||||
}
|
||||
} else {
|
||||
|
||||
sendPacketToAddress(krs.getRemoteVaddr(), new RSTPacket(synt.getDport(), synt.getSport()),
|
||||
65537);
|
||||
if(rec instanceof PortPacket&&krs.getRemoteVaddr()!=null) {
|
||||
PortPacket pt=(PortPacket) rec;
|
||||
if(!streamPortBinder.distributePacketToConsumer(krs, pt)) {
|
||||
if(!(pt instanceof RSTPacket))
|
||||
sendPacketToAddress(krs.getRemoteVaddr(), new RSTPacket(pt.getDport(), pt.getSport()),
|
||||
0,2);
|
||||
}
|
||||
} else if (rec instanceof SACKTPacket) {
|
||||
SACKTPacket sackt = (SACKTPacket) rec;
|
||||
KLALBVirtualSocketImpl kvi = bindmap.get(sackt.getDport());
|
||||
if (kvi != null) {
|
||||
if (!kvi.isListening()) {
|
||||
kvi.getPackReceiver().accept(krs.getRemoteVaddr(), sackt);
|
||||
}
|
||||
}
|
||||
} else if (rec instanceof RSTPacket) {
|
||||
RSTPacket rst = (RSTPacket) rec;
|
||||
KLALBVirtualSocketImpl kvi = bindmap.get(rst.getDport());
|
||||
if (kvi != null) {
|
||||
if (kvi.isListening()) {
|
||||
KLALBVirtualSocketImpl kvi2 = kvi.getAccepts()
|
||||
.get(new InetSocketAddress(krs.getRemoteVaddr(), rst.getSport()));
|
||||
if (kvi2 != null) {
|
||||
kvi2.getPackReceiver().accept(krs.getRemoteVaddr(), rst);
|
||||
}
|
||||
} else {
|
||||
kvi.getPackReceiver().accept(krs.getRemoteVaddr(), rst);
|
||||
}
|
||||
}
|
||||
} else if (rec instanceof DATATPacket) {
|
||||
DATATPacket datat = (DATATPacket) rec;
|
||||
KLALBVirtualSocketImpl kvi = bindmap.get(datat.getDport());
|
||||
if (kvi != null) {
|
||||
if (kvi.isListening()) {
|
||||
KLALBVirtualSocketImpl kvi2 = kvi.getAccepts()
|
||||
.get(new InetSocketAddress(krs.getRemoteVaddr(), datat.getSport()));
|
||||
if (kvi2 != null) {
|
||||
kvi2.getPackReceiver().accept(krs.getRemoteVaddr(), datat);
|
||||
}
|
||||
} else {
|
||||
kvi.getPackReceiver().accept(krs.getRemoteVaddr(), datat);
|
||||
}
|
||||
}
|
||||
} else if (rec instanceof ACKTPacket) {
|
||||
ACKTPacket ackt = (ACKTPacket) rec;
|
||||
KLALBVirtualSocketImpl kvi = bindmap.get(ackt.getDport());
|
||||
if (kvi != null) {
|
||||
if (kvi.isListening()) {
|
||||
KLALBVirtualSocketImpl kvi2 = kvi.getAccepts()
|
||||
.get(new InetSocketAddress(krs.getRemoteVaddr(), ackt.getSport()));
|
||||
if (kvi2 != null) {
|
||||
kvi2.getPackReceiver().accept(krs.getRemoteVaddr(), ackt);
|
||||
}
|
||||
} else {
|
||||
kvi.getPackReceiver().accept(krs.getRemoteVaddr(), ackt);
|
||||
}
|
||||
}
|
||||
} else if (rec instanceof VADDRPacket) {
|
||||
VADDRPacket var = (VADDRPacket) rec;
|
||||
setLine(var.getVaddr(), krs);
|
||||
cdl.countDown();
|
||||
}else if(rec instanceof LINESPacket) {
|
||||
LINESPacket lpt=(LINESPacket) rec;
|
||||
}else {
|
||||
switch (rec.getType()) {
|
||||
case KLALBPacket.ADDLINES:
|
||||
ADDLINESPacket lpt=(ADDLINESPacket) rec;
|
||||
String s=lpt.getLines();
|
||||
Scanner scn=new Scanner(s);
|
||||
while(scn.hasNext()) {
|
||||
String sn=scn.nextLine();
|
||||
getLineManager().addHostPort(new MultipurposeSocketAddress(sn));
|
||||
MultipurposeSocketAddress msa= new MultipurposeSocketAddress(sn);
|
||||
addRemoteLines(msa);
|
||||
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} catch (NoRouteToHostException e) {
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// TODO 自动生成的 catch 块
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
krs.setCloseListener((x) -> {
|
||||
removeLine(krs);
|
||||
cdl.countDown();
|
||||
});
|
||||
krs.sendPacket(new VADDRPacket(self), 65537);
|
||||
String selflineTable=selflineTableSupplier.get();
|
||||
if(selflineTable!=null)
|
||||
krs.sendPacket(new LINESPacket(selflineTable), 65537);
|
||||
try {
|
||||
cdl.await();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public void addRemoteLines(MultipurposeSocketAddress target) throws SocketTimeoutException, SocketException {
|
||||
synchronized (lines) {
|
||||
|
||||
try {
|
||||
Enumeration<NetworkInterface>eu= NetworkInterface.getNetworkInterfaces();
|
||||
while (eu.hasMoreElements()) {
|
||||
NetworkInterface networkInterface = (NetworkInterface) eu.nextElement();
|
||||
if(networkInterface.isUp()) {
|
||||
//System.out.println(networkInterface+" "+networkInterface.isUp());
|
||||
Enumeration<InetAddress>ei= networkInterface.getInetAddresses();
|
||||
while (ei.hasMoreElements()) {
|
||||
InetAddress inetAddress = (InetAddress) ei.nextElement();
|
||||
MultipurposeSocketAddress bind=new MultipurposeSocketAddress(inetAddress.getHostAddress(),0);
|
||||
if(!checkContainsTargetAndBind(target,bind)) {
|
||||
//System.out.println(target+" "+bind);
|
||||
addRemoteLine( new KLALBRemoteLine(target,bind));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SocketException e) {
|
||||
if(!checkContainsTarget(target))
|
||||
addRemoteLine( new KLALBRemoteLine(target));
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public Inet6Address getRemoteVaddrBySocketAddress(MultipurposeSocketAddress target) throws SocketTimeoutException {
|
||||
KLALBRemoteLine kr=null;
|
||||
synchronized(lines) {
|
||||
for (Iterator iterator = lines.iterator(); iterator.hasNext();) {
|
||||
KLALBRemoteLine klalbRemoteLine = (KLALBRemoteLine) iterator.next();
|
||||
if(target.equals(klalbRemoteLine.getSocketAddress())) {
|
||||
kr=klalbRemoteLine;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(kr==null) {
|
||||
kr=new KLALBRemoteLine(target);
|
||||
addRemoteLine(kr);
|
||||
kr.waitForRemoteVaddrAvaliable(20000);
|
||||
}else {
|
||||
kr.reconnectImmediately();
|
||||
kr.waitForRemoteVaddrAvaliable(20000);
|
||||
}
|
||||
return kr.getRemoteVaddr();
|
||||
}
|
||||
private boolean checkContainsTargetAndBind(MultipurposeSocketAddress target,MultipurposeSocketAddress bind) {
|
||||
boolean b=false;
|
||||
for (Iterator<KLALBRemoteLine> iterator = lines.iterator(); iterator.hasNext();) {
|
||||
KLALBRemoteLine klalbRemoteLine = (KLALBRemoteLine) iterator.next();
|
||||
if(bind.equals(klalbRemoteLine.getBindAddress())&&target.equals(klalbRemoteLine.getSocketAddress())) {
|
||||
b=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
private boolean checkContainsTarget(MultipurposeSocketAddress target) {
|
||||
boolean b=false;
|
||||
for (Iterator<KLALBRemoteLine> iterator = lines.iterator(); iterator.hasNext();) {
|
||||
KLALBRemoteLine klalbRemoteLine = (KLALBRemoteLine) iterator.next();
|
||||
if(target.equals(klalbRemoteLine.getSocketAddress())) {
|
||||
b=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
public void addRemoteLine(KLALBRemoteLine krs) throws SocketTimeoutException {
|
||||
krs.setPacketReceiver(prc);
|
||||
krs.setLocalVaddrSupplier(()->{return self;});
|
||||
krs.startIO();
|
||||
String selflineTable=selflineTableSupplier.get();
|
||||
if(selflineTable!=null)
|
||||
krs.sendPacket(new ADDLINESPacket(selflineTable), 0);
|
||||
synchronized (lines) {
|
||||
lines.add(krs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public KLALBController(Inet6Address self) {
|
||||
this.self = self;
|
||||
@@ -205,135 +234,149 @@ public class KLALBController {
|
||||
this.self=KLALBUtils.uuidToIP(UUID.randomUUID());
|
||||
}
|
||||
|
||||
private Map<Integer, KLALBVirtualSocketImpl> bindmap = new ConcurrentHashMap<>();
|
||||
|
||||
protected Map<Integer, KLALBVirtualSocketImpl> getBindmap() {
|
||||
return bindmap;
|
||||
}
|
||||
|
||||
protected KLALBVirtualSocketImpl createVirtualImpl() {
|
||||
return new KLALBVirtualSocketImpl(this);
|
||||
}
|
||||
|
||||
protected int bind(KLALBVirtualSocketImpl klalbVirtualSocketImpl, int port) throws BindException {
|
||||
synchronized (bindmap) {
|
||||
if (port == 0) {
|
||||
port = allocPort();
|
||||
}
|
||||
if (bindmap.putIfAbsent(port, klalbVirtualSocketImpl) != null) {
|
||||
throw new BindException("port " + port + " is already bind!");
|
||||
}
|
||||
return port;
|
||||
}
|
||||
}
|
||||
|
||||
protected void unbind(KLALBVirtualSocketImpl klalbVirtualSocketImpl) {
|
||||
synchronized (bindmap) {
|
||||
Set<Entry<Integer, KLALBVirtualSocketImpl>> s = bindmap.entrySet();
|
||||
Iterator<Entry<Integer, KLALBVirtualSocketImpl>> it = s.iterator();
|
||||
while (it.hasNext()) {
|
||||
Entry<Integer, KLALBVirtualSocketImpl> object = it.next();
|
||||
if (klalbVirtualSocketImpl.equals(object.getValue())) {
|
||||
it.remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected int allocPort() throws BindException {
|
||||
int i = 1;
|
||||
while (bindmap.containsKey(i)) {
|
||||
if (i == 65535) {
|
||||
throw new BindException("can't alloc port");
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
protected void sendPacketToAddress(Inet6Address addr, KLALBPacket syntPacket, int priority)
|
||||
throws NoRouteToHostException {
|
||||
throws IOException {
|
||||
sendPacketToAddress(addr, syntPacket, priority, 1);
|
||||
}
|
||||
|
||||
protected void sendPacketToAddress(Inet6Address addr, KLALBPacket packet, int priority, int count)
|
||||
throws NoRouteToHostException {
|
||||
synchronized (routes) {
|
||||
List<KLALBRemoteSocket> l = routes.get(addr);
|
||||
if (l == null || l.isEmpty()) {
|
||||
throw new NoRouteToHostException("address unreachable: " + addr);
|
||||
|
||||
private void updateLines2(Inet6Address addr) throws SocketTimeoutException {
|
||||
List<KLALBRemoteLine> l=new ArrayList();
|
||||
synchronized (lines) {
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
KLALBRemoteLine klalbRemoteLine = lines.get(i);
|
||||
if(klalbRemoteLine.isClosed()) {
|
||||
lines.remove(i);
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
if(addr.equals(klalbRemoteLine.getRemoteVaddr())&&klalbRemoteLine.getMonitor().getState()==Monitor.ONLINE) {
|
||||
l.add(klalbRemoteLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(l.isEmpty()) {
|
||||
lines2.remove(addr);
|
||||
}else {
|
||||
lines2.put(addr, l);
|
||||
}
|
||||
}
|
||||
List<KLALBRemoteSocket> l2 = (List<KLALBRemoteSocket>) ((ArrayList<KLALBRemoteSocket>) l).clone();
|
||||
private Map<Inet6Address,List<KLALBRemoteLine>> lines2 = new ConcurrentHashMap<>();
|
||||
private volatile long itm=System.nanoTime();
|
||||
protected void sendPacketToAddress(Inet6Address addr, KLALBPacket packet, int priority, int count)
|
||||
throws IOException {
|
||||
/*if(packet instanceof RSTPacket) {
|
||||
new Exception("-RST-").printStackTrace();
|
||||
}*/
|
||||
//TimeDebugger tdb=new TimeDebugger();
|
||||
//tdb.putTime("start");
|
||||
|
||||
List<KLALBRemoteLine> lines2x;
|
||||
//loop:while(true) {
|
||||
long cur=System.nanoTime();
|
||||
if(cur-itm>10000000L) {
|
||||
itm=cur;
|
||||
lines2.clear();
|
||||
}
|
||||
lines2x=lines2.get(addr);
|
||||
if (lines2x == null || lines2x.isEmpty()) {
|
||||
updateLines2(addr);
|
||||
lines2x=lines2.get(addr);
|
||||
}
|
||||
if (lines2x == null || lines2x.isEmpty()) {
|
||||
throw new NoRouteToHostException("address unreachable: " + addr);
|
||||
}
|
||||
//tdb.putTime("selectLines");
|
||||
/* for (Iterator<KLALBRemoteLine> iterator = lines2x.iterator(); iterator.hasNext();) {
|
||||
KLALBRemoteLine klalbRemoteLine = (KLALBRemoteLine) iterator.next();
|
||||
if(klalbRemoteLine.statLengthBefore(priority)<=65536*10) {
|
||||
break loop;
|
||||
}
|
||||
}
|
||||
try {
|
||||
//System.out.println("slp");
|
||||
Thread.sleep(1);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}*/
|
||||
List<KLALBRemoteLine> l2 = (List<KLALBRemoteLine>) ((ArrayList<KLALBRemoteLine>) lines2x).clone();
|
||||
l2.removeAll(packet.getSendRecord());
|
||||
if(l2.isEmpty()) {
|
||||
l2 = (List<KLALBRemoteSocket>) ((ArrayList<KLALBRemoteSocket>) l).clone();
|
||||
l2 = (List<KLALBRemoteLine>) ((ArrayList<KLALBRemoteLine>) lines2x).clone();
|
||||
}
|
||||
|
||||
//tdb.putTime("findAvaliable");
|
||||
|
||||
int count0 = Math.min(count, l2.size());
|
||||
LineDecitionComparator ldc = new LineDecitionComparator(l2,packet, priority);
|
||||
Collections.sort(l2,ldc);
|
||||
l2.forEach((r)->{
|
||||
r.runPredict(packet,priority);
|
||||
});
|
||||
//Collections.shuffle(l2);
|
||||
Collections.sort(l2);
|
||||
//tdb.putTime("makeDecision");
|
||||
//System.out.println(l2);
|
||||
for (Iterator<KLALBRemoteSocket> iterator = l2.iterator(); iterator.hasNext();) {
|
||||
KLALBRemoteSocket krst = (KLALBRemoteSocket) iterator.next();
|
||||
for (int i = 0; i < l2.size(); i++) {
|
||||
KLALBRemoteLine krst =l2.get(i);
|
||||
krst.sendPacket(packet, priority);
|
||||
packet.getSendRecord().add(krst);
|
||||
count0--;
|
||||
Thread.yield();
|
||||
if (count0 <= 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//tdb.putTime("sendPacket");
|
||||
//tdb.print();
|
||||
/*if(packet instanceof RSTPacket)
|
||||
new Exception().printStackTrace();*/
|
||||
}
|
||||
protected void removeFromSend(Inet6Address addr,KLALBPacket klalbPacket) {
|
||||
synchronized (routes) {
|
||||
List<KLALBRemoteSocket> l = routes.get(addr);
|
||||
if (l != null && !l.isEmpty()) {
|
||||
l.forEach((x)->{
|
||||
x.remoeFromSendQueue(klalbPacket);
|
||||
});
|
||||
synchronized (lines) {
|
||||
for (Iterator<KLALBRemoteLine> iterator = lines.iterator(); iterator.hasNext();) {
|
||||
KLALBRemoteLine klalbRemoteLine = (KLALBRemoteLine) iterator.next();
|
||||
klalbRemoteLine.remoeFromSendQueue(klalbPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected boolean checkIsBind(KLALBVirtualSocketImpl klalbVirtualSocketImpl) {
|
||||
return bindmap.containsValue(klalbVirtualSocketImpl);
|
||||
}
|
||||
private Timer t=new Timer("数据包发送计时器", true);
|
||||
public Timer getTimer() {
|
||||
return t;
|
||||
}
|
||||
|
||||
public void registerToProxyTypeAs(String proxyname) {
|
||||
MultipurposeSocketAddress.getSocketFactoryRegister().put(proxyname, new KLALBVirtualSocketFactory(this));
|
||||
MultipurposeSocketAddress.getServerSocketFactoryRegister().put(proxyname, new KLALBVirtualServerSocketFactory(this));
|
||||
ProxyProfileEntry.getRegister().put(proxyname, new KLALBNetworkService());
|
||||
}
|
||||
|
||||
private class KLALBNetworkService implements NetworkService{
|
||||
|
||||
public void registerToProxyTypeAs(String proxyname) {
|
||||
MultipurposeSocketAddress.getSocketTypeRegister().put(proxyname+"_Stream",socketType);
|
||||
//ProxyProfileEntry.getRegister().put(proxyname, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void listen(MultipurposeSocketAddress msa) {
|
||||
// TODO 自动生成的方法存根
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unlisten(MultipurposeSocketAddress msc) {
|
||||
// TODO 自动生成的方法存根
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(MultipurposeSocketAddress msa) {
|
||||
getLineManager().addHostPort(msa);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unconnect(MultipurposeSocketAddress msc) {
|
||||
getLineManager().removeHostPort(msc);
|
||||
}
|
||||
/*@Override
|
||||
public void listen(MultipurposeSocketAddress msa) {
|
||||
// TODO 自动生成的方法存根
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unlisten(MultipurposeSocketAddress msc) {
|
||||
// TODO 自动生成的方法存根
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(MultipurposeSocketAddress msa) {
|
||||
// TODO 自动生成的方法存根
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unconnect(MultipurposeSocketAddress msc) {
|
||||
// TODO 自动生成的方法存根
|
||||
|
||||
}*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user