summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorAlex Clayton <alex.clayton@isode.com>2013-11-08 10:06:08 (GMT)
committerKevin Smith <git@kismith.co.uk>2013-11-09 23:15:51 (GMT)
commit82a909b9ff8af20bc5674b3e544dfd81330354d4 (patch)
treebf6f9656840521f2865f82b329be2ba69ee64ae3 /src/com
parent14a773c38050d4af9c34c24e426b7a5460ad9735 (diff)
downloadstroke-82a909b9ff8af20bc5674b3e544dfd81330354d4.zip
stroke-82a909b9ff8af20bc5674b3e544dfd81330354d4.tar.bz2
Allow /etc/hosts to override DNS host lookups
A recent change made Stroke use the dnsjava library instead of JNDI for domain service queries, because JNDI had problems with IPv6 addresses. The change also replaced the use of Java's standard InetAddress class for name resolution with the Address class inside dnsjava - this change was not neccessary, and is problematic because although the documentation for "Address" says that it "Includes functions similar to those in the java.net.InetAddress class", it does not provide equivalent functionality. Specifically, whereas InetAddress.getAllByName() will use the local system's "host" file when attempting to resolve hostnames, the corresponding Address.getAllByName() method in dnsjava does not do this. This means that if a user inserts values into /etc/hosts, they will be ignored by the Address.getAllByName(). As a result, users who had expected stroke to honour values in /etc/hosts (which is something you might want to do just for testing purposes) will be surprised when it stops doing this. So this patch reverts the code in question to use InetAddress instead of dnsjava's Address class. Test Information I added the following lines to my /etc/hosts file. 127.0.0.1 alexmac.com 127.0.0.1 alexmac.clayton.com At time of the testing there already existed an external domain with name alexmac.com but none corresponding to alexmac.clayton.com. I then ran the 'Check DNS for a domain...' dialog in the MLC Help Menu. Before the patch this would give me the the details for the external domain for 'alexmac.com' and say no DNS could be found for 'alexmac.clayton.com'. After the patch the correct details (i.e 127.0.0.1) were returned for both domains. Also, before the patch I could not connect to the local xmpp server 'alexmac.com'. After the patch I connected correctly. Change-Id: If7f15b8aa98313278a1892eb27a5f73aaea8802b
Diffstat (limited to 'src/com')
-rw-r--r--src/com/isode/stroke/network/PlatformDomainNameResolver.java9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/com/isode/stroke/network/PlatformDomainNameResolver.java b/src/com/isode/stroke/network/PlatformDomainNameResolver.java
index 32f466d..0b87e65 100644
--- a/src/com/isode/stroke/network/PlatformDomainNameResolver.java
+++ b/src/com/isode/stroke/network/PlatformDomainNameResolver.java
@@ -8,15 +8,14 @@
*/
package com.isode.stroke.network;
-import com.isode.stroke.eventloop.Event.Callback;
-import com.isode.stroke.eventloop.EventLoop;
-import com.isode.stroke.eventloop.EventOwner;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collection;
-import org.xbill.DNS.Address;
+import com.isode.stroke.eventloop.Event.Callback;
+import com.isode.stroke.eventloop.EventLoop;
+import com.isode.stroke.eventloop.EventOwner;
public class PlatformDomainNameResolver extends DomainNameResolver {
@@ -27,7 +26,7 @@ public class PlatformDomainNameResolver extends DomainNameResolver {
public void run() {
final Collection<HostAddress> results = new ArrayList<HostAddress>();
try {
- for (InetAddress result : Address.getAllByName(hostname)) {
+ for (InetAddress result : InetAddress.getAllByName(hostname)) {
results.add(new HostAddress(result));
}
} catch (UnknownHostException ex) {