catch ip-format exception on wrong server access setting ip filter

as reported in http://mantis.tokeek.de/view.php?id=713
to prevent abort of initialization.
This jetty/whitelist ipaccesshandler accepts currently only ipv4
This commit is contained in:
reger 2016-12-11 04:43:36 +01:00
parent b32bcdf344
commit 3151cda3a5

View File

@ -205,12 +205,16 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {
int i=0;
while (st.hasMoreTokens()) {
String ip = st.nextToken();
iphandler.addWhite(ip);
try {
iphandler.addWhite(ip); // accepts only ipv4
} catch (IllegalArgumentException nex) { // catch number format exception on non ipv4 input
ConcurrentLog.severe("SERVER", "Server Access Settings - IP filter: " + nex.getMessage());
continue;
}
i++;
}
if (i > 0) {
iphandler.addWhite("127.0.0.1"); // allow localhost (loopback addr)
iphandler.setServer(server);
iphandler.setHandler(crashHandler);
server.setHandler(iphandler);
ConcurrentLog.info("SERVER","activated IP access restriction to: [127.0.0.1," + white +"] (this works only correct with start parameter -Djava.net.preferIPv4Stack=true)");