Author: bombe
Date: 2006-07-03 18:20:59 +0000 (Mon, 03 Jul 2006)
New Revision: 9441
Modified:
trunk/freenet/src/freenet/io/NetworkInterface.java
Log:
ignore all non-ip addresses (except for "*") in *.allowedHosts
Modified: trunk/freenet/src/freenet/io/NetworkInterface.java
===================================================================
--- trunk/freenet/src/freenet/io/NetworkInterface.java 2006-07-03 17:10:50 UTC
(rev 9440)
+++ trunk/freenet/src/freenet/io/NetworkInterface.java 2006-07-03 18:20:59 UTC
(rev 9441)
@@ -103,7 +103,6 @@
Map newAddressMatchers = new HashMap();
while (allowedHostsTokens.hasMoreTokens()) {
String allowedHost =
allowedHostsTokens.nextToken().trim();
- newAllowedHosts.add(allowedHost);
String hostname = allowedHost;
if (allowedHost.indexOf('/') != -1) {
hostname = allowedHost.substring(0,
allowedHost.indexOf('/'));
@@ -111,8 +110,14 @@
AddressType addressType =
AddressIdentifier.getAddressType(hostname);
if (addressType == AddressType.IPv4) {
newAddressMatchers.put(allowedHost, new
Inet4AddressMatcher(allowedHost));
+ newAllowedHosts.add(allowedHost);
} else if (addressType == AddressType.IPv6) {
newAddressMatchers.put(allowedHost, new
Inet6AddressMatcher(allowedHost));
+ newAllowedHosts.add(allowedHost);
+ } else if (allowedHost.equals("*")) {
+ newAllowedHosts.add(allowedHost);
+ } else {
+ Logger.normal(NetworkInterface.class, "Ignoring
invalid allowedHost: " + allowedHost);
}
}
synchronized (syncObject) {
@@ -260,7 +265,6 @@
Socket clientSocket =
serverSocket.accept();
InetAddress clientAddress =
clientSocket.getInetAddress();
Logger.minor(Acceptor.class,
"Connection from " + clientAddress);
- String clientHostName =
clientAddress.getHostName();
/* check if the ip address is allowed */
boolean addressMatched = false;
@@ -272,7 +276,7 @@
if (matcher != null) {
addressMatched
= matcher.matches(clientAddress);
} else {
- addressMatched
= "*".equals(host) || clientHostName.equalsIgnoreCase(host);
+ addressMatched
= "*".equals(host);
}
}
}
@@ -287,7 +291,7 @@
clientSocket.close();
} catch (IOException ioe1) {
}
- Logger.normal(Acceptor.class,
"Denied connection to " + clientHostName);
+ Logger.normal(Acceptor.class,
"Denied connection to " + clientAddress);
}
} catch (SocketTimeoutException ste1) {
Logger.minor(this, "Timeout");