aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/impl
diff options
context:
space:
mode:
authorDanny van Heumen <danny@dannyvanheumen.nl>2015-04-03 16:47:44 +0200
committerDanny van Heumen <danny@dannyvanheumen.nl>2015-04-03 21:37:01 +0200
commit976559f5b1c8aab2467a9159b6ad5a9dbe3c4b6c (patch)
treebf7ce2469a67b833e6a0c39c424a83b6a601caa3 /src/net/java/sip/communicator/impl
parent8319f99727366d3544c2b2288d369832d46b3f45 (diff)
downloadjitsi-976559f5b1c8aab2467a9159b6ad5a9dbe3c4b6c.zip
jitsi-976559f5b1c8aab2467a9159b6ad5a9dbe3c4b6c.tar.gz
jitsi-976559f5b1c8aab2467a9159b6ad5a9dbe3c4b6c.tar.bz2
Added option for resolving all DNS lookups through SOCKS proxy.
Diffstat (limited to 'src/net/java/sip/communicator/impl')
-rw-r--r--src/net/java/sip/communicator/impl/protocol/irc/IrcStack.java76
-rw-r--r--src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderFactoryIrcImpl.java7
-rw-r--r--src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderServiceIrcImpl.java29
3 files changed, 74 insertions, 38 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/irc/IrcStack.java b/src/net/java/sip/communicator/impl/protocol/irc/IrcStack.java
index 03b8e9d..2033b5b 100644
--- a/src/net/java/sip/communicator/impl/protocol/irc/IrcStack.java
+++ b/src/net/java/sip/communicator/impl/protocol/irc/IrcStack.java
@@ -113,21 +113,9 @@ public class IrcStack implements IrcConnectionListener
throws OperationFailedException,
Exception
{
- final IRCServer server;
- final String plainPass = config.getSASL() == null ? password : null;
- if (secureConnection)
- {
- server =
- new SecureIRCServer(host, port, plainPass,
- getCustomSSLContext(host), config.getProxy(),
- config.isResolveByProxy());
- }
- else
- {
- server =
- new IRCServer(host, port, plainPass, false, config.getProxy(),
- config.isResolveByProxy());
- }
+ final String plainPass = determinePlainPassword(password, config);
+ final IRCServer server =
+ createServer(config, host, port, secureConnection, plainPass);
try
{
@@ -212,6 +200,64 @@ public class IrcStack implements IrcConnectionListener
}
/**
+ * Create matching IRCServer instances based on connection parameters.
+ *
+ * @param config the IRC config
+ * @param host the IRC server host
+ * @param port the IRC server port
+ * @param secureConnection <tt>true</tt> for a secure connection,
+ * <tt>false</tt> for plain text connection
+ * @param password the normal IRC password (<tt>Note</tt> this is not the
+ * password used for SASL authentication. This password may be
+ * null in case SASL authentication is required.)
+ * @return Returns a server instance that matches the provided parameters.
+ */
+ private IRCServer createServer(final ClientConfig config,
+ final String host, final int port, final boolean secureConnection,
+ final String password)
+ {
+ final IRCServer server;
+ if (secureConnection)
+ {
+ server =
+ new SecureIRCServer(host, port, password,
+ getCustomSSLContext(host), config.getProxy(),
+ config.isResolveByProxy());
+ }
+ else
+ {
+ server =
+ new IRCServer(host, port, password, false, config.getProxy(),
+ config.isResolveByProxy());
+ }
+ return server;
+ }
+
+ /**
+ * Determine the correct plain IRC password for the provided IRC
+ * configuration.
+ *
+ * @param password the user-specified password
+ * @param config the IRC configuration, which includes possible SASL
+ * preferences
+ * @return Returns the IRC plain password to use in the connection,
+ * determined by the provided IRC configuration.
+ */
+ private String determinePlainPassword(final String password,
+ final ClientConfig config)
+ {
+ final String plainPass;
+ if (config.isVersion3Allowed() && config.getSASL() != null) {
+ plainPass = null;
+ }
+ else
+ {
+ plainPass = password;
+ }
+ return plainPass;
+ }
+
+ /**
* Check to see if a certificate exception is the root cause for the
* exception.
*
diff --git a/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderFactoryIrcImpl.java b/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderFactoryIrcImpl.java
index db0d2c2..96ae4c7 100644
--- a/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderFactoryIrcImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderFactoryIrcImpl.java
@@ -52,6 +52,13 @@ public class ProtocolProviderFactoryIrcImpl
public static final String SASL_ROLE = "SASL_ROLE";
/**
+ * Property for indicating that DNS names should be resolved through the
+ * SOCKS proxy if a proxy server is configured.
+ */
+ public static final String RESOLVE_DNS_THROUGH_PROXY =
+ "RESOLVE_DNS_THROUGH_PROXY";
+
+ /**
* Constructor.
*/
public ProtocolProviderFactoryIrcImpl()
diff --git a/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderServiceIrcImpl.java b/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderServiceIrcImpl.java
index bb4cefa..4d3a8c7 100644
--- a/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderServiceIrcImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderServiceIrcImpl.java
@@ -252,6 +252,9 @@ public class ProtocolProviderServiceIrcImpl
boolean autoNickChange =
accountID.getAccountPropertyBoolean(
ProtocolProviderFactory.AUTO_CHANGE_USER_NAME, true);
+ boolean resolveDnsThroughProxy =
+ accountID.getAccountPropertyBoolean(
+ ProtocolProviderFactoryIrcImpl.RESOLVE_DNS_THROUGH_PROXY, true);
boolean passwordRequired =
!accountID.getAccountPropertyBoolean(
ProtocolProviderFactory.NO_PASSWORD_REQUIRED, true);
@@ -315,12 +318,12 @@ public class ProtocolProviderServiceIrcImpl
// configure client options according to account properties
final ClientConfigImpl config = new ClientConfigImpl();
- // TODO makes allow-version-3 configurable in GUI
config.setVersion3Allowed(true);
config.setContactPresenceTaskEnabled(contactPresenceTask);
config.setChannelPresenceTaskEnabled(channelPresenceTask);
- config.setProxy(loadProxy());
- config.setResolveByProxy(loadDNSThroughProxySetting());
+ final Proxy proxy = loadProxy();
+ config.setProxy(proxy);
+ config.setResolveByProxy(resolveDnsThroughProxy);
if (saslEnabled)
{
final SASLImpl sasl =
@@ -392,26 +395,6 @@ public class ProtocolProviderServiceIrcImpl
}
/**
- * Method for loading the current value for option to resolve DNS host names
- * through SOCKS5 proxy.
- *
- * @return returns <tt>true</tt> to enable resolving through proxy, or
- * <tt>false</tt> for local DNS resolving
- */
- private boolean loadDNSThroughProxySetting()
- {
- final ConfigurationService configSvc =
- IrcActivator.getConfigurationService();
- if (configSvc == null)
- {
- // Assuming maximum use of configured proxy server is desirable.
- return true;
- }
- // FIXME implement support for option to enable SOCKS5 DNS resolving
- return true;
- }
-
- /**
* Makes the service implementation close all open sockets and release
* any resources that it might have taken and prepare for
* shutdown/garbage collection.