Add methods to enable/disable proxy types

This commit is contained in:
vanitasvitae 2017-06-30 15:19:36 +02:00
parent 59a600a0b6
commit dec275aa4d
Signed by: vanitasvitae
GPG Key ID: 62BEE9264BF17311
2 changed files with 29 additions and 8 deletions

View File

@ -55,6 +55,9 @@ public final class JingleS5BTransportManager extends JingleTransportManager<Jing
private List<Bytestream.StreamHost> localStreamHosts = null;
private List<Bytestream.StreamHost> availableStreamHosts = null;
private static boolean useLocalCandidates = true;
private static boolean useExternalCandidates = true;
private JingleS5BTransportManager(XMPPConnection connection) {
super(connection);
JingleContentProviderManager.addJingleContentTransportProvider(getNamespace(), new JingleS5BTransportProvider());
@ -213,4 +216,19 @@ public final class JingleS5BTransportManager extends JingleTransportManager<Jing
return jingle;
}
public static void setUseLocalCandidates(boolean localCandidates) {
JingleS5BTransportManager.useLocalCandidates = localCandidates;
}
public static void setUseExternalCandidates(boolean externalCandidates) {
JingleS5BTransportManager.useExternalCandidates = externalCandidates;
}
public static boolean isUseLocalCandidates() {
return useLocalCandidates;
}
public static boolean isUseExternalCandidates() {
return useExternalCandidates;
}
}

View File

@ -78,16 +78,19 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
Socks5Utils.createDigest(sid, jingleSession.getLocal(), jingleSession.getRemote()));
//Local host
for (Bytestream.StreamHost host : transportManager().getLocalStreamHosts()) {
jb.addTransportCandidate(new JingleS5BTransportCandidate(host, 100, JingleS5BTransportCandidate.Type.direct));
if (JingleS5BTransportManager.isUseLocalCandidates()) {
for (Bytestream.StreamHost host : transportManager().getLocalStreamHosts()) {
jb.addTransportCandidate(new JingleS5BTransportCandidate(host, 100, JingleS5BTransportCandidate.Type.direct));
}
}
List<Bytestream.StreamHost> remoteHosts;
try {
remoteHosts = transportManager().getAvailableStreamHosts();
} catch (InterruptedException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | SmackException.NoResponseException e) {
LOGGER.log(Level.WARNING, "Could not determine available StreamHosts.", e);
remoteHosts = Collections.emptyList();
List<Bytestream.StreamHost> remoteHosts = Collections.emptyList();
if (JingleS5BTransportManager.isUseExternalCandidates()) {
try {
remoteHosts = transportManager().getAvailableStreamHosts();
} catch (InterruptedException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | SmackException.NoResponseException e) {
LOGGER.log(Level.WARNING, "Could not determine available StreamHosts.", e);
}
}
for (Bytestream.StreamHost host : remoteHosts) {