Fixes GitHub issue #24: Wrong preference for choosing default candidate (not in accordance with rfc5245).
This commit is contained in:
parent
469f045b9b
commit
75c2a52f9e
14
pom.xml
14
pom.xml
@ -35,6 +35,20 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>**/*TestSuite.*</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<activation>
|
||||
|
||||
@ -773,24 +773,32 @@ public abstract class Candidate<T extends Candidate<?>>
|
||||
*/
|
||||
protected int getDefaultPreference()
|
||||
{
|
||||
if( getType() == CandidateType.RELAYED_CANDIDATE)
|
||||
// https://tools.ietf.org/html/rfc5245#section-4.1.4
|
||||
//
|
||||
// It is RECOMMENDED that default candidates be chosen based on the
|
||||
// likelihood of those candidates to work with the peer that is being
|
||||
// contacted. It is RECOMMENDED that the default candidates are the
|
||||
// relayed candidates (if relayed candidates are available), server
|
||||
// reflexive candidates (if server reflexive candidates are available),
|
||||
// and finally host candidates.
|
||||
|
||||
switch (getType())
|
||||
{
|
||||
case RELAYED_CANDIDATE:
|
||||
return 30;
|
||||
|
||||
if( getType() == CandidateType.SERVER_REFLEXIVE_CANDIDATE)
|
||||
return 10;
|
||||
case SERVER_REFLEXIVE_CANDIDATE:
|
||||
return 20;
|
||||
|
||||
if( getType() == CandidateType.HOST_CANDIDATE)
|
||||
{
|
||||
//prefer IPv4 as default since many servers would still freak out
|
||||
//when seeing IPv6 address.
|
||||
if(getTransportAddress().isIPv6())
|
||||
return 20;
|
||||
else
|
||||
return 25;
|
||||
case HOST_CANDIDATE:
|
||||
// Prefer IPv4 as default since many servers would still freak out
|
||||
// when seeing IPv6 address.
|
||||
return getTransportAddress().isIPv6() ? 10 : 15;
|
||||
|
||||
default:
|
||||
// WTF?
|
||||
return 5;
|
||||
}
|
||||
|
||||
//WTF?
|
||||
return 5;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -691,21 +691,15 @@ public class Component
|
||||
{
|
||||
synchronized(localCandidates)
|
||||
{
|
||||
Iterator<LocalCandidate> localCandsIter
|
||||
= localCandidates.iterator();
|
||||
Iterator<LocalCandidate> localCandsIter = localCandidates.iterator();
|
||||
|
||||
while (localCandsIter.hasNext())
|
||||
{
|
||||
LocalCandidate cand = localCandsIter.next();
|
||||
|
||||
if(this.defaultCandidate == null)
|
||||
{
|
||||
this.defaultCandidate = cand;
|
||||
continue;
|
||||
}
|
||||
|
||||
if( defaultCandidate.getDefaultPreference()
|
||||
< cand.getDefaultPreference())
|
||||
if ((defaultCandidate == null)
|
||||
|| (defaultCandidate.getDefaultPreference()
|
||||
< cand.getDefaultPreference()))
|
||||
{
|
||||
defaultCandidate = cand;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user