Prevents us from attempting to reach Global IPv6 addresses from link local ones. The assumption is not always valid (which is why the behaviour is configurable), but it probably would be in 99% of the cases and for those cases it allows us to drop candidate gathering for the Ice sample test from 4 seconds to 396 ms.
This commit is contained in:
parent
7730d0c1d5
commit
01ba7540b1
@ -24,6 +24,13 @@ public class TransportAddress
|
||||
*/
|
||||
private static final long serialVersionUID = 5076001401234631237L;
|
||||
|
||||
/**
|
||||
* A property that allows us to specify whether we would expect link local
|
||||
* IPv6 addresses to be able to reach globally routable ones.
|
||||
*/
|
||||
public static final String PNAME_ALLOW_LINK_TO_GLOBAL_REACHABILITY
|
||||
= "org.ice4j.ALLOW_LINK_TO_GLOBAL_REACHABILITY";
|
||||
|
||||
/**
|
||||
* The variable that we are using to store the transport that this address
|
||||
* is pertaining to.
|
||||
@ -232,7 +239,36 @@ public class TransportAddress
|
||||
*/
|
||||
public boolean canReach(TransportAddress dst)
|
||||
{
|
||||
return (getTransport() == dst.getTransport())
|
||||
&& (isIPv6() == dst.isIPv6());
|
||||
if( getTransport() != dst.getTransport() )
|
||||
return false;
|
||||
|
||||
if (isIPv6() != dst.isIPv6())
|
||||
return false;
|
||||
|
||||
if (isIPv6())
|
||||
{
|
||||
Inet6Address srcAddr = (Inet6Address)getAddress();
|
||||
Inet6Address dstAddr = (Inet6Address)dst.getAddress();
|
||||
|
||||
if(srcAddr.isLinkLocalAddress() != dstAddr.isLinkLocalAddress())
|
||||
{
|
||||
//this one may actually work if for example we are contacting
|
||||
//the public address of someone in our local network. however
|
||||
//in most cases we would also be able to reach the same address
|
||||
//via a global address of our own and the probability of the
|
||||
//opposite is considerably lower than the probability of us
|
||||
//trying to reach a distant global address through one of our
|
||||
//own. Therefore we would return false here by default.
|
||||
|
||||
if(Boolean.getBoolean(PNAME_ALLOW_LINK_TO_GLOBAL_REACHABILITY))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//may add more unreachability condition here in the future;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user