do not include link local in direct candidates

This commit is contained in:
Daniel Gultsch 2019-09-05 13:17:45 +02:00
parent 571c29f92a
commit 0e1c26c569
4 changed files with 19 additions and 22 deletions

View File

@ -26,6 +26,7 @@ import eu.siacs.conversations.Config;
import eu.siacs.conversations.R; import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.DownloadableFile; import eu.siacs.conversations.entities.DownloadableFile;
import eu.siacs.conversations.utils.Compatibility; import eu.siacs.conversations.utils.Compatibility;
import eu.siacs.conversations.utils.CryptoHelper;
public class AbstractConnectionManager { public class AbstractConnectionManager {

View File

@ -26,9 +26,10 @@ public class DirectConnectionUtils {
final Enumeration<InetAddress> inetAddressEnumeration = networkInterface.getInetAddresses(); final Enumeration<InetAddress> inetAddressEnumeration = networkInterface.getInetAddresses();
while (inetAddressEnumeration.hasMoreElements()) { while (inetAddressEnumeration.hasMoreElements()) {
final InetAddress inetAddress = inetAddressEnumeration.nextElement(); final InetAddress inetAddress = inetAddressEnumeration.nextElement();
if (!inetAddress.isLoopbackAddress()) { if (inetAddress.isLoopbackAddress() || inetAddress.isLinkLocalAddress()) {
addresses.add(inetAddress); continue;
} }
addresses.add(inetAddress);
} }
} }
return addresses; return addresses;

View File

@ -110,15 +110,12 @@ public class JingleCandidate {
} }
public static JingleCandidate parse(Element candidate) { public static JingleCandidate parse(Element candidate) {
JingleCandidate parsedCandidate = new JingleCandidate( JingleCandidate parsedCandidate = new JingleCandidate(candidate.getAttribute("cid"), false);
candidate.getAttribute("cid"), false);
parsedCandidate.setHost(candidate.getAttribute("host")); parsedCandidate.setHost(candidate.getAttribute("host"));
parsedCandidate.setJid(InvalidJid.getNullForInvalid(candidate.getAttributeAsJid("jid"))); parsedCandidate.setJid(InvalidJid.getNullForInvalid(candidate.getAttributeAsJid("jid")));
parsedCandidate.setType(candidate.getAttribute("type")); parsedCandidate.setType(candidate.getAttribute("type"));
parsedCandidate.setPriority(Integer.parseInt(candidate parsedCandidate.setPriority(Integer.parseInt(candidate.getAttribute("priority")));
.getAttribute("priority"))); parsedCandidate.setPort(Integer.parseInt(candidate.getAttribute("port")));
parsedCandidate
.setPort(Integer.parseInt(candidate.getAttribute("port")));
return parsedCandidate; return parsedCandidate;
} }

View File

@ -320,22 +320,20 @@ public class JingleConnection implements Transferable {
@Override @Override
public void failed() { public void failed() {
Log.d(Config.LOGTAG, Log.d(Config.LOGTAG, "connection to our own proxy65 candidate failed");
"connection to our own primary candidete failed");
sendInitRequest(); sendInitRequest();
} }
@Override @Override
public void established() { public void established() {
Log.d(Config.LOGTAG, Log.d(Config.LOGTAG, "successfully connected to our own proxy65 candidate");
"successfully connected to our own primary candidate");
mergeCandidate(candidate); mergeCandidate(candidate);
sendInitRequest(); sendInitRequest();
} }
}); });
mergeCandidate(candidate); mergeCandidate(candidate);
} else { } else {
Log.d(Config.LOGTAG, "no primary candidate of our own was found"); Log.d(Config.LOGTAG, "no proxy65 candidate of our own was found");
sendInitRequest(); sendInitRequest();
} }
}); });
@ -619,7 +617,7 @@ public class JingleConnection implements Transferable {
@Override @Override
public void failed() { public void failed() {
Log.d(Config.LOGTAG, "connection to our own primary candidate failed"); Log.d(Config.LOGTAG, "connection to our own proxy65 candidate failed");
content.socks5transport().setChildren(getCandidatesAsElements()); content.socks5transport().setChildren(getCandidatesAsElements());
packet.setContent(content); packet.setContent(content);
sendJinglePacket(packet); sendJinglePacket(packet);
@ -628,7 +626,7 @@ public class JingleConnection implements Transferable {
@Override @Override
public void established() { public void established() {
Log.d(Config.LOGTAG, "connected to primary candidate"); Log.d(Config.LOGTAG, "connected to proxy65 candidate");
mergeCandidate(candidate); mergeCandidate(candidate);
content.socks5transport().setChildren(getCandidatesAsElements()); content.socks5transport().setChildren(getCandidatesAsElements());
packet.setContent(content); packet.setContent(content);
@ -637,7 +635,7 @@ public class JingleConnection implements Transferable {
} }
}); });
} else { } else {
Log.d(Config.LOGTAG, "did not find a primary candidate for ourselves"); Log.d(Config.LOGTAG, "did not find a proxy65 candidate for ourselves");
content.socks5transport().setChildren(getCandidatesAsElements()); content.socks5transport().setChildren(getCandidatesAsElements());
packet.setContent(content); packet.setContent(content);
sendJinglePacket(packet); sendJinglePacket(packet);