mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-26 04:28:00 +01:00
Add methods to enable/disable proxy types
This commit is contained in:
parent
59a600a0b6
commit
dec275aa4d
2 changed files with 29 additions and 8 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue