aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/xmpp
diff options
context:
space:
mode:
authorChristian Schneppe <christian.schneppe@pix-art.de>2019-10-02 15:36:22 +0200
committerChristian Schneppe <christian.schneppe@pix-art.de>2019-10-02 15:36:22 +0200
commit60ca56c188c179f6ed34270e62c2fe2853142e32 (patch)
tree560d2e0617ffbd91b7a2b638c5398f18f8f1154a /src/main/java/de/pixart/messenger/xmpp
parentcb0be6f06ac8d542c38d6b55babe23e1a207de9f (diff)
report not-acceptable on jingle errors
Diffstat (limited to 'src/main/java/de/pixart/messenger/xmpp')
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java15
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/jingle/JingleInbandTransport.java20
2 files changed, 16 insertions, 19 deletions
diff --git a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java
index 884b27111..d1a523239 100644
--- a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java
+++ b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java
@@ -12,7 +12,6 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
@@ -21,11 +20,9 @@ import java.util.concurrent.ConcurrentHashMap;
import de.pixart.messenger.Config;
import de.pixart.messenger.crypto.axolotl.AxolotlService;
-import de.pixart.messenger.crypto.axolotl.OnMessageCreatedCallback;
import de.pixart.messenger.crypto.axolotl.XmppAxolotlMessage;
import de.pixart.messenger.entities.Account;
import de.pixart.messenger.entities.Conversation;
-import de.pixart.messenger.entities.Conversational;
import de.pixart.messenger.entities.DownloadableFile;
import de.pixart.messenger.entities.Message;
import de.pixart.messenger.entities.Presence;
@@ -277,6 +274,8 @@ public class JingleConnection implements Transferable {
} else {
response = packet.generateResponse(IqPacket.TYPE.ERROR);
+ final Element error = response.addChild("error").setAttribute("type", "cancel");
+ error.addChild("not-acceptable", "urn:ietf:params:xml:ns:xmpp-stanzas");
}
mXmppConnectionService.sendIqPacket(account, response, null);
}
@@ -939,8 +938,9 @@ public class JingleConnection implements Transferable {
private boolean receiveTransportAccept(JinglePacket packet) {
if (packet.getJingleContent().hasIbbTransport()) {
- String receivedBlockSize = packet.getJingleContent().ibbTransport()
- .getAttribute("block-size");
+ final Element ibbTransport = packet.getJingleContent().ibbTransport();
+ final String receivedBlockSize = ibbTransport.getAttribute("block-size");
+ final String sid = ibbTransport.getAttribute("sid");
if (receivedBlockSize != null) {
try {
int bs = Integer.parseInt(receivedBlockSize);
@@ -952,7 +952,9 @@ public class JingleConnection implements Transferable {
}
}
this.transport = new JingleInbandTransport(this, this.transportId, this.ibbBlockSize);
-
+ if (sid == null || !sid.equals(this.transportId)) {
+ Log.w(Config.LOGTAG, String.format("%s: sid in transport-accept (%s) did not match our sid (%s) ", account.getJid().asBareJid(), sid, transportId));
+ }
//might be receive instead if we are not initiating
if (initiating()) {
this.transport.connect(onIbbTransportConnected);
@@ -961,6 +963,7 @@ public class JingleConnection implements Transferable {
}
return true;
} else {
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received invalid transport-accept");
return false;
}
}
diff --git a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleInbandTransport.java b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleInbandTransport.java
index 8b8a16ac9..30986ca0c 100644
--- a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleInbandTransport.java
+++ b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleInbandTransport.java
@@ -79,19 +79,13 @@ public class JingleInbandTransport extends JingleTransport {
open.setAttribute("stanza", "iq");
open.setAttribute("block-size", Integer.toString(this.blockSize));
this.connected = true;
- this.account.getXmppConnection().sendIqPacket(iq,
- new OnIqPacketReceived() {
-
- @Override
- public void onIqPacketReceived(Account account,
- IqPacket packet) {
- if (packet.getType() != IqPacket.TYPE.RESULT) {
- callback.failed();
- } else {
- callback.established();
- }
- }
- });
+ this.account.getXmppConnection().sendIqPacket(iq, (account, packet) -> {
+ if (packet.getType() != IqPacket.TYPE.RESULT) {
+ callback.failed();
+ } else {
+ callback.established();
+ }
+ });
}
@Override