do not offer jingle calls when using Tor

This commit is contained in:
Daniel Gultsch 2020-04-10 16:28:15 +02:00
parent 9d83981f2c
commit 07e671d7c3
4 changed files with 21 additions and 10 deletions

View File

@ -34,14 +34,6 @@ public abstract class AbstractGenerator {
Namespace.JINGLE_TRANSPORTS_IBB, Namespace.JINGLE_TRANSPORTS_IBB,
Namespace.JINGLE_ENCRYPTED_TRANSPORT, Namespace.JINGLE_ENCRYPTED_TRANSPORT,
Namespace.JINGLE_ENCRYPTED_TRANSPORT_OMEMO, 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", "http://jabber.org/protocol/muc",
"jabber:x:conference", "jabber:x:conference",
Namespace.OOB, Namespace.OOB,
@ -63,6 +55,14 @@ public abstract class AbstractGenerator {
private final String[] PRIVACY_SENSITIVE = { private final String[] PRIVACY_SENSITIVE = {
"urn:xmpp:time" //XEP-0202: Entity Time leaks time zone "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 String mVersion = null;
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US); 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()) { if (!mXmppConnectionService.useTorToConnect() && !account.isOnion()) {
features.addAll(Arrays.asList(PRIVACY_SENSITIVE)); features.addAll(Arrays.asList(PRIVACY_SENSITIVE));
features.addAll(Arrays.asList(VOIP_NAMESPACES));
} }
if (mXmppConnectionService.broadcastLastActivity()) { if (mXmppConnectionService.broadcastLastActivity()) {
features.add(Namespace.IDLE); features.add(Namespace.IDLE);

View File

@ -1244,11 +1244,16 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
} }
private void checkPermissionAndTriggerRtpSession() { 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)) { if (hasPermissions(REQUEST_START_AUDIO_CALL, Manifest.permission.RECORD_AUDIO)) {
triggerRtpSession(); triggerRtpSession();
} }
} }
private void triggerRtpSession() { private void triggerRtpSession() {
final Contact contact = conversation.getContact(); final Contact contact = conversation.getContact();
final Intent intent = new Intent(activity, RtpSessionActivity.class); final Intent intent = new Intent(activity, RtpSessionActivity.class);

View File

@ -59,7 +59,7 @@ public class JingleConnectionManager extends AbstractConnectionManager {
final AbstractJingleConnection connection; final AbstractJingleConnection connection;
if (FileTransferDescription.NAMESPACES.contains(descriptionNamespace)) { if (FileTransferDescription.NAMESPACES.contains(descriptionNamespace)) {
connection = new JingleFileTransferConnection(this, id, from); 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()) { if (isBusy()) {
mXmppConnectionService.sendIqPacket(account, packet.generateResponse(IqPacket.TYPE.RESULT), null); mXmppConnectionService.sendIqPacket(account, packet.generateResponse(IqPacket.TYPE.RESULT), null);
final JinglePacket sessionTermination = new JinglePacket(JinglePacket.Action.SESSION_TERMINATE, id.sessionId); 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() { private boolean isBusy() {
for (AbstractJingleConnection connection : this.connections.values()) { for (AbstractJingleConnection connection : this.connections.values()) {
if (connection instanceof JingleRtpConnection) { if (connection instanceof JingleRtpConnection) {
@ -147,7 +151,7 @@ public class JingleConnectionManager extends AbstractConnectionManager {
if ("propose".equals(message.getName())) { if ("propose".equals(message.getName())) {
final Element description = message.findChild("description"); final Element description = message.findChild("description");
final String namespace = description == null ? null : description.getNamespace(); 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()) { if (isBusy()) {
final MessagePacket reject = mXmppConnectionService.getMessageGenerator().sessionReject(from, sessionId); final MessagePacket reject = mXmppConnectionService.getMessageGenerator().sessionReject(from, sessionId);
mXmppConnectionService.sendMessagePacket(account, reject); mXmppConnectionService.sendMessagePacket(account, reject);

View File

@ -902,6 +902,7 @@
<string name="rtp_state_application_failure">Application failure</string> <string name="rtp_state_application_failure">Application failure</string>
<string name="hang_up">Hang up</string> <string name="hang_up">Hang up</string>
<string name="ongoing_call">Ongoing call</string> <string name="ongoing_call">Ongoing call</string>
<string name="disable_tor_to_make_call">Disable Tor to make calls</string>
<plurals name="view_users"> <plurals name="view_users">
<item quantity="one">View %1$d Participant</item> <item quantity="one">View %1$d Participant</item>
<item quantity="other">View %1$d Participants</item> <item quantity="other">View %1$d Participants</item>