I'm not a contributor to James, but I thought someone might be interested in
a little mod I made to James.
I made it so that one can hard wire a domain to a hostname or IP.  This was
needed in our LAN.

I implemented it as a subclass, but it would be simpler to modify
DNSServer.java directly if this were added to James permanently.

Config.xml file fragment:

  <dnsserver>
        <servers>
          <server>196.3.2.4</server>
          <server>196.3.2.195</server>
        </servers>
        <hosts>  <!-- HERE IS WHERE I CAN HARD WIRE DOMAINS -->
          <host name="myplace.net">10.10.254.63</host>
        </hosts>
        <authoritative>false</authoritative>
  </dnsserver>

import java.util.*;
import org.apache.james.dnsserver.*;
import org.apache.james.services.*;
import org.apache.avalon.framework.configuration.*;

/**
 * This subclass of DNSServer is specifically designed to take
 * into account the fact that our domain doesn't work from within the LAN.
 *
 **/
public class HardDnsServer extends org.apache.james.dnsserver.DNSServer
{
  HashMap mappings = new HashMap();

  public void configure( final Configuration configuration )
    throws ConfigurationException
  {
    super.configure( configuration );
    
    // Get this servers that this block will use for lookups
    Configuration hostsConfiguration = configuration.getChild( "hosts" );
    Configuration[] hostConfigurations =
      hostsConfiguration.getChildren( "host" );

    for ( int i = 0; i < hostConfigurations.length; i++ )
    {
      Configuration hostConfiguration = hostConfigurations[i];

      mappings.put( hostConfiguration.getAttribute("name").toLowerCase(),
        hostConfiguration.getValue());
    }
  }

  public Collection findMXRecords(String hostname)
  {
    Collection result;
    String mappedHost = (String)mappings.get(hostname.toLowerCase());
    if( mappedHost == null )
    {
      result = super.findMXRecords(hostname);
    }
    else
    {
      result = new ArrayList(1);
      result.add(mappedHost);
    }
    return result;
  }
}

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to