Norman,
this is v2.3, a branch in RC state!!
bugfixes should be applied to trunk and *then* we should discuss wether
to backport to v2.3, IMHO.
Then you used tabs instead of spaces, but this is another issue ;-)
About the issue and the patch, looking at the code it seems that it
should have already worked, so probably if we have a bug it is related
to DNS and not to fetchmail. In the current fetchmail code there are
almost 30 lines of code to manage the -1 scenario, so it seems a bit
weird to simply add a couple of lines to avoid their execution.
Maybe Steve can help understanding what's going on...
Have you debugged the problem? Where exactly the unkownhost happens?
----
protected String computeRemoteAddress()
throws MessagingException, UnknownHostException
{
String domain = getRemoteDomain();
String address = null;
String validatedAddress = null;
int ipAddressStart = domain.indexOf('[');
int ipAddressEnd = -1;
if (ipAddressStart > -1)
ipAddressEnd = domain.indexOf(']', ipAddressStart);
if (ipAddressEnd > -1)
address = domain.substring(ipAddressStart + 1, ipAddressEnd);
else
{
int hostNameEnd = domain.indexOf(' ');
if (hostNameEnd == -1)
hostNameEnd = domain.length();
address = domain.substring(0, hostNameEnd);
}
validatedAddress =
org.apache.james.dnsserver.DNSServer.getByName(address).getHostAddress();
return validatedAddress;
}
-----
getRemoteDomain returns what computeRemoteDomain calculated and when the
getRemoteReceivedHeaderIndex is -1 it does this:
-----
// If a domain was not found, the default is the local host and
// if we cannot resolve this, the local address 127.0.0.1
// Note that earlier versions of this code simply used 'localhost'
// which works fine with java.net but is not resolved by dnsjava
// which was introduced in v2.2.0. See Jira issue JAMES-302.
if (domainBuffer.length() == 0)
{
try
{
InetAddress addr1 = java.net.InetAddress.getLocalHost();
// These shenanigans are required to get the fully qualified
// hostname prior to JDK 1.4 in which getCanonicalHostName()
// does the job for us
InetAddress addr2 =
java.net.InetAddress.getByName(addr1.getHostAddress());
InetAddress addr3 =
java.net.InetAddress.getByName(addr2.getHostName());
domainBuffer.append(addr3.getHostName());
}
catch (UnknownHostException ue)
{
domainBuffer.append("[127.0.0.1]");
}
}
return domainBuffer.toString().trim();
-----
Thank you,
Stefano
[EMAIL PROTECTED] ha scritto:
Author: norman
Date: Wed Apr 18 01:39:43 2007
New Revision: 529916
URL: http://svn.apache.org/viewvc?view=rev&rev=529916
Log:
Fix use of index=-1 im Fetchmail. See JAMES-787
Modified:
james/server/branches/v2.3/src/java/org/apache/james/fetchmail/MessageProcessor.java
Modified:
james/server/branches/v2.3/src/java/org/apache/james/fetchmail/MessageProcessor.java
URL:
http://svn.apache.org/viewvc/james/server/branches/v2.3/src/java/org/apache/james/fetchmail/MessageProcessor.java?view=diff&rev=529916&r1=529915&r2=529916
==============================================================================
---
james/server/branches/v2.3/src/java/org/apache/james/fetchmail/MessageProcessor.java
(original)
+++
james/server/branches/v2.3/src/java/org/apache/james/fetchmail/MessageProcessor.java
Wed Apr 18 01:39:43 2007
@@ -1500,6 +1500,9 @@
protected String getRemoteAddress()
throws MessagingException, UnknownHostException
{
+ // No need for parsing the header for the remoteipaddress. Just return
127.0.0.1
+ if (getRemoteReceivedHeaderIndex() == -1) return "127.0.0.1";
+
String remoteAddress;
if (null == (remoteAddress = getRemoteAddressBasic()))
{
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]