forked from I2P_Developers/i2p.i2p
* SSU, confignet: Add support for specifiying multiple addresses
This commit is contained in:
@ -1,9 +1,12 @@
|
|||||||
package net.i2p.router.web;
|
package net.i2p.router.web;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import net.i2p.router.Router;
|
import net.i2p.router.Router;
|
||||||
import net.i2p.router.transport.FIFOBandwidthRefiller;
|
import net.i2p.router.transport.FIFOBandwidthRefiller;
|
||||||
@ -94,9 +97,6 @@ public class ConfigNetHandler extends FormHandler {
|
|||||||
public void setUdpHost1(String host) {
|
public void setUdpHost1(String host) {
|
||||||
_udpHost1 = (host != null ? host.trim() : null);
|
_udpHost1 = (host != null ? host.trim() : null);
|
||||||
}
|
}
|
||||||
public void setUdpHost2(String host) {
|
|
||||||
_udpHost2 = (host != null ? host.trim() : null);
|
|
||||||
}
|
|
||||||
public void setUdpPort(String port) {
|
public void setUdpPort(String port) {
|
||||||
_udpPort = (port != null ? port.trim() : null);
|
_udpPort = (port != null ? port.trim() : null);
|
||||||
}
|
}
|
||||||
@ -160,26 +160,48 @@ public class ConfigNetHandler extends FormHandler {
|
|||||||
if (_udpAutoIP != null) {
|
if (_udpAutoIP != null) {
|
||||||
String uhost = "";
|
String uhost = "";
|
||||||
if (_udpAutoIP.equals("fixed")) {
|
if (_udpAutoIP.equals("fixed")) {
|
||||||
if (_udpHost1 != null && _udpHost1.length() > 0)
|
if (_settings == null)
|
||||||
uhost = _udpHost1;
|
_settings = Collections.EMPTY_MAP;
|
||||||
else if (_udpHost2 != null && _udpHost2.length() > 0)
|
Set<String> addrs = new TreeSet();
|
||||||
uhost = _udpHost2;
|
for (Object o : _settings.keySet()) {
|
||||||
else
|
String k = (String) o;
|
||||||
_udpAutoIP = UDPTransport.DEFAULT_SOURCES;
|
if (k.startsWith("addr_")) {
|
||||||
}
|
String v = k.substring(5);
|
||||||
changes.put(UDPTransport.PROP_SOURCES, _udpAutoIP);
|
if (v.length() > 0)
|
||||||
boolean valid = true;
|
addrs.add(v);
|
||||||
if (uhost.length() > 0) {
|
}
|
||||||
valid = verifyAddress(uhost);
|
}
|
||||||
if (valid) {
|
if (getJettyString("addrnew") != null) {
|
||||||
|
if (_udpHost1 != null && _udpHost1.length() > 0) {
|
||||||
|
if (verifyAddress(_udpHost1)) {
|
||||||
|
addrs.add(_udpHost1);
|
||||||
|
} else {
|
||||||
|
error = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int tot = addrs.size();
|
||||||
|
int i = 0;
|
||||||
|
if (tot > 0) {
|
||||||
|
StringBuilder buf = new StringBuilder(128);
|
||||||
|
for (String addr : addrs) {
|
||||||
|
buf.append(addr);
|
||||||
|
if (++i < tot)
|
||||||
|
buf.append(',');
|
||||||
|
}
|
||||||
|
uhost = buf.toString();
|
||||||
changes.put(UDPTransport.PROP_EXTERNAL_HOST, uhost);
|
changes.put(UDPTransport.PROP_EXTERNAL_HOST, uhost);
|
||||||
} else {
|
} else {
|
||||||
error = true;
|
_udpAutoIP = UDPTransport.DEFAULT_SOURCES;
|
||||||
|
removes.add(UDPTransport.PROP_EXTERNAL_HOST);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
removes.add(UDPTransport.PROP_EXTERNAL_HOST);
|
// not fixed
|
||||||
|
if (oldUHost.length() > 0)
|
||||||
|
removes.add(UDPTransport.PROP_EXTERNAL_HOST);
|
||||||
}
|
}
|
||||||
if (valid && ((!oldUdp.equals(_udpAutoIP)) || (!oldUHost.equals(uhost)))) {
|
changes.put(UDPTransport.PROP_SOURCES, _udpAutoIP);
|
||||||
|
if ((!oldUdp.equals(_udpAutoIP)) || (!oldUHost.equals(uhost))) {
|
||||||
addFormNotice(_("Updating IP address"));
|
addFormNotice(_("Updating IP address"));
|
||||||
restartRequired = true;
|
restartRequired = true;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package net.i2p.router.web;
|
package net.i2p.router.web;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import net.i2p.data.DataHelper;
|
import net.i2p.data.DataHelper;
|
||||||
import net.i2p.data.RouterAddress;
|
import net.i2p.data.RouterAddress;
|
||||||
@ -18,10 +21,10 @@ import net.i2p.util.Addresses;
|
|||||||
public class ConfigNetHelper extends HelperBase {
|
public class ConfigNetHelper extends HelperBase {
|
||||||
|
|
||||||
/** copied from various private components */
|
/** copied from various private components */
|
||||||
public final static String PROP_I2NP_NTCP_HOSTNAME = "i2np.ntcp.hostname";
|
final static String PROP_I2NP_NTCP_HOSTNAME = "i2np.ntcp.hostname";
|
||||||
public final static String PROP_I2NP_NTCP_PORT = "i2np.ntcp.port";
|
final static String PROP_I2NP_NTCP_PORT = "i2np.ntcp.port";
|
||||||
public final static String PROP_I2NP_NTCP_AUTO_PORT = "i2np.ntcp.autoport";
|
final static String PROP_I2NP_NTCP_AUTO_PORT = "i2np.ntcp.autoport";
|
||||||
public final static String PROP_I2NP_NTCP_AUTO_IP = "i2np.ntcp.autoip";
|
final static String PROP_I2NP_NTCP_AUTO_IP = "i2np.ntcp.autoip";
|
||||||
private final static String CHECKED = " checked=\"checked\" ";
|
private final static String CHECKED = " checked=\"checked\" ";
|
||||||
|
|
||||||
public String getUdphostname() {
|
public String getUdphostname() {
|
||||||
@ -175,9 +178,48 @@ public class ConfigNetHelper extends HelperBase {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getAddresses() {
|
public Set<String> getAddresses() {
|
||||||
ArrayList<String> al = new ArrayList(Addresses.getAddresses());
|
// exclude local, include IPv6
|
||||||
return al.toArray(new String[al.size()]);
|
return Addresses.getAddresses(false, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @since IPv6 */
|
||||||
|
public String getAddressSelector() {
|
||||||
|
Set<String> addrs = getAddresses();
|
||||||
|
Set<String> configs;
|
||||||
|
String cs = getUdphostname();
|
||||||
|
if (cs.length() <= 0) {
|
||||||
|
configs = Collections.EMPTY_SET;
|
||||||
|
} else {
|
||||||
|
configs = new HashSet(4);
|
||||||
|
String[] ca = cs.split("[,; \r\n\t]");
|
||||||
|
for (int i = 0; i < ca.length; i++) {
|
||||||
|
String c = ca[i];
|
||||||
|
if (c.length() > 0) {
|
||||||
|
configs.add(c);
|
||||||
|
addrs.add(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
StringBuilder buf = new StringBuilder(128);
|
||||||
|
buf.append("<div class=\"indent\">");
|
||||||
|
for (String addr : addrs) {
|
||||||
|
buf.append("\n " +
|
||||||
|
"<input type=\"checkbox\" class=\"optbox\" value=\"foo\" name=\"addr_");
|
||||||
|
buf.append(addr);
|
||||||
|
buf.append('"');
|
||||||
|
if (addrs.size() == 1 || configs.contains(addr))
|
||||||
|
buf.append(CHECKED);
|
||||||
|
buf.append("> ");
|
||||||
|
buf.append(addr);
|
||||||
|
buf.append("<br>");
|
||||||
|
}
|
||||||
|
buf.append("\n " +
|
||||||
|
"<input type=\"checkbox\" class=\"optbox\" name=\"addrnew\"");
|
||||||
|
buf.append(CHECKED);
|
||||||
|
buf.append("><input name =\"udpHost1\" type=\"text\" size=\"16\" />" +
|
||||||
|
"</div>");
|
||||||
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getInboundRate() {
|
public String getInboundRate() {
|
||||||
|
@ -40,25 +40,11 @@
|
|||||||
<%=intl._("Ignore local interface IP address")%><br>
|
<%=intl._("Ignore local interface IP address")%><br>
|
||||||
<input type="radio" class="optbox" name="udpAutoIP" value="ssu" <%=nethelper.getUdpAutoIPChecked(0) %> >
|
<input type="radio" class="optbox" name="udpAutoIP" value="ssu" <%=nethelper.getUdpAutoIPChecked(0) %> >
|
||||||
<%=intl._("Use SSU IP address detection only")%><br>
|
<%=intl._("Use SSU IP address detection only")%><br>
|
||||||
<input type="radio" class="optbox" name="udpAutoIP" value="fixed" <%=nethelper.getUdpAutoIPChecked(1) %> >
|
|
||||||
<%=intl._("Specify hostname or IP")%>:
|
|
||||||
<input name ="udpHost1" type="text" size="16" value="<jsp:getProperty name="nethelper" property="udphostname" />" >
|
|
||||||
<% String[] ips = nethelper.getAddresses();
|
|
||||||
if (ips.length > 0) {
|
|
||||||
out.print(intl._("or") + " <select name=\"udpHost2\"><option value=\"\" selected=\"selected\">"+intl._("Select Interface")+"</option>\n");
|
|
||||||
for (int i = 0; i < ips.length; i++) {
|
|
||||||
out.print("<option value=\"");
|
|
||||||
out.print(ips[i]);
|
|
||||||
out.print("\">");
|
|
||||||
out.print(ips[i]);
|
|
||||||
out.print("</option>\n");
|
|
||||||
}
|
|
||||||
out.print("</select>\n");
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<br>
|
|
||||||
<input type="radio" class="optbox" name="udpAutoIP" value="hidden" <%=nethelper.getUdpAutoIPChecked(2) %> >
|
<input type="radio" class="optbox" name="udpAutoIP" value="hidden" <%=nethelper.getUdpAutoIPChecked(2) %> >
|
||||||
<%=intl._("Hidden mode - do not publish IP")%> <i><%=intl._("(prevents participating traffic)")%></i><br>
|
<%=intl._("Hidden mode - do not publish IP")%> <i><%=intl._("(prevents participating traffic)")%></i><br>
|
||||||
|
<input type="radio" class="optbox" name="udpAutoIP" value="fixed" <%=nethelper.getUdpAutoIPChecked(1) %> >
|
||||||
|
<%=intl._("Specify hostname or IP")%>:<br>
|
||||||
|
<%=nethelper.getAddressSelector() %>
|
||||||
</p><p>
|
</p><p>
|
||||||
<%=intl._("Action when IP changes")%>:<br>
|
<%=intl._("Action when IP changes")%>:<br>
|
||||||
<input type="checkbox" class="optbox" name="laptop" value="true" <jsp:getProperty name="nethelper" property="laptopChecked" /> >
|
<input type="checkbox" class="optbox" name="laptop" value="true" <jsp:getProperty name="nethelper" property="laptopChecked" /> >
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2013-08-30 zzz
|
||||||
|
* Addresses: Treat Teredo addresses 2001:0::/32 as local
|
||||||
|
* SSU, confignet: Add support for specifiying multiple addresses
|
||||||
|
* SusiDNS: Don't require last subscription to be terminated by newline (ticket #1000)
|
||||||
|
|
||||||
2013-08-11 zzz
|
2013-08-11 zzz
|
||||||
* Jetty 7.6.12.v20130726
|
* Jetty 7.6.12.v20130726
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ public class RouterVersion {
|
|||||||
/** deprecated */
|
/** deprecated */
|
||||||
public final static String ID = "Monotone";
|
public final static String ID = "Monotone";
|
||||||
public final static String VERSION = CoreVersion.VERSION;
|
public final static String VERSION = CoreVersion.VERSION;
|
||||||
public final static long BUILD = 20;
|
public final static long BUILD = 21;
|
||||||
|
|
||||||
/** for example "-test" */
|
/** for example "-test" */
|
||||||
public final static String EXTRA = "";
|
public final static String EXTRA = "";
|
||||||
|
@ -329,15 +329,21 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InetAddress bindToAddr = null;
|
List<InetAddress> bindToAddrs = new ArrayList(4);
|
||||||
if (bindTo != null) {
|
if (bindTo != null) {
|
||||||
try {
|
String[] bta = bindTo.split("[,; \r\n\t]");
|
||||||
bindToAddr = InetAddress.getByName(bindTo);
|
for (int i = 0; i < bta.length; i++) {
|
||||||
} catch (UnknownHostException uhe) {
|
String bt = bta[i];
|
||||||
_log.error("Invalid SSU bind interface specified [" + bindTo + "]", uhe);
|
if (bt.length() <= 0)
|
||||||
//setReachabilityStatus(CommSystemFacade.STATUS_HOSED);
|
continue;
|
||||||
//return;
|
try {
|
||||||
// fall thru...
|
bindToAddrs.add(InetAddress.getByName(bt));
|
||||||
|
} catch (UnknownHostException uhe) {
|
||||||
|
_log.error("Invalid SSU bind interface specified [" + bt + "]", uhe);
|
||||||
|
//setReachabilityStatus(CommSystemFacade.STATUS_HOSED);
|
||||||
|
//return;
|
||||||
|
// fall thru...
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -355,15 +361,23 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
port = oldBindPort;
|
port = oldBindPort;
|
||||||
else
|
else
|
||||||
port = oldEPort;
|
port = oldEPort;
|
||||||
if (bindToAddr != null && _log.shouldLog(Log.WARN))
|
if (!bindToAddrs.isEmpty() && _log.shouldLog(Log.WARN))
|
||||||
_log.warn("Binding only to " + bindToAddr);
|
_log.warn("Binding only to " + bindToAddrs);
|
||||||
if (_log.shouldLog(Log.INFO))
|
if (_log.shouldLog(Log.INFO))
|
||||||
_log.info("Binding to the port: " + port);
|
_log.info("Binding to the port: " + port);
|
||||||
if (_endpoints.isEmpty()) {
|
if (_endpoints.isEmpty()) {
|
||||||
// will always be empty since we are removing them above
|
// will always be empty since we are removing them above
|
||||||
UDPEndpoint endpoint = new UDPEndpoint(_context, this, port, bindToAddr);
|
if (bindToAddrs.isEmpty()) {
|
||||||
_endpoints.add(endpoint);
|
UDPEndpoint endpoint = new UDPEndpoint(_context, this, port, null);
|
||||||
// TODO add additional endpoints for additional addresses/ports
|
_endpoints.add(endpoint);
|
||||||
|
setMTU(null);
|
||||||
|
} else {
|
||||||
|
for (InetAddress bindToAddr : bindToAddrs) {
|
||||||
|
UDPEndpoint endpoint = new UDPEndpoint(_context, this, port, bindToAddr);
|
||||||
|
_endpoints.add(endpoint);
|
||||||
|
setMTU(bindToAddr);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// unused for now
|
// unused for now
|
||||||
for (UDPEndpoint endpoint : _endpoints) {
|
for (UDPEndpoint endpoint : _endpoints) {
|
||||||
@ -375,7 +389,6 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setMTU(bindToAddr);
|
|
||||||
|
|
||||||
if (_establisher == null)
|
if (_establisher == null)
|
||||||
_establisher = new EstablishmentManager(_context, this);
|
_establisher = new EstablishmentManager(_context, this);
|
||||||
@ -440,7 +453,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
// set up external addresses
|
// set up external addresses
|
||||||
// REA param is false;
|
// REA param is false;
|
||||||
// TransportManager.startListening() calls router.rebuildRouterInfo()
|
// TransportManager.startListening() calls router.rebuildRouterInfo()
|
||||||
if (newPort > 0 && bindToAddr == null) {
|
if (newPort > 0 && bindToAddrs.isEmpty()) {
|
||||||
for (InetAddress ia : getSavedLocalAddresses()) {
|
for (InetAddress ia : getSavedLocalAddresses()) {
|
||||||
rebuildExternalAddress(ia.getHostAddress(), newPort, false);
|
rebuildExternalAddress(ia.getHostAddress(), newPort, false);
|
||||||
}
|
}
|
||||||
@ -1725,6 +1738,17 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
String host = null;
|
String host = null;
|
||||||
if (explicitAddressSpecified()) {
|
if (explicitAddressSpecified()) {
|
||||||
host = _context.getProperty(PROP_EXTERNAL_HOST);
|
host = _context.getProperty(PROP_EXTERNAL_HOST);
|
||||||
|
if (host != null) {
|
||||||
|
String[] hosts = host.split("[,; \r\n\t]");
|
||||||
|
RouterAddress rv = null;
|
||||||
|
for (int i = 0; i < hosts.length; i++) {
|
||||||
|
String h = hosts[i];
|
||||||
|
if (h.length() <= 0)
|
||||||
|
continue;
|
||||||
|
rv = rebuildExternalAddress(h, port, allowRebuildRouterInfo);
|
||||||
|
}
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
RouterAddress cur = getCurrentAddress(false);
|
RouterAddress cur = getCurrentAddress(false);
|
||||||
if (cur != null)
|
if (cur != null)
|
||||||
|
Reference in New Issue
Block a user