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
pull/97/head
reger 8 years ago
parent b32bcdf344
commit 3151cda3a5

@ -205,12 +205,16 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer {
int i=0; int i=0;
while (st.hasMoreTokens()) { while (st.hasMoreTokens()) {
String ip = st.nextToken(); 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++; i++;
} }
if (i > 0) { if (i > 0) {
iphandler.addWhite("127.0.0.1"); // allow localhost (loopback addr) iphandler.addWhite("127.0.0.1"); // allow localhost (loopback addr)
iphandler.setServer(server);
iphandler.setHandler(crashHandler); iphandler.setHandler(crashHandler);
server.setHandler(iphandler); 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)"); ConcurrentLog.info("SERVER","activated IP access restriction to: [127.0.0.1," + white +"] (this works only correct with start parameter -Djava.net.preferIPv4Stack=true)");

Loading…
Cancel
Save