properly wrap IPv6 addresses

This commit is contained in:
Daniel Gultsch 2020-05-08 17:52:41 +02:00
parent 5af4c865a7
commit 350fc57d87
2 changed files with 10 additions and 2 deletions

View File

@ -19,4 +19,12 @@ public class IP {
|| PATTERN_IPV6_HEXCOMPRESSED.matcher(server).matches()); || PATTERN_IPV6_HEXCOMPRESSED.matcher(server).matches());
} }
public static String wrapIPv6(final String host) {
if (matches(host)) {
return String.format("[%s]", host);
} else {
return host;
}
}
} }

View File

@ -36,6 +36,7 @@ import eu.siacs.conversations.entities.Conversational;
import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.entities.RtpSessionStatus; import eu.siacs.conversations.entities.RtpSessionStatus;
import eu.siacs.conversations.services.AppRTCAudioManager; import eu.siacs.conversations.services.AppRTCAudioManager;
import eu.siacs.conversations.utils.IP;
import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xml.Element;
import eu.siacs.conversations.xml.Namespace; import eu.siacs.conversations.xml.Namespace;
import eu.siacs.conversations.xmpp.jingle.stanzas.Group; import eu.siacs.conversations.xmpp.jingle.stanzas.Group;
@ -1109,9 +1110,8 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": skipping invalid combination of udp/tls in external services"); Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": skipping invalid combination of udp/tls in external services");
continue; continue;
} }
//TODO wrap ipv6 addresses
final PeerConnection.IceServer.Builder iceServerBuilder = PeerConnection.IceServer final PeerConnection.IceServer.Builder iceServerBuilder = PeerConnection.IceServer
.builder(String.format("%s:%s:%s?transport=%s", type, host, port, transport)); .builder(String.format("%s:%s:%s?transport=%s", type, IP.wrapIPv6(host), port, transport));
iceServerBuilder.setTlsCertPolicy(PeerConnection.TlsCertPolicy.TLS_CERT_POLICY_INSECURE_NO_CHECK); iceServerBuilder.setTlsCertPolicy(PeerConnection.TlsCertPolicy.TLS_CERT_POLICY_INSECURE_NO_CHECK);
if (username != null && password != null) { if (username != null && password != null) {
iceServerBuilder.setUsername(username); iceServerBuilder.setUsername(username);