forked from I2P_Developers/i2p.i2p
* Addresses: Reject numeric IPs of the form n, n.n, and n.n.n
* Console, i2ptunnel: More validation of address and port in forms
This commit is contained in:
@@ -32,6 +32,7 @@ import net.i2p.i2ptunnel.I2PTunnelHTTPClientBase;
|
||||
import net.i2p.i2ptunnel.I2PTunnelIRCClient;
|
||||
import net.i2p.i2ptunnel.TunnelController;
|
||||
import net.i2p.i2ptunnel.TunnelControllerGroup;
|
||||
import net.i2p.util.Addresses;
|
||||
import net.i2p.util.ConcurrentHashSet;
|
||||
import net.i2p.util.FileUtil;
|
||||
import net.i2p.util.Log;
|
||||
@@ -436,6 +437,9 @@ public class IndexBean {
|
||||
return _("New Tunnel");
|
||||
}
|
||||
|
||||
/**
|
||||
* No validation
|
||||
*/
|
||||
public String getClientPort(int tunnel) {
|
||||
TunnelController tun = getController(tunnel);
|
||||
if (tun != null && tun.getListenPort() != null)
|
||||
@@ -444,6 +448,23 @@ public class IndexBean {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns error message if blank or invalid
|
||||
* @since 0.9.3
|
||||
*/
|
||||
public String getClientPort2(int tunnel) {
|
||||
TunnelController tun = getController(tunnel);
|
||||
if (tun != null && tun.getListenPort() != null) {
|
||||
String port = tun.getListenPort();
|
||||
if (port.length() == 0)
|
||||
return "<font color=\"red\">" + _("Port not set") + "</font>";
|
||||
if (Addresses.getPort(port) == 0)
|
||||
return "<font color=\"red\">" + _("Invalid port") + ' ' + port + "</font>";
|
||||
return port;
|
||||
}
|
||||
return "<font color=\"red\">" + _("Port not set") + "</font>";
|
||||
}
|
||||
|
||||
public String getTunnelType(int tunnel) {
|
||||
TunnelController tun = getController(tunnel);
|
||||
if (tun != null)
|
||||
@@ -551,12 +572,16 @@ public class IndexBean {
|
||||
else
|
||||
host = tun.getTargetHost();
|
||||
String port = tun.getTargetPort();
|
||||
if (host == null)
|
||||
if (host == null || host.length() == 0)
|
||||
host = "<font color=\"red\">" + _("Host not set") + "</font>";
|
||||
else if (Addresses.getIP(host) == null)
|
||||
host = "<font color=\"red\">" + _("Invalid address") + ' ' + host + "</font>";
|
||||
else if (host.indexOf(':') >= 0)
|
||||
host = '[' + host + ']';
|
||||
if (port == null)
|
||||
if (port == null || port.length() == 0)
|
||||
port = "<font color=\"red\">" + _("Port not set") + "</font>";
|
||||
else if (Addresses.getPort(port) == 0)
|
||||
port = "<font color=\"red\">" + _("Invalid port") + ' ' + port + "</font>";
|
||||
return host + ':' + port;
|
||||
} else
|
||||
return "";
|
||||
|
Reference in New Issue
Block a user