From 07e671d7c31c5ab5deef76b37cf0f4a168e51136 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 10 Apr 2020 16:28:15 +0200 Subject: [PATCH] do not offer jingle calls when using Tor --- .../generator/AbstractGenerator.java | 17 +++++++++-------- .../conversations/ui/ConversationFragment.java | 5 +++++ .../xmpp/jingle/JingleConnectionManager.java | 8 ++++++-- src/main/res/values/strings.xml | 1 + 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java b/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java index dbb188593..d478a252e 100644 --- a/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java +++ b/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java @@ -34,14 +34,6 @@ public abstract class AbstractGenerator { Namespace.JINGLE_TRANSPORTS_IBB, Namespace.JINGLE_ENCRYPTED_TRANSPORT, Namespace.JINGLE_ENCRYPTED_TRANSPORT_OMEMO, - - //VoIP - Namespace.JINGLE_TRANSPORT_ICE_UDP, - Namespace.JINGLE_FEATURE_AUDIO, - Namespace.JINGLE_FEATURE_VIDEO, - Namespace.JINGLE_APPS_RTP, - Namespace.JINGLE_APPS_DTLS, - "http://jabber.org/protocol/muc", "jabber:x:conference", Namespace.OOB, @@ -63,6 +55,14 @@ public abstract class AbstractGenerator { private final String[] PRIVACY_SENSITIVE = { "urn:xmpp:time" //XEP-0202: Entity Time leaks time zone }; + + private final String[] VOIP_NAMESPACES = { + Namespace.JINGLE_TRANSPORT_ICE_UDP, + Namespace.JINGLE_FEATURE_AUDIO, + Namespace.JINGLE_FEATURE_VIDEO, + Namespace.JINGLE_APPS_RTP, + Namespace.JINGLE_APPS_DTLS, + }; private String mVersion = null; private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US); @@ -132,6 +132,7 @@ public abstract class AbstractGenerator { } if (!mXmppConnectionService.useTorToConnect() && !account.isOnion()) { features.addAll(Arrays.asList(PRIVACY_SENSITIVE)); + features.addAll(Arrays.asList(VOIP_NAMESPACES)); } if (mXmppConnectionService.broadcastLastActivity()) { features.add(Namespace.IDLE); diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index e1638b6db..aec25048e 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -1244,11 +1244,16 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } private void checkPermissionAndTriggerRtpSession() { + if (activity.xmppConnectionService.useTorToConnect() || conversation.getAccount().isOnion()) { + Toast.makeText(activity, R.string.disable_tor_to_make_call, Toast.LENGTH_SHORT).show(); + return; + } if (hasPermissions(REQUEST_START_AUDIO_CALL, Manifest.permission.RECORD_AUDIO)) { triggerRtpSession(); } } + private void triggerRtpSession() { final Contact contact = conversation.getContact(); final Intent intent = new Intent(activity, RtpSessionActivity.class); diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java index 0a4336c3f..30bcf66a4 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java @@ -59,7 +59,7 @@ public class JingleConnectionManager extends AbstractConnectionManager { final AbstractJingleConnection connection; if (FileTransferDescription.NAMESPACES.contains(descriptionNamespace)) { connection = new JingleFileTransferConnection(this, id, from); - } else if (Namespace.JINGLE_APPS_RTP.equals(descriptionNamespace)) { //and not using Tor + } else if (Namespace.JINGLE_APPS_RTP.equals(descriptionNamespace) && !usesTor(account)) { if (isBusy()) { mXmppConnectionService.sendIqPacket(account, packet.generateResponse(IqPacket.TYPE.RESULT), null); final JinglePacket sessionTermination = new JinglePacket(JinglePacket.Action.SESSION_TERMINATE, id.sessionId); @@ -82,6 +82,10 @@ public class JingleConnectionManager extends AbstractConnectionManager { } } + private boolean usesTor(final Account account) { + return account.isOnion() || mXmppConnectionService.useTorToConnect(); + } + private boolean isBusy() { for (AbstractJingleConnection connection : this.connections.values()) { if (connection instanceof JingleRtpConnection) { @@ -147,7 +151,7 @@ public class JingleConnectionManager extends AbstractConnectionManager { if ("propose".equals(message.getName())) { final Element description = message.findChild("description"); final String namespace = description == null ? null : description.getNamespace(); - if (Namespace.JINGLE_APPS_RTP.equals(namespace)) { //and not using Tor + if (Namespace.JINGLE_APPS_RTP.equals(namespace) && !usesTor(account)) { if (isBusy()) { final MessagePacket reject = mXmppConnectionService.getMessageGenerator().sessionReject(from, sessionId); mXmppConnectionService.sendMessagePacket(account, reject); diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 7bf491ed5..ef2267a4a 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -902,6 +902,7 @@ Application failure Hang up Ongoing call + Disable Tor to make calls View %1$d Participant View %1$d Participants