From 1c8300fcecab22b52caf2c87b7e005656c38d0e1 Mon Sep 17 00:00:00 2001 From: theli Date: Mon, 4 Sep 2006 11:23:57 +0000 Subject: [PATCH] *) Bugfix for name resolution in proxy mode See: http://www.yacy-forum.de/viewtopic.php?p=25241 git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2477 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/de/anomic/http/httpc.java | 19 ++++++++++--------- .../de/anomic/plasma/plasmaCrawlStacker.java | 13 ++++++++----- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/source/de/anomic/http/httpc.java b/source/de/anomic/http/httpc.java index 02a80e4cd..ee37ab02e 100644 --- a/source/de/anomic/http/httpc.java +++ b/source/de/anomic/http/httpc.java @@ -622,21 +622,22 @@ public final class httpc { this.adressed_host = server; this.adressed_port = port; this.target_virtual_host = vhost; - InetAddress hostip; -// if ((server.equals("localhost")) || (server.equals("127.0.0.1")) || (server.startsWith("192.168.")) || (server.startsWith("10."))) { -// hostip = server; -// } else { - hostip = dnsResolve(server); - if (hostip == null) throw new UnknownHostException(server); -// } - + // creating a socket this.socket = (ssl) ? theSSLSockFactory.createSocket() : new Socket(); // creating a socket address - InetSocketAddress address = new InetSocketAddress(hostip, port); + InetSocketAddress address = null; + if (!this.remoteProxyUse) { + // only try to resolve the address if we are not using a proxy + InetAddress hostip = dnsResolve(server); + if (hostip == null) throw new UnknownHostException(server); + address = new InetSocketAddress(hostip, port); + } else { + address = new InetSocketAddress(server,port); + } // trying to establish a connection to the address this.socket.connect(address,timeout); diff --git a/source/de/anomic/plasma/plasmaCrawlStacker.java b/source/de/anomic/plasma/plasmaCrawlStacker.java index 42fef71d8..64cc22145 100644 --- a/source/de/anomic/plasma/plasmaCrawlStacker.java +++ b/source/de/anomic/plasma/plasmaCrawlStacker.java @@ -285,13 +285,16 @@ public final class plasmaCrawlStacker { } // check if ip is local ip address - checkInterruption(); + checkInterruption(); InetAddress hostAddress = httpc.dnsResolve(nexturl.getHost()); if (hostAddress == null) { - reason = plasmaCrawlEURL.DENIED_UNKNOWN_HOST; - this.log.logFine("Unknown host in URL '" + nexturlString + "'. " + - "Stack processing time: " + (System.currentTimeMillis()-startTime) + "ms"); - return reason; + // if a http proxy is configured name resolution may not work + if (this.sb.remoteProxyConfig == null || !this.sb.remoteProxyConfig.useProxy()) { + reason = plasmaCrawlEURL.DENIED_UNKNOWN_HOST; + this.log.logFine("Unknown host in URL '" + nexturlString + "'. " + + "Stack processing time: " + (System.currentTimeMillis()-startTime) + "ms"); + return reason; + } } else if (hostAddress.isSiteLocalAddress()) { reason = plasmaCrawlEURL.DENIED_PRIVATE_IP_ADDRESS; this.log.logFine("Host in URL '" + nexturlString + "' has private IP address. " +