diff --git a/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHelper.java index 0814df38e..2c90b805c 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHelper.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHelper.java @@ -5,6 +5,7 @@ import net.i2p.router.CommSystemFacade; import net.i2p.router.LoadTestManager; import net.i2p.router.Router; import net.i2p.router.RouterContext; +import net.i2p.router.transport.Addresses; import net.i2p.router.transport.TransportManager; import net.i2p.router.transport.udp.UDPAddress; import net.i2p.router.transport.udp.UDPTransport; @@ -20,6 +21,13 @@ public class ConfigNetHelper extends HelperBase { public final static String PROP_I2NP_NTCP_AUTO_IP = "i2np.ntcp.autoip"; private final static String CHECKED = " checked=\"true\" "; private final static String DISABLED = " disabled=\"true\" "; + + public String getUdphostname() { + String hostname = _context.getProperty(UDPTransport.PROP_EXTERNAL_HOST); + if (hostname == null) return ""; + return hostname; + } + public String getNtcphostname() { if (!TransportManager.enableNTCP(_context)) return "\" disabled=\"true"; @@ -116,6 +124,18 @@ public class ConfigNetHelper extends HelperBase { return ""; } +//////////////// FIXME + public String getUdpAutoIPChecked(int mode) { + String hostname = _context.getProperty(PROP_I2NP_NTCP_HOSTNAME); + boolean specified = hostname != null && hostname.length() > 0; + boolean auto = Boolean.valueOf(_context.getProperty(PROP_I2NP_NTCP_AUTO_IP)).booleanValue(); + if ((mode == 0 && (!specified) && !auto) || + (mode == 1 && specified && !auto) || + (mode == 2 && auto)) + return CHECKED; + return ""; + } + public String getUpnpChecked() { return getChecked(TransportManager.PROP_ENABLE_UPNP); } @@ -133,6 +153,10 @@ public class ConfigNetHelper extends HelperBase { } } + public String[] getAddresses() { + return Addresses.getAddresses(); + } + public String getInboundRate() { return "" + _context.bandwidthLimiter().getInboundKBytesPerSecond(); } diff --git a/apps/routerconsole/jsp/config.jsp b/apps/routerconsole/jsp/config.jsp index 4bcf6880c..10232ec73 100644 --- a/apps/routerconsole/jsp/config.jsp +++ b/apps/routerconsole/jsp/config.jsp @@ -68,17 +68,46 @@
If you can, please poke a hole in your NAT or firewall to allow unsolicited UDP packets to reach you on your external UDP address. If you can't, I2P now includes supports UDP hole punching with "SSU introductions" - peers who will relay a request from someone you don't know to your router for your router so that you can make an outbound connection to them. I2P will use these introductions automatically if it detects that the port is not forwarded (as shown by - the Status: Firewalled line), or you can manually require them here. + the Reachability: Firewalled line), or you can manually require them here. Users behind symmetric NATs, such as OpenBSD's pf, are not currently supported.
@@ -88,18 +117,18 @@
Disable
/>
Use IP address detected by SSU
- (currently
+ (currently
/>
Specify hostname or IP:
" />
- (dyndns and the like are fine)
+ (dyndns and the like are fine)
Externally reachable TCP port:
/>
Disable
/>
Use the same port configured for SSU
- (currently
+ (currently
/>
Specify Port:
" />
diff --git a/router/java/src/net/i2p/router/transport/Addresses.java b/router/java/src/net/i2p/router/transport/Addresses.java
new file mode 100644
index 000000000..cd82a9086
--- /dev/null
+++ b/router/java/src/net/i2p/router/transport/Addresses.java
@@ -0,0 +1,80 @@
+package net.i2p.router.transport;
+
+/*
+ * public domain
+ */
+
+import java.net.InetAddress;
+import java.net.Inet4Address;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.net.UnknownHostException;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Set;
+
+
+/**
+ * Get the local addresses
+ *
+ * @author zzz
+ */
+public class Addresses {
+
+ /** return the first non-local address it finds, or null */
+ public static String getAnyAddress() {
+ String[] a = getAddresses();
+ if (a.length > 0)
+ return a[0];
+ return null;
+ }
+
+ /**
+ * Return an array of all addresses, excluding
+ * IPv6, local, broadcast, multicast, etc.
+ */
+ public static String[] getAddresses() {
+ Set