隧道链接改成标准URI格式
This commit is contained in:
@@ -33,7 +33,7 @@ import java.util.function.Consumer;
|
||||
|
||||
import org.kne.cloud.clock.HighAccuracyClock;
|
||||
import org.kne.cloud.network.IPMulticastDiscovery;
|
||||
import org.kne.cloud.network.MultipurposeSocketAddress;
|
||||
import org.kne.cloud.network.MultiProtocolSocketAddress;
|
||||
import org.kne.cloud.network.PortPair;
|
||||
import org.kne.cloud.network.SocketType;
|
||||
import org.kne.cloud.network.ThreadTool;
|
||||
@@ -67,7 +67,7 @@ public class KLALBController {
|
||||
public HighAccuracyClock getClock() {
|
||||
return clock;
|
||||
}
|
||||
private final long TIME_WINDOW=5000000000L;
|
||||
private final long TIME_WINDOW=2000000000L;
|
||||
private SpeedAndTrafficMonitorDataImpl linkMonitor = new SpeedAndTrafficMonitorDataImpl(
|
||||
new HashMapTimestampMonitor<UUID>(HighAccuracyClock.SYSTEM_CLOCK, "up", 100,TIME_WINDOW ),
|
||||
new HashMapTimestampMonitor<UUID>(HighAccuracyClock.SYSTEM_CLOCK, "down", 100, TIME_WINDOW));
|
||||
@@ -76,8 +76,13 @@ public class KLALBController {
|
||||
new HashMapTimestampMonitor<UUID>(HighAccuracyClock.SYSTEM_CLOCK, "up", 100, TIME_WINDOW),
|
||||
new HashMapTimestampMonitor<UUID>(HighAccuracyClock.SYSTEM_CLOCK, "down", 100, TIME_WINDOW));
|
||||
|
||||
private List<MultipurposeSocketAddress> selflineTable = new ArrayList<>();
|
||||
private List<MultiProtocolSocketAddress> selflineTable = new ArrayList<>();
|
||||
|
||||
private List<MultiProtocolSocketAddress> listensSocketAddress = new CopyOnWriteArrayList<>();
|
||||
|
||||
public List<MultiProtocolSocketAddress> getListenSocketAddress() {
|
||||
return listensSocketAddress;
|
||||
}
|
||||
private static final boolean debug=false;
|
||||
private static final boolean showpacket = false;
|
||||
|
||||
@@ -86,10 +91,12 @@ public class KLALBController {
|
||||
|
||||
private static List<IPMulticastDiscovery> ipmd = new ArrayList<>();
|
||||
|
||||
private List<NetworkInterface> networkInterfaceExcept = new ArrayList<>();
|
||||
|
||||
private NetworkInterfaceManager networkInterfaceManager=new NetworkInterfaceManager();
|
||||
public NetworkInterfaceManager getNetworkInterfaceManager() {
|
||||
return networkInterfaceManager;
|
||||
}
|
||||
public List<NetworkInterface> getNetworkInterfaceExcept() {
|
||||
return networkInterfaceExcept;
|
||||
return networkInterfaceManager.getNetworkInterfaceExcept();
|
||||
}
|
||||
|
||||
private List<InetAddress> dnsAddresses = new ArrayList<>();
|
||||
@@ -111,50 +118,23 @@ public class KLALBController {
|
||||
|
||||
private Timer twk = new Timer("网卡检测扫描计时器", true);
|
||||
|
||||
private List<InetAddress> getAllNetworkInterfaceAddress() throws SocketException {
|
||||
List<InetAddress> addresses = new ArrayList<InetAddress>();
|
||||
Enumeration<NetworkInterface> eu = NetworkInterface.getNetworkInterfaces();
|
||||
while (eu.hasMoreElements()) {
|
||||
NetworkInterface networkInterface = (NetworkInterface) eu.nextElement();
|
||||
|
||||
if (networkInterface.getDisplayName()
|
||||
.startsWith(CONST.KLALB_DECENTRALIZED_S_RV6_NETWORK)) {
|
||||
continue;
|
||||
}
|
||||
if (networkInterfaceExcept.contains(networkInterface)) {
|
||||
continue;
|
||||
}
|
||||
if (networkInterface.isUp()) {
|
||||
// System.out.println(networkInterface+" "+networkInterface.isUp());
|
||||
Enumeration<InetAddress> ei = networkInterface.getInetAddresses();
|
||||
while (ei.hasMoreElements()) {
|
||||
InetAddress inetAddress = (InetAddress) ei.nextElement();
|
||||
if (checkIsSelfLocator(inetAddress)) {
|
||||
continue;
|
||||
}
|
||||
addresses.add(inetAddress);
|
||||
}
|
||||
}
|
||||
}
|
||||
return addresses;
|
||||
}
|
||||
|
||||
private TimerTask tsk1 = new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
List<InetAddress> localaddress = getAllNetworkInterfaceAddress();
|
||||
List<InetAddress> localaddress = networkInterfaceManager.getAllNetworkInterfaceAddress();
|
||||
|
||||
for (InetAddress inetAddress : localaddress) {
|
||||
if (!inetAddress.isLoopbackAddress())
|
||||
for (Iterator<MultipurposeSocketAddress> iterator = listens.iterator(); iterator.hasNext();) {
|
||||
MultipurposeSocketAddress tcpl = (MultipurposeSocketAddress) iterator.next();
|
||||
for (Iterator<MultiProtocolSocketAddress> iterator = listensSocketAddress.iterator(); iterator.hasNext();) {
|
||||
MultiProtocolSocketAddress tcpl = (MultiProtocolSocketAddress) iterator.next();
|
||||
|
||||
try {
|
||||
if (tcpl.getInetAddress().isAnyLocalAddress()
|
||||
|| tcpl.getInetAddress().equals(inetAddress)) {
|
||||
MultipurposeSocketAddress bind = new MultipurposeSocketAddress(tcpl.getType(),
|
||||
MultiProtocolSocketAddress bind = new MultiProtocolSocketAddress(tcpl.getProtocol(),
|
||||
inetAddress.getHostAddress(), tcpl.getPort());
|
||||
// System.out.println(bind);
|
||||
synchronized (selflineTable) {
|
||||
@@ -175,46 +155,45 @@ public class KLALBController {
|
||||
try {
|
||||
|
||||
|
||||
Set<MultipurposeSocketAddress> st = new HashSet<>();
|
||||
for (Iterator<IPv6NetworkLink> iterator = srv6Router.getLinkTabel().iterator(); iterator.hasNext();) {
|
||||
IPv6NetworkLink link = iterator.next();
|
||||
if (link instanceof KLALBRemoteLink) {
|
||||
KLALBRemoteLink multipurposeSocketAddress = (KLALBRemoteLink) link;
|
||||
if (multipurposeSocketAddress.getSocketAddress() != null)
|
||||
st.add(multipurposeSocketAddress.getSocketAddress());
|
||||
}
|
||||
}
|
||||
Set<MultiProtocolSocketAddress> st = new HashSet<>();
|
||||
for (IPv6NetworkLink link : srv6Router.getLinkTabel()) {
|
||||
if (link instanceof KLALBRemoteLink) {
|
||||
KLALBRemoteLink multipurposeSocketAddress = (KLALBRemoteLink) link;
|
||||
if (multipurposeSocketAddress.getSocketAddress() != null)
|
||||
st.add(multipurposeSocketAddress.getSocketAddress());
|
||||
}
|
||||
}
|
||||
|
||||
for (Iterator<MultipurposeSocketAddress> iterator = st.iterator(); iterator.hasNext();) {
|
||||
MultipurposeSocketAddress target = (MultipurposeSocketAddress) iterator.next();
|
||||
addRemoteLines(target);
|
||||
}
|
||||
for (Iterator<IPv6NetworkLink> iterator = srv6Router.getLinkTabel().iterator(); iterator.hasNext();) {
|
||||
IPv6NetworkLink link = iterator.next();
|
||||
if (link instanceof KLALBRemoteLink) {
|
||||
KLALBRemoteLink reml = (KLALBRemoteLink) link;
|
||||
if (reml.getSocketAddress() != null) {
|
||||
if (reml.getBindAddress() != null || reml.getRemoteVaddr() != null)
|
||||
try {
|
||||
MultipurposeSocketAddress iadr=reml.getBindAddress();
|
||||
if(iadr!=null) {
|
||||
if (!localaddress.contains(iadr.getInetAddress())) {
|
||||
reml.close();
|
||||
srv6Router.getLinkTabel().remove(reml);
|
||||
}
|
||||
}else {
|
||||
for (MultiProtocolSocketAddress target : st) {
|
||||
addRemoteLines(target);
|
||||
}
|
||||
|
||||
reml.close();
|
||||
}
|
||||
} catch (UnknownHostException e) {
|
||||
reml.close();
|
||||
srv6Router.getLinkTabel().remove(reml);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
for (IPv6NetworkLink link : srv6Router.getLinkTabel()) {
|
||||
if (link instanceof KLALBRemoteLink) {
|
||||
KLALBRemoteLink reml = (KLALBRemoteLink) link;
|
||||
if (reml.getSocketAddress() != null) {
|
||||
if (reml.getBindAddress() != null || reml.getRemoteVaddr() != null)
|
||||
try {
|
||||
MultipurposeSocketAddress iadr = reml.getBindAddress();
|
||||
if (iadr != null) {
|
||||
if (!localaddress.contains(iadr.getInetAddress())) {
|
||||
reml.close();
|
||||
srv6Router.getLinkTabel().remove(reml);
|
||||
}
|
||||
} else {
|
||||
|
||||
reml.close();
|
||||
}
|
||||
} catch (UnknownHostException e) {
|
||||
reml.close();
|
||||
srv6Router.getLinkTabel().remove(reml);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
} finally {
|
||||
lineslock.writeLock().unlock();
|
||||
}
|
||||
@@ -228,9 +207,9 @@ public class KLALBController {
|
||||
}
|
||||
|
||||
private void updateBroadcastNetworkInterface() throws SocketException {
|
||||
for (Iterator<IPMulticastDiscovery> iterator = ipmd.iterator(); iterator.hasNext();) {
|
||||
for (Iterator<IPMulticastDiscovery> iterator = ipmd.iterator(); iterator.hasNext(); ) {
|
||||
IPMulticastDiscovery ipMulticastDiscovery = (IPMulticastDiscovery) iterator.next();
|
||||
if (ipMulticastDiscovery.isClosed() || (!ipMulticastDiscovery.getNinterface().isUp())
|
||||
if (ipMulticastDiscovery.isClosed() || (!ipMulticastDiscovery.getInterface().isUp())
|
||||
|| (configItem != null && configItem.isDenyLineTableBroadcast())) {
|
||||
iterator.remove();
|
||||
try {
|
||||
@@ -238,99 +217,86 @@ public class KLALBController {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(debug)
|
||||
System.out.println("关闭网卡地址广播:" + ipMulticastDiscovery.getNinterface());
|
||||
if (debug)
|
||||
System.out.println("关闭网卡地址广播:" + ipMulticastDiscovery.getInterface());
|
||||
}
|
||||
}
|
||||
|
||||
if (configItem != null && configItem.isDenyLineTableBroadcast()) {
|
||||
|
||||
} else {
|
||||
Enumeration<NetworkInterface> eu2 = NetworkInterface.getNetworkInterfaces();
|
||||
while (eu2.hasMoreElements()) {
|
||||
NetworkInterface networkInterface = (NetworkInterface) eu2.nextElement();
|
||||
if (networkInterface.getDisplayName()
|
||||
.startsWith(CONST.KLALB_DECENTRALIZED_S_RV6_NETWORK)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (networkInterfaceExcept.contains(networkInterface)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (networkInterface.isUp()) {
|
||||
|
||||
Enumeration<InetAddress> ei = networkInterface.getInetAddresses();
|
||||
loop: while (ei.hasMoreElements()) {
|
||||
InetAddress bidr = (InetAddress) ei.nextElement();
|
||||
if (checkIsSelfLocator(bidr)) {
|
||||
continue;
|
||||
}
|
||||
for (Iterator<IPMulticastDiscovery> iterator = ipmd.iterator(); iterator.hasNext();) {
|
||||
IPMulticastDiscovery ipMulticastDiscovery = (IPMulticastDiscovery) iterator.next();
|
||||
if (networkInterface.equals(ipMulticastDiscovery.getNinterface())
|
||||
&& bidr.equals(ipMulticastDiscovery.getBind().getAddress())) {
|
||||
continue loop;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// InetAddress bidr=InetAddress.getByName("::0");
|
||||
|
||||
if (bidr instanceof Inet6Address) {
|
||||
IPMulticastDiscovery ipd = new IPMulticastDiscovery(
|
||||
new InetSocketAddress(bidr, DISCOVERY_PORT),
|
||||
new InetSocketAddress(InetAddress.getByName("ff02::2486"),
|
||||
DISCOVERY_PORT),
|
||||
networkInterface, selflineTable, nodeuuid,10000L);
|
||||
ipd.setCon((mpa) -> {
|
||||
// System.out.println("添加本地IPv6链路:"+mpa);
|
||||
try {
|
||||
if (!checkIsSelf(mpa))
|
||||
addRemoteLines(mpa);
|
||||
} catch (UnknownHostException e) {
|
||||
}
|
||||
});
|
||||
ipd.start();
|
||||
ipmd.add(ipd);
|
||||
} else if (bidr instanceof Inet4Address) {
|
||||
// bidr=InetAddress.getByName("0.0.0.0");
|
||||
IPMulticastDiscovery ipd2 = new IPMulticastDiscovery(
|
||||
new InetSocketAddress(bidr, DISCOVERY_PORT),
|
||||
new InetSocketAddress(InetAddress.getByName("224.0.0.86"),
|
||||
DISCOVERY_PORT),
|
||||
networkInterface, selflineTable,nodeuuid, 10000L);
|
||||
ipd2.setCon((mpa) -> {
|
||||
// System.out.println("添加本地IPv4链路:"+mpa);
|
||||
try {
|
||||
if (!checkIsSelf(mpa))
|
||||
addRemoteLines(mpa);
|
||||
} catch (UnknownHostException e) {
|
||||
}
|
||||
});
|
||||
ipd2.start();
|
||||
ipmd.add(ipd2);
|
||||
}
|
||||
if(debug)
|
||||
System.out.println("开启网卡地址广播:" + networkInterface);
|
||||
} catch (BindException e) {
|
||||
// e.printStackTrace();
|
||||
} catch (UnknownHostException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
List<NetworkInterface> interfaceList = networkInterfaceManager.getAllAvaliableNetworkInterface();
|
||||
for(NetworkInterface networkInterface:interfaceList){
|
||||
List<InetAddress> addressList= networkInterfaceManager.getNetworkInterfaceAddress(networkInterface);
|
||||
loop:for (InetAddress bidr:addressList) {
|
||||
|
||||
for (IPMulticastDiscovery ipMulticastDiscovery : ipmd) {
|
||||
if (networkInterface.equals(ipMulticastDiscovery.getInterface())
|
||||
&& bidr.equals(ipMulticastDiscovery.getBind().getAddress())) {
|
||||
continue loop;
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// InetAddress bidr=InetAddress.getByName("::0");
|
||||
|
||||
if (bidr instanceof Inet6Address) {
|
||||
IPMulticastDiscovery ipd = new IPMulticastDiscovery(new InetSocketAddress(bidr,DISCOVERY_PORT),
|
||||
new InetSocketAddress(InetAddress.getByName("ff02::2486"),
|
||||
DISCOVERY_PORT),
|
||||
networkInterface, listensSocketAddress, nodeuuid, 10000L);
|
||||
ipd.setCon((mpa) -> {
|
||||
if (debug)
|
||||
System.out.println("添加本地IPv6链路:" + mpa);
|
||||
try {
|
||||
if (!checkIsSelf(mpa))
|
||||
addRemoteLines(mpa);
|
||||
} catch (UnknownHostException e) {
|
||||
}
|
||||
});
|
||||
ipd.start();
|
||||
ipmd.add(ipd);
|
||||
} else if (bidr instanceof Inet4Address) {
|
||||
// bidr=InetAddress.getByName("0.0.0.0");
|
||||
IPMulticastDiscovery ipd2 = new IPMulticastDiscovery(new InetSocketAddress(bidr,DISCOVERY_PORT),
|
||||
new InetSocketAddress(InetAddress.getByName("224.0.0.86"),
|
||||
DISCOVERY_PORT),
|
||||
networkInterface, listensSocketAddress, nodeuuid, 10000L);
|
||||
ipd2.setCon((mpa) -> {
|
||||
if (debug)
|
||||
System.out.println("添加本地IPv4链路:" + mpa);
|
||||
try {
|
||||
if (!checkIsSelf(mpa))
|
||||
addRemoteLines(mpa);
|
||||
} catch (UnknownHostException e) {
|
||||
}
|
||||
});
|
||||
ipd2.start();
|
||||
ipmd.add(ipd2);
|
||||
}
|
||||
if (debug)
|
||||
System.out.println("开启网卡地址广播:" + networkInterface);
|
||||
} catch (BindException e) {
|
||||
// e.printStackTrace();
|
||||
} catch (UnknownHostException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
private boolean checkIsSelf(MultipurposeSocketAddress inetAddress) throws UnknownHostException {
|
||||
private boolean checkIsSelf(MultiProtocolSocketAddress inetAddress) throws UnknownHostException {
|
||||
|
||||
return inetAddress.getInetAddress().isAnyLocalAddress() || inetAddress.getInetAddress().isLoopbackAddress()
|
||||
|| selflineTable.contains(inetAddress);
|
||||
@@ -345,16 +311,16 @@ public class KLALBController {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
List<MultipurposeSocketAddress> nt = ntptable;
|
||||
List<MultiProtocolSocketAddress> nt = ntptable;
|
||||
// System.out.println("srv6 ip"+nb);
|
||||
if (nvc2 != null) {
|
||||
Set<NTPPeer> sp = nvc2.getPeers();
|
||||
for (MultipurposeSocketAddress server : nt) {
|
||||
for (MultiProtocolSocketAddress server : nt) {
|
||||
sp.add(new NTPPeer(server, NTPv4Packet.NTP_CLIENT));
|
||||
|
||||
}
|
||||
sp.removeIf((p) -> {
|
||||
for (MultipurposeSocketAddress server : nt) {
|
||||
for (MultiProtocolSocketAddress server : nt) {
|
||||
if (server.equals(p.getAddress())) {
|
||||
return false;
|
||||
}
|
||||
@@ -365,33 +331,30 @@ public class KLALBController {
|
||||
}
|
||||
};
|
||||
|
||||
private TimerTask tsk3 = new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (srv6Router != null && routingProtocol != null) {
|
||||
Set<IPv6AddressGroup> nb = srv6Router.getLocators();
|
||||
for (Iterator<IPv6AddressGroup> iterator = nb.iterator(); iterator.hasNext();) {
|
||||
IPv6AddressGroup neighbor = (IPv6AddressGroup) iterator.next();
|
||||
try {
|
||||
InetSocketAddress iaddr = new InetSocketAddress(neighbor.getAddress().toInet6Address(),
|
||||
KLALBRoutingProtocol.DEFAULT_PORT);
|
||||
apiClient.requestOpenLines(iaddr, (v) -> {
|
||||
ThreadTool.makeVDaemonThreadIfSupport("线路添加任务", () -> {
|
||||
for (MultipurposeSocketAddress msa : v) {
|
||||
// System.out.print(msa);
|
||||
addRemoteLines(msa);
|
||||
}
|
||||
}).start();
|
||||
});
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
public void tryConnectMore(){
|
||||
if (srv6Router != null && routingProtocol != null) {
|
||||
Set<IPv6AddressGroup> nb = srv6Router.getLocators();
|
||||
for (Iterator<IPv6AddressGroup> iterator = nb.iterator(); iterator.hasNext();) {
|
||||
IPv6AddressGroup neighbor = (IPv6AddressGroup) iterator.next();
|
||||
try {
|
||||
InetSocketAddress iaddr = new InetSocketAddress(neighbor.getAddress().toInet6Address(),
|
||||
KLALBRoutingProtocol.DEFAULT_PORT);
|
||||
apiClient.requestOpenLines(iaddr, (v) -> {
|
||||
ThreadTool.makeVDaemonThreadIfSupport("线路添加任务", () -> {
|
||||
for (MultiProtocolSocketAddress msa : v) {
|
||||
// System.out.print(msa);
|
||||
addRemoteLines(msa);
|
||||
}
|
||||
}).start();
|
||||
});
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public SpeedAndTrafficMonitorDataImpl getLinkMonitor() {
|
||||
return linkMonitor;
|
||||
@@ -403,6 +366,8 @@ public class KLALBController {
|
||||
|
||||
private SocketType streamSocketType = new KLALBStreamSocketType();
|
||||
|
||||
|
||||
|
||||
public class KLALBStreamSocketType extends SocketType {
|
||||
|
||||
public KLALBStreamSocketType() {
|
||||
@@ -436,7 +401,7 @@ public class KLALBController {
|
||||
}
|
||||
|
||||
|
||||
public List<MultipurposeSocketAddress> getSelflineTable() {
|
||||
public List<MultiProtocolSocketAddress> getSelflineTable() {
|
||||
return selflineTable;
|
||||
}
|
||||
|
||||
@@ -472,13 +437,13 @@ public class KLALBController {
|
||||
|
||||
private KLALBControllerConfigItem configItem;
|
||||
|
||||
public void addRemoteLines(List<MultipurposeSocketAddress> select) {
|
||||
for (MultipurposeSocketAddress target : select) {
|
||||
public void addRemoteLines(List<MultiProtocolSocketAddress> select) {
|
||||
for (MultiProtocolSocketAddress target : select) {
|
||||
addRemoteLines(target);
|
||||
}
|
||||
}
|
||||
|
||||
public List<KLALBRemoteLink> addRemoteLines(MultipurposeSocketAddress target) {
|
||||
public List<KLALBRemoteLink> addRemoteLines(MultiProtocolSocketAddress target) {
|
||||
lineslock.writeLock().lock();
|
||||
try {
|
||||
List<KLALBRemoteLink> added = new ArrayList<>();
|
||||
@@ -492,7 +457,7 @@ public class KLALBController {
|
||||
while (ei.hasMoreElements()) {
|
||||
InetAddress inetAddress = (InetAddress) ei.nextElement();
|
||||
try {
|
||||
MultipurposeSocketAddress bind = new MultipurposeSocketAddress(
|
||||
MultiProtocolSocketAddress bind = new MultiProtocolSocketAddress(
|
||||
inetAddress.getHostAddress(), 0);
|
||||
try {
|
||||
if (target.getInetAddress().isLoopbackAddress()
|
||||
@@ -553,7 +518,7 @@ public class KLALBController {
|
||||
}
|
||||
}
|
||||
|
||||
public List<KLALBRemoteLink> removeRemoteLines(MultipurposeSocketAddress mpsa) {
|
||||
public List<KLALBRemoteLink> removeRemoteLines(MultiProtocolSocketAddress mpsa) {
|
||||
|
||||
List<KLALBRemoteLink> rmved = new ArrayList<>();
|
||||
for (Iterator<IPv6NetworkLink> iterator = srv6Router.getLinkTabel().iterator(); iterator.hasNext();) {
|
||||
@@ -569,7 +534,7 @@ public class KLALBController {
|
||||
return rmved;
|
||||
}
|
||||
|
||||
public Inet6Address getRemoteVaddrBySocketAddress(MultipurposeSocketAddress target) throws SocketTimeoutException {
|
||||
public Inet6Address getRemoteVaddrBySocketAddress(MultiProtocolSocketAddress target) throws SocketTimeoutException {
|
||||
KLALBRemoteLink kr = null;
|
||||
for (Iterator<IPv6NetworkLink> iterator = srv6Router.getLinkTabel().iterator(); iterator.hasNext();) {
|
||||
IPv6NetworkLink link = iterator.next();
|
||||
@@ -593,7 +558,7 @@ public class KLALBController {
|
||||
return kr.getRemoteVaddr().getAddress().toInet6Address();
|
||||
}
|
||||
|
||||
private boolean checkContainsTargetAndBind(MultipurposeSocketAddress target, MultipurposeSocketAddress bind) {
|
||||
private boolean checkContainsTargetAndBind(MultiProtocolSocketAddress target, MultiProtocolSocketAddress bind) {
|
||||
boolean b = false;
|
||||
for (Iterator<IPv6NetworkLink> iterator = srv6Router.getLinkTabel().iterator(); iterator.hasNext();) {
|
||||
IPv6NetworkLink link = iterator.next();
|
||||
@@ -609,7 +574,7 @@ public class KLALBController {
|
||||
return b;
|
||||
}
|
||||
|
||||
private boolean checkContainsTarget(MultipurposeSocketAddress target) {
|
||||
private boolean checkContainsTarget(MultiProtocolSocketAddress target) {
|
||||
boolean b = false;
|
||||
for (Iterator<IPv6NetworkLink> iterator = srv6Router.getLinkTabel().iterator(); iterator.hasNext();) {
|
||||
IPv6NetworkLink link = iterator.next();
|
||||
@@ -639,8 +604,8 @@ public class KLALBController {
|
||||
|
||||
private String generateSelfLineTable() {
|
||||
StringBuilder sbd = new StringBuilder();
|
||||
for (Iterator<MultipurposeSocketAddress> iterator = selflineTable.iterator(); iterator.hasNext();) {
|
||||
MultipurposeSocketAddress klalbRemoteLine = (MultipurposeSocketAddress) iterator.next();
|
||||
for (Iterator<MultiProtocolSocketAddress> iterator = selflineTable.iterator(); iterator.hasNext();) {
|
||||
MultiProtocolSocketAddress klalbRemoteLine = (MultiProtocolSocketAddress) iterator.next();
|
||||
sbd.append(klalbRemoteLine.toString());
|
||||
sbd.append('\n');
|
||||
}
|
||||
@@ -668,7 +633,11 @@ public class KLALBController {
|
||||
}
|
||||
|
||||
private void loadSRv6ProtocolStack(IPv6AddressGroup selfx, boolean enableVirtualAdapter) {
|
||||
networkInterfaceManager.getInetAddressesExcept().add(selfx.getAddress().toInet6Address());
|
||||
srv6Router = new SRv6Router(selfx, clock);
|
||||
if(configItem!=null) {
|
||||
srv6Router.setPerformanceStrategy(PerformanceStrategy.fromDescription(configItem.getPerformanceStrategy()));
|
||||
}
|
||||
srv6Router.runKLALBRouteProtocol();
|
||||
routingProtocol = srv6Router.getKlalbRouteProtol();
|
||||
routingProtocol.addReceiver((addr, packet) -> {
|
||||
@@ -715,7 +684,7 @@ public class KLALBController {
|
||||
// System.out.println(context);
|
||||
try {
|
||||
NTPv4Protocol nvc = new NTPv4Protocol(context,
|
||||
new MultipurposeSocketAddress("{" + iproxyname + "_Datagram}0.0.0.0:123"));
|
||||
new MultiProtocolSocketAddress(iproxyname + "_Datagram","0.0.0.0",123));
|
||||
srv6Router.addSRv6RouterListener(new SRv6RouterListener() {
|
||||
|
||||
@Override
|
||||
@@ -726,7 +695,7 @@ public class KLALBController {
|
||||
for (Neighbor neighbor : nb) {
|
||||
if (neighbor.getLocator() != null)
|
||||
sp.add(new NTPPeer(
|
||||
new MultipurposeSocketAddress(iproxyname + "_Datagram",
|
||||
new MultiProtocolSocketAddress(iproxyname + "_Datagram",
|
||||
neighbor.getLocator().getAddress().toString(), 123),
|
||||
NTPv4Packet.NTP_SYMMETRIC_ACTIVE));
|
||||
|
||||
@@ -747,7 +716,7 @@ public class KLALBController {
|
||||
});
|
||||
}
|
||||
});
|
||||
nvc2 = new NTPv4Protocol(context, new MultipurposeSocketAddress("{UDP}0.0.0.0:0"));// 106.55.184.199
|
||||
nvc2 = new NTPv4Protocol(context, new MultiProtocolSocketAddress("udp","0.0.0.0",0));
|
||||
|
||||
System.out.println(" Loaded: NTP Module");
|
||||
} catch (UnknownHostException e) {
|
||||
@@ -764,7 +733,6 @@ public class KLALBController {
|
||||
this.apiClient = new KLALBRoutingProtocolAPIClient(routingProtocol);
|
||||
twk.schedule(tsk1, 5000, 5000);
|
||||
twk.schedule(tsk2, 5000, 5000);
|
||||
twk.schedule(tsk3, 5000, 5000);
|
||||
}
|
||||
|
||||
public KLALBController() {
|
||||
@@ -830,18 +798,18 @@ public class KLALBController {
|
||||
getIpv6Router().setASN(vasn);
|
||||
}
|
||||
|
||||
List<MultipurposeSocketAddress> linele = configItem.getLineTable();
|
||||
List<MultiProtocolSocketAddress> linele = configItem.getLineTable();
|
||||
if (linele != null) {
|
||||
getSelflineTable().addAll(linele);
|
||||
}
|
||||
List<MultipurposeSocketAddress> linetoc = configItem.getConnectLineTable();
|
||||
List<MultiProtocolSocketAddress> linetoc = configItem.getConnectLineTable();
|
||||
if (linetoc != null) {
|
||||
linetoc.forEach((aline) -> {
|
||||
addRemoteLines(aline);
|
||||
});
|
||||
}
|
||||
|
||||
List<MultipurposeSocketAddress> ntps = configItem.getNtpServerTable();
|
||||
List<MultiProtocolSocketAddress> ntps = configItem.getNtpServerTable();
|
||||
if (ntps != null) {
|
||||
getNTPTable().addAll(ntps);
|
||||
}
|
||||
@@ -1004,24 +972,19 @@ public class KLALBController {
|
||||
|
||||
|
||||
|
||||
private List<MultipurposeSocketAddress> listens = new CopyOnWriteArrayList<>();
|
||||
|
||||
|
||||
public void registerToProxyTypeAs(String proxyname) {
|
||||
MultipurposeSocketAddress.getSocketTypeRegister().put(proxyname + "_Stream", streamSocketType);
|
||||
MultipurposeSocketAddress.getSocketTypeRegister().put(proxyname + "_Datagram", datagramSocketType);
|
||||
MultiProtocolSocketAddress.getSocketTypeRegister().put(proxyname + "_Stream", streamSocketType);
|
||||
MultiProtocolSocketAddress.getSocketTypeRegister().put(proxyname + "_Datagram", datagramSocketType);
|
||||
// ProxyProfileEntry.getRegister().put(proxyname, this);
|
||||
}
|
||||
|
||||
public List<MultipurposeSocketAddress> getListenSocketAddress() {
|
||||
return listens;
|
||||
}
|
||||
|
||||
private List<MultipurposeSocketAddress> ntptable = new CopyOnWriteArrayList();
|
||||
private List<MultiProtocolSocketAddress> ntptable = new CopyOnWriteArrayList();
|
||||
|
||||
private KLALBRoutingProtocol routingProtocol;
|
||||
|
||||
public List<MultipurposeSocketAddress> getNTPTable() {
|
||||
public List<MultiProtocolSocketAddress> getNTPTable() {
|
||||
return ntptable;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user