fix 2 more servlet RuntimeException in intranet mode thrown due to seed.getIP()

returning null in intranet mode (in servlets: ConfigSearchBox, Load_PHPBB3
+remove unused (const ∅) seed.IPTYPE
This commit is contained in:
reger 2016-05-29 20:35:57 +02:00
parent bb0076c3dd
commit f23d8ab47b
3 changed files with 3 additions and 6 deletions

View File

@ -34,7 +34,7 @@ public class ConfigSearchBox {
final serverObjects prop = new serverObjects();
final Switchboard sb = (Switchboard) env;
String myaddress = sb.peers.mySeed().getPublicAddress(sb.peers.mySeed().getIP());
String myaddress = sb.peers.mySeed().getIP() == null ? null : sb.peers.mySeed().getPublicAddress(sb.peers.mySeed().getIP());
if (myaddress == null) myaddress = "localhost:" + sb.getLocalPort();
prop.put("myaddress", myaddress);
return prop;

View File

@ -38,7 +38,7 @@ public class Load_PHPBB3 {
final serverObjects prop = new serverObjects();
// define visible variables
String a = sb.peers.mySeed().getPublicAddress(sb.peers.mySeed().getIP());
String a = sb.peers.mySeed().getIP() == null ? null : sb.peers.mySeed().getPublicAddress(sb.peers.mySeed().getIP());
if (a == null) a = "localhost:" + sb.getLocalPort();
final boolean intranet = sb.getConfig(SwitchboardConstants.NETWORK_NAME, "").equals("intranet");
final String repository = "http://" + a + "/repository/";

View File

@ -133,8 +133,6 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>
*/
public static final String PEERTYPE = "PeerType";
/** static/dynamic (if the IP changes often for any reason) */
private static final String IPTYPE = "IPType";
private static final String FLAGS = "Flags";
public static final String FLAGSZERO = " ";
@ -262,7 +260,6 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>
// settings that is created during the 'hello' phase - in first contact
this.dna.put(Seed.IP, ""); // 123.234.345.456
this.dna.put(Seed.PORT, "&empty;");
this.dna.put(Seed.IPTYPE, "&empty;");
// settings that can only be computed by visiting peer
this.dna.put(Seed.USPEED, Seed.ZERO); // the computated uplink speed of the peer
@ -758,7 +755,7 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>
* @return an address string which can be used as host:port part of an url (if no port avail returns just host)
*/
public final String getPublicAddress(final String ip) {
if (ip == null) throw new RuntimeException("ip == NULL"); // that should not happen
if (ip == null) throw new RuntimeException("ip == NULL"); // that should not happen in Peer-to-Peer mode (but can in Intranet mode)
final String port = this.dna.get(Seed.PORT); // we do not use getPort() here to avoid String->Integer->toString() conversion
final StringBuilder sb = new StringBuilder(ip.length() + 8); // / = surplus for port
if (ip.indexOf(':') >= 0) {