forked from KNEMC/KLALB
UI改进
This commit is contained in:
@@ -79,7 +79,7 @@ public class KLALBController {
|
||||
|
||||
private static final boolean showpacket = false;
|
||||
|
||||
private static final int PREFIX = 112;
|
||||
private static final int PREFIX = 128;//112
|
||||
private static final int DISCOVERY_PORT=4569;
|
||||
|
||||
private static List<IPMulticastDiscovery> ipmd=new ArrayList<>();
|
||||
@@ -168,25 +168,33 @@ public class KLALBController {
|
||||
|
||||
|
||||
for (Iterator<MultipurposeSocketAddress> iterator = st.iterator(); iterator.hasNext();) {
|
||||
MultipurposeSocketAddress multipurposeSocketAddress = (MultipurposeSocketAddress) iterator
|
||||
MultipurposeSocketAddress target = (MultipurposeSocketAddress) iterator
|
||||
.next();
|
||||
for (Iterator<MultipurposeSocketAddress> iterator2 = localaddress.iterator(); iterator2.hasNext();) {
|
||||
addRemoteLines(target);
|
||||
/*for (Iterator<MultipurposeSocketAddress> iterator2 = localaddress.iterator(); iterator2.hasNext();) {
|
||||
MultipurposeSocketAddress bind = (MultipurposeSocketAddress) iterator2
|
||||
.next();
|
||||
try {
|
||||
if(multipurposeSocketAddress.getInetAddress()instanceof Inet4Address&&bind.getInetAddress() instanceof Inet6Address) {
|
||||
if(target.getInetAddress().isLoopbackAddress() &&(!bind.getInetAddress().isLoopbackAddress())) {
|
||||
continue;
|
||||
}
|
||||
if(multipurposeSocketAddress.getInetAddress() instanceof Inet6Address &&bind.getInetAddress() instanceof Inet4Address) {
|
||||
if((!target.getInetAddress().isLoopbackAddress()) &&bind.getInetAddress().isLoopbackAddress()) {
|
||||
continue;
|
||||
}
|
||||
if(target.getInetAddress()instanceof Inet4Address&&bind.getInetAddress() instanceof Inet6Address) {
|
||||
continue;
|
||||
}
|
||||
if(target.getInetAddress() instanceof Inet6Address &&bind.getInetAddress() instanceof Inet4Address) {
|
||||
continue;
|
||||
}
|
||||
} catch (UnknownHostException e) {
|
||||
if(e.getMessage().toLowerCase().contains("no scope_id found"))
|
||||
}
|
||||
if(!checkContainsTargetAndBind(multipurposeSocketAddress,bind)) {
|
||||
if(!checkContainsTargetAndBind(target,bind)) {
|
||||
//System.out.println(target+" "+bind);
|
||||
addRemoteLine( new KLALBRemoteLine(multipurposeSocketAddress,bind));
|
||||
addRemoteLine( new KLALBRemoteLine(target,bind));
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
for (Iterator<KLALBRemoteLine> iterator = lines.iterator(); iterator.hasNext();) {
|
||||
@@ -404,7 +412,8 @@ public class KLALBController {
|
||||
|
||||
}
|
||||
|
||||
public List<KLALBRemoteLine> addRemoteLines(MultipurposeSocketAddress target) {lineslock.writeLock().lock();
|
||||
public List<KLALBRemoteLine> addRemoteLines(MultipurposeSocketAddress target) {
|
||||
lineslock.writeLock().lock();
|
||||
try {
|
||||
List<KLALBRemoteLine>added=new ArrayList<>();
|
||||
try {
|
||||
@@ -416,21 +425,36 @@ public class KLALBController {
|
||||
Enumeration<InetAddress>ei= networkInterface.getInetAddresses();
|
||||
while (ei.hasMoreElements()) {
|
||||
InetAddress inetAddress = (InetAddress) ei.nextElement();
|
||||
try {
|
||||
MultipurposeSocketAddress bind=new MultipurposeSocketAddress(inetAddress.getHostAddress(),0);
|
||||
try {
|
||||
if(target.getInetAddress().isLoopbackAddress() &&(!bind.getInetAddress().isLoopbackAddress())) {
|
||||
continue;
|
||||
}
|
||||
if((!target.getInetAddress().isLoopbackAddress()) &&bind.getInetAddress().isLoopbackAddress()) {
|
||||
continue;
|
||||
}
|
||||
if(target.getInetAddress()instanceof Inet4Address&&bind.getInetAddress() instanceof Inet6Address) {
|
||||
continue;
|
||||
}
|
||||
if(target.getInetAddress() instanceof Inet6Address &&bind.getInetAddress() instanceof Inet4Address) {
|
||||
continue;
|
||||
}
|
||||
//System.out.println(target+"->"+bind);
|
||||
} catch (UnknownHostException e) {
|
||||
if(e.getMessage().trim().toLowerCase().contains("no scope_id found")) {
|
||||
throw e;
|
||||
}
|
||||
//e.printStackTrace();
|
||||
}
|
||||
if(!checkContainsTargetAndBind(target,bind)) {
|
||||
KLALBRemoteLine line=new KLALBRemoteLine(target,bind);
|
||||
addRemoteLine(line );
|
||||
added.add(line);
|
||||
}
|
||||
} catch (UnknownHostException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user