aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java
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
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')
-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
-rw-r--r--src/net/java/sip/communicator/plugin/ircaccregwizz/FirstWizardPage.java25
-rw-r--r--src/net/java/sip/communicator/plugin/ircaccregwizz/IrcAccountRegistration.java58
-rw-r--r--src/net/java/sip/communicator/plugin/ircaccregwizz/IrcAccountRegistrationWizard.java24
6 files changed, 171 insertions, 48 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.
diff --git a/src/net/java/sip/communicator/plugin/ircaccregwizz/FirstWizardPage.java b/src/net/java/sip/communicator/plugin/ircaccregwizz/FirstWizardPage.java
index cdaf60f..18ede51 100644
--- a/src/net/java/sip/communicator/plugin/ircaccregwizz/FirstWizardPage.java
+++ b/src/net/java/sip/communicator/plugin/ircaccregwizz/FirstWizardPage.java
@@ -114,6 +114,9 @@ public class FirstWizardPage
= new SIPCommCheckBox(
Resources.getString("plugin.ircaccregwizz.AUTO_NICK_CHANGE"));
+ private JCheckBox resolveDnsThroughProxy = new SIPCommCheckBox(
+ Resources.getString("plugin.ircaccregwizz.RESOLVE_DNS_THROUGH_PROXY"));
+
private JCheckBox defaultPort = new SIPCommCheckBox(
Resources.getString("plugin.ircaccregwizz.USE_DEFAULT_PORT"));
@@ -182,6 +185,7 @@ public class FirstWizardPage
this.portField.setEnabled(false);
this.rememberPassBox.setEnabled(false);
this.useSecureConnection.setEnabled(true);
+ this.resolveDnsThroughProxy.setEnabled(true);
}
/**
@@ -208,6 +212,7 @@ public class FirstWizardPage
this.passField.setEnabled(false);
this.rememberPassBox.setSelected(true);
this.autoNickChange.setSelected(true);
+ this.resolveDnsThroughProxy.setSelected(true);
this.defaultPort.setSelected(true);
this.passwordNotRequired.setSelected(true);
this.useSecureConnection.setSelected(true);
@@ -267,10 +272,14 @@ public class FirstWizardPage
serverPanel.setBorder(BorderFactory.createTitledBorder(
Resources.getString("plugin.ircaccregwizz.IRC_SERVER")));
- optionsPanel.add(rememberPassBox, BorderLayout.NORTH);
- optionsPanel.add(autoNickChange, BorderLayout.CENTER);
- JPanel partition = new TransparentPanel();
- optionsPanel.add(partition);
+ final JPanel optionsSubPanel = new TransparentPanel();
+ optionsSubPanel.setLayout(new BoxLayout(optionsSubPanel, BoxLayout.Y_AXIS));
+ optionsPanel.add(optionsSubPanel, BorderLayout.WEST);
+ optionsSubPanel.add(rememberPassBox);
+ optionsSubPanel.add(autoNickChange);
+ final JPanel partition = new TransparentPanel();
+ optionsSubPanel.add(resolveDnsThroughProxy);
+ optionsPanel.add(partition, BorderLayout.SOUTH);
partition.setLayout(new BorderLayout());
partition.add(enableContactPresenceTask, BorderLayout.WEST);
partition.add(enableChatRoomPresenceTask, BorderLayout.EAST);
@@ -404,6 +413,8 @@ public class FirstWizardPage
&& this.saslEnabled.isSelected());
registration.setSaslUser(this.saslUserIdField.getText());
registration.setSaslRole(this.saslRoleField.getText());
+ registration.setResolveDnsThroughProxy(this.resolveDnsThroughProxy
+ .isSelected());
isCommitted = true;
}
@@ -507,6 +518,10 @@ public class FirstWizardPage
accountID.getAccountPropertyBoolean(
ProtocolProviderFactory.DEFAULT_ENCRYPTION, true);
+ boolean resolveDnsThroughProxy =
+ accountID.getAccountPropertyBoolean(
+ IrcAccountRegistrationWizard.RESOLVE_DNS_THROUGH_PROXY, true);
+
boolean contactPresenceTaskEnabled =
accountID.getAccountPropertyBoolean(
IrcAccountRegistrationWizard.CONTACT_PRESENCE_TASK, true);
@@ -552,6 +567,8 @@ public class FirstWizardPage
new Boolean(autoNickChange).booleanValue());
}
+ this.resolveDnsThroughProxy.setSelected(resolveDnsThroughProxy);
+
if (noPasswordRequired != null)
{
boolean isPassRequired = !Boolean.valueOf(noPasswordRequired);
diff --git a/src/net/java/sip/communicator/plugin/ircaccregwizz/IrcAccountRegistration.java b/src/net/java/sip/communicator/plugin/ircaccregwizz/IrcAccountRegistration.java
index 08a71fd..435157a 100644
--- a/src/net/java/sip/communicator/plugin/ircaccregwizz/IrcAccountRegistration.java
+++ b/src/net/java/sip/communicator/plugin/ircaccregwizz/IrcAccountRegistration.java
@@ -26,6 +26,7 @@ public class IrcAccountRegistration
private boolean saslEnabled;
private String saslUser;
private String saslRole;
+ private boolean resolveDnsThroughProxy;
/**
* Option for activating contact presence task.
@@ -186,7 +187,7 @@ public class IrcAccountRegistration
/**
* Indicates if the the connection must be secure or not.
- *
+ *
* @return returns <code>true</code> to indicate that the connection should
* be secure, or false for unsecured connection.
*/
@@ -197,7 +198,7 @@ public class IrcAccountRegistration
/**
* Set the <tt>useSecureConnection</tt> property.
- *
+ *
* @param secureConnection true to require secure connection, or false
* for unsecured connections
*/
@@ -246,33 +247,86 @@ public class IrcAccountRegistration
this.chatroomPresenceTaskEnabled = value;
}
+ /**
+ * Get SASL enable status.
+ *
+ * @return Returns <tt>true</tt> if SASL is enabled, or <tt>false</tt> if
+ * SASL is disabled.
+ */
public boolean isSaslEnabled()
{
return this.saslEnabled;
}
+ /**
+ * Set SASL enabled.
+ *
+ * @param enabled <tt>true</tt> to enable SASL, <tt>false</tt> to disable
+ */
public void setSaslEnabled(final boolean enabled)
{
this.saslEnabled = enabled;
}
+ /**
+ * Get SASL user name.
+ *
+ * @return Returns SASL user name.
+ */
public String getSaslUser()
{
return this.saslUser;
}
+ /**
+ * Set SASL user name. (Mandatory)
+ *
+ * @param user SASL user name
+ */
public void setSaslUser(final String user)
{
this.saslUser = user;
}
+ /**
+ * Get SASL authorization role. (Optional)
+ *
+ * @return Returns the SASL authorization role if configured, of
+ * <tt>null</tt> if no role known.
+ */
public String getSaslRole()
{
return this.saslRole;
}
+ /**
+ * Set SASL authorization role.
+ *
+ * @param role the SASL authorization role
+ */
public void setSaslRole(final String role)
{
this.saslRole = role;
}
+
+ /**
+ * Get property for resolving DNS names through configured proxy server.
+ * <tt>true</tt> to resolve DNS names through configured proxy server, or
+ * <tt>false</tt> to resolve using own DNS server.
+ */
+ public boolean isResolveDnsThroughProxy()
+ {
+ return this.resolveDnsThroughProxy;
+ }
+
+ /**
+ * Set property for resolving DNS through configured proxy server.
+ *
+ * @param value <tt>true</tt> to enable resolving through proxy server, or
+ * <tt>false</tt> to resolve via local DNS server
+ */
+ public void setResolveDnsThroughProxy(final boolean value)
+ {
+ this.resolveDnsThroughProxy = value;
+ }
}
diff --git a/src/net/java/sip/communicator/plugin/ircaccregwizz/IrcAccountRegistrationWizard.java b/src/net/java/sip/communicator/plugin/ircaccregwizz/IrcAccountRegistrationWizard.java
index 7f26e69..a1c71ff 100644
--- a/src/net/java/sip/communicator/plugin/ircaccregwizz/IrcAccountRegistrationWizard.java
+++ b/src/net/java/sip/communicator/plugin/ircaccregwizz/IrcAccountRegistrationWizard.java
@@ -61,7 +61,16 @@ public class IrcAccountRegistrationWizard
* Property for SASL authorization role.
*/
public static final String SASL_ROLE = "SASL_ROLE";
-
+
+ /**
+ * Property for resolving DNS names through configured proxy server.
+ */
+ public static final String RESOLVE_DNS_THROUGH_PROXY =
+ "RESOLVE_DNS_THROUGH_PROXY";
+
+ /**
+ * Logger.
+ */
private final Logger logger
= Logger.getLogger(IrcAccountRegistrationWizard.class);
@@ -198,6 +207,9 @@ public class IrcAccountRegistrationWizard
summaryTable.put(
Resources.getString("plugin.ircaccregwizz.USE_SECURE_CONNECTION"),
registration.isSecureConnection() ? yes : no);
+ summaryTable.put(Resources
+ .getString("plugin.ircaccregwizz.RESOLVE_DNS_THROUGH_PROXY"),
+ registration.isResolveDnsThroughProxy() ? yes : no);
summaryTable
.put(Resources
.getString("plugin.ircaccregwizz.ENABLE_CONTACT_PRESENCE"),
@@ -294,14 +306,18 @@ public class IrcAccountRegistrationWizard
accountProperties.put(
ProtocolProviderFactory.AUTO_CHANGE_USER_NAME,
- new Boolean(registration.isAutoChangeNick()).toString());
+ Boolean.toString(registration.isAutoChangeNick()));
+
+ accountProperties.put(
+ IrcAccountRegistrationWizard.RESOLVE_DNS_THROUGH_PROXY,
+ Boolean.toString(registration.isResolveDnsThroughProxy()));
accountProperties.put(
ProtocolProviderFactory.NO_PASSWORD_REQUIRED,
- new Boolean(!registration.isRequiredPassword()).toString());
+ Boolean.toString(!registration.isRequiredPassword()));
accountProperties.put(ProtocolProviderFactory.DEFAULT_ENCRYPTION,
- new Boolean(registration.isSecureConnection()).toString());
+ Boolean.toString(registration.isSecureConnection()).toString());
// Presence-based background tasks
accountProperties.put(CONTACT_PRESENCE_TASK,