fix NPE in Load_MediawikiWiki servlet in intranet mode

- in intranet mode getip returns null causing a NPE
  - adjust starturl (which was set to http://localip/repository) which is never the start url for the Mediawiki
+ correct javadoc for seed.getIP()
pull/56/head
reger 9 years ago
parent bfd4e5f9e5
commit 6384b7d82e

@ -26,7 +26,6 @@
import net.yacy.cora.protocol.RequestHeader; import net.yacy.cora.protocol.RequestHeader;
import net.yacy.search.Switchboard; import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants;
import net.yacy.server.serverObjects; import net.yacy.server.serverObjects;
import net.yacy.server.serverSwitch; import net.yacy.server.serverSwitch;
@ -38,11 +37,13 @@ public class Load_MediawikiWiki {
final serverObjects prop = new serverObjects(); final serverObjects prop = new serverObjects();
// define visible variables // define visible variables
String a = sb.peers.mySeed().getPublicAddress(sb.peers.mySeed().getIP()); String a;
if (a == null) a = "localhost:" + sb.getLocalPort(); if (sb.peers.myIPs().isEmpty()) {
final boolean intranet = sb.getConfig(SwitchboardConstants.NETWORK_NAME, "").equals("intranet"); a = "localhost:" + sb.getLocalPort();
final String repository = "http://" + a + "/repository/"; } else {
prop.put("starturl", (intranet) ? repository : "http://"); a = sb.peers.mySeed().getPublicAddress(sb.peers.mySeed().getIP());
}
prop.put("starturl", "http://");
prop.put("address", a); prop.put("address", a);
// return rewrite properties // return rewrite properties

@ -344,7 +344,7 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>
/** /**
* try to get the public IP<br> * try to get the public IP<br>
* *
* @return the IP or localhost IP (127.0.0.1) * @return the public IP or null
*/ */
@Deprecated @Deprecated
public final String getIP() { public final String getIP() {

Loading…
Cancel
Save