aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/xmpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java5
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnectionManager.java2
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/jingle/JingleSocks5Transport.java12
3 files changed, 13 insertions, 6 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 d1a523239..561404186 100644
--- a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java
+++ b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java
@@ -568,8 +568,11 @@ public class JingleConnection implements Transferable {
content.setTransportId(this.transportId);
if (this.initialTransport == Transport.IBB) {
content.ibbTransport().setAttribute("block-size", Integer.toString(this.ibbBlockSize));
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": sending IBB offer");
} else {
- content.socks5transport().setChildren(getCandidatesAsElements());
+ final List<Element> candidates = getCandidatesAsElements();
+ Log.d(Config.LOGTAG, String.format("%s: sending S5B offer with %d candidates", account.getJid().asBareJid(), candidates.size()));
+ content.socks5transport().setChildren(candidates);
}
packet.setContent(content);
this.sendJinglePacket(packet, (account, response) -> {
diff --git a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnectionManager.java b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnectionManager.java
index 068924bca..addd350d2 100644
--- a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnectionManager.java
+++ b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnectionManager.java
@@ -106,7 +106,7 @@ public class JingleConnectionManager extends AbstractConnectionManager {
candidate.setPort(Integer.parseInt(port));
candidate.setType(JingleCandidate.TYPE_PROXY);
candidate.setJid(proxy);
- candidate.setPriority(655360 + (initiator ? 10 : 20));
+ candidate.setPriority(655360 + (initiator ? 30 : 0));
primaryCandidates.put(account.getJid().asBareJid(), candidate);
listener.onPrimaryCandidateFound(true, candidate);
} catch (final NumberFormatException e) {
diff --git a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleSocks5Transport.java b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleSocks5Transport.java
index b3f56bba5..1fc69ec6f 100644
--- a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleSocks5Transport.java
+++ b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleSocks5Transport.java
@@ -26,7 +26,8 @@ import de.pixart.messenger.utils.WakeLockHelper;
import de.pixart.messenger.xmpp.jingle.stanzas.Content;
public class JingleSocks5Transport extends JingleTransport {
-
+ private static final int SOCKET_TIMEOUT_DIRECT = 3000;
+ private static final int SOCKET_TIMEOUT_PROXY = 5000;
private final JingleCandidate candidate;
private final JingleConnection connection;
private final String destination;
@@ -93,8 +94,9 @@ public class JingleSocks5Transport extends JingleTransport {
}
}
- private void acceptIncomingSocketConnection(Socket socket) throws IOException {
+ private void acceptIncomingSocketConnection(final Socket socket) throws IOException {
Log.d(Config.LOGTAG, "accepted connection from " + socket.getInetAddress().getHostAddress());
+ socket.setSoTimeout(SOCKET_TIMEOUT_DIRECT);
final byte[] authBegin = new byte[2];
final InputStream inputStream = socket.getInputStream();
final OutputStream outputStream = socket.getOutputStream();
@@ -137,6 +139,7 @@ public class JingleSocks5Transport extends JingleTransport {
outputStream.flush();
if (success) {
Log.d(Config.LOGTAG, connection.getAccount().getJid().asBareJid() + ": successfully processed connection to candidate " + candidate.getHost() + ":" + candidate.getPort());
+ socket.setSoTimeout(0);
this.socket = socket;
this.inputStream = inputStream;
this.outputStream = outputStream;
@@ -152,6 +155,7 @@ public class JingleSocks5Transport extends JingleTransport {
public void connect(final OnTransportConnected callback) {
new Thread(() -> {
+ final int timeout = candidate.getType() == JingleCandidate.TYPE_DIRECT ? SOCKET_TIMEOUT_DIRECT : SOCKET_TIMEOUT_PROXY;
try {
final boolean useTor = connection.getAccount().isOnion() || connection.getConnectionManager().getXmppConnectionService().useTorToConnect();
if (useTor) {
@@ -159,11 +163,11 @@ public class JingleSocks5Transport extends JingleTransport {
} else {
socket = new Socket();
SocketAddress address = new InetSocketAddress(candidate.getHost(), candidate.getPort());
- socket.connect(address, 5000);
+ socket.connect(address, timeout);
}
inputStream = socket.getInputStream();
outputStream = socket.getOutputStream();
- socket.setSoTimeout(5000);
+ socket.setSoTimeout(timeout);
SocksSocketFactory.createSocksConnection(socket, destination, 0);
socket.setSoTimeout(0);
isEstablished = true;