forked from I2P_Developers/i2p.i2p
add ipv6 to /confignet
This commit is contained in:
@ -7,8 +7,8 @@ import java.util.Map;
|
||||
|
||||
import net.i2p.router.Router;
|
||||
import net.i2p.router.transport.FIFOBandwidthRefiller;
|
||||
import net.i2p.router.transport.TransportUtil;
|
||||
import net.i2p.router.transport.TransportManager;
|
||||
import net.i2p.router.transport.TransportUtil;
|
||||
import net.i2p.router.transport.udp.UDPTransport;
|
||||
import net.i2p.router.web.ConfigServiceHandler;
|
||||
import net.i2p.util.Addresses;
|
||||
@ -17,6 +17,7 @@ import net.i2p.util.Addresses;
|
||||
* Handler to deal with form submissions from the main config form and act
|
||||
* upon the values.
|
||||
*
|
||||
* Used for both /config and /confignet
|
||||
*/
|
||||
public class ConfigNetHandler extends FormHandler {
|
||||
private String _hostname;
|
||||
@ -45,6 +46,7 @@ public class ConfigNetHandler extends FormHandler {
|
||||
private String _sharePct;
|
||||
private boolean _ratesOnly;
|
||||
private boolean _udpDisabled;
|
||||
private String _ipv6Mode;
|
||||
private final Map<String, String> changes = new HashMap();
|
||||
private static final String PROP_HIDDEN = Router.PROP_HIDDEN_HIDDEN; // see Router for other choice
|
||||
|
||||
@ -130,6 +132,11 @@ public class ConfigNetHandler extends FormHandler {
|
||||
_udpDisabled = true;
|
||||
}
|
||||
|
||||
/** @since IPv6 */
|
||||
public void setIpv6(String mode) {
|
||||
_ipv6Mode = mode;
|
||||
}
|
||||
|
||||
private void recheckReachability() {
|
||||
_context.commSystem().recheckReachability();
|
||||
addFormNotice(_("Rechecking router reachability..."));
|
||||
@ -177,6 +184,26 @@ public class ConfigNetHandler extends FormHandler {
|
||||
restartRequired = true;
|
||||
}
|
||||
}
|
||||
if (_ipv6Mode != null) {
|
||||
// take care not to set default, as it will change
|
||||
String tcp6 = _context.getProperty(TransportUtil.NTCP_IPV6_CONFIG);
|
||||
if (tcp6 == null)
|
||||
tcp6 = TransportUtil.DEFAULT_IPV6_CONFIG.toConfigString();
|
||||
String udp6 = _context.getProperty(TransportUtil.SSU_IPV6_CONFIG);
|
||||
if (udp6 == null)
|
||||
udp6 = TransportUtil.DEFAULT_IPV6_CONFIG.toConfigString();
|
||||
boolean ch = false;
|
||||
if (!_ipv6Mode.equals(tcp6)) {
|
||||
changes.put(TransportUtil.NTCP_IPV6_CONFIG, _ipv6Mode);
|
||||
ch = true;
|
||||
}
|
||||
if (!_ipv6Mode.equals(udp6)) {
|
||||
changes.put(TransportUtil.SSU_IPV6_CONFIG, _ipv6Mode);
|
||||
ch = true;
|
||||
}
|
||||
if (ch)
|
||||
addFormNotice(_("Updating IPv6 setting"));
|
||||
}
|
||||
|
||||
// NTCP Settings
|
||||
// Normalize some things to make the following code a little easier...
|
||||
|
@ -7,11 +7,15 @@ import net.i2p.data.RouterAddress;
|
||||
import net.i2p.router.CommSystemFacade;
|
||||
import net.i2p.router.Router;
|
||||
import net.i2p.router.transport.TransportManager;
|
||||
import net.i2p.router.transport.TransportUtil;
|
||||
import net.i2p.router.transport.udp.UDPTransport;
|
||||
import net.i2p.util.Addresses;
|
||||
|
||||
/**
|
||||
*
|
||||
* Used for both /config and /confignet
|
||||
*/
|
||||
public class ConfigNetHelper extends HelperBase {
|
||||
public ConfigNetHelper() {}
|
||||
|
||||
/** copied from various private components */
|
||||
public final static String PROP_I2NP_NTCP_HOSTNAME = "i2np.ntcp.hostname";
|
||||
@ -19,6 +23,7 @@ public class ConfigNetHelper extends HelperBase {
|
||||
public final static String PROP_I2NP_NTCP_AUTO_PORT = "i2np.ntcp.autoport";
|
||||
public final static String PROP_I2NP_NTCP_AUTO_IP = "i2np.ntcp.autoip";
|
||||
private final static String CHECKED = " checked=\"checked\" ";
|
||||
|
||||
public String getUdphostname() {
|
||||
return _context.getProperty(UDPTransport.PROP_EXTERNAL_HOST, "");
|
||||
}
|
||||
@ -152,6 +157,23 @@ public class ConfigNetHelper extends HelperBase {
|
||||
return CHECKED;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Combined SSU/NTCP
|
||||
* Use SSU setting, then NTCP setting, then default
|
||||
* @since IPv6
|
||||
*/
|
||||
public String getIPv6Checked(String mode) {
|
||||
String s = _context.getProperty(TransportUtil.SSU_IPV6_CONFIG);
|
||||
if (s == null) {
|
||||
s = _context.getProperty(TransportUtil.NTCP_IPV6_CONFIG);
|
||||
if (s == null)
|
||||
s = TransportUtil.DEFAULT_IPV6_CONFIG.toConfigString();
|
||||
}
|
||||
if (s.equals(mode))
|
||||
return CHECKED;
|
||||
return "";
|
||||
}
|
||||
|
||||
public String[] getAddresses() {
|
||||
ArrayList<String> al = new ArrayList(Addresses.getAddresses());
|
||||
|
@ -64,6 +64,18 @@
|
||||
<input type="checkbox" class="optbox" name="laptop" value="true" <jsp:getProperty name="nethelper" property="laptopChecked" /> >
|
||||
<%=intl._("Laptop mode - Change router identity and UDP port when IP changes for enhanced anonymity")%>
|
||||
(<i><%=intl._("Experimental")%></i>)
|
||||
</p><p>
|
||||
<%=intl._("IPv6 Configuration")%>:<br>
|
||||
<input type="radio" class="optbox" name="ipv6" value="false" <%=nethelper.getIPv6Checked("false") %> >
|
||||
<%=intl._("Disable IPv6")%><br>
|
||||
<input type="radio" class="optbox" name="ipv6" value="enable" <%=nethelper.getIPv6Checked("enable") %> >
|
||||
<%=intl._("Enable IPv6")%><br>
|
||||
<input type="radio" class="optbox" name="ipv6" value="preferIPv4" <%=nethelper.getIPv6Checked("preferIPv4") %> >
|
||||
<%=intl._("Prefer IPv4 over IPv6")%><br>
|
||||
<input type="radio" class="optbox" name="ipv6" value="preferIPv6" <%=nethelper.getIPv6Checked("preferIPv6") %> >
|
||||
<%=intl._("Prefer IPv6 over IPv4")%><br>
|
||||
<input type="radio" class="optbox" name="ipv6" value="only" <%=nethelper.getIPv6Checked("only") %> >
|
||||
<%=intl._("Use IPv6 only (disable IPv4)")%><br>
|
||||
</p><p><b><%=intl._("UDP Configuration:")%></b><br>
|
||||
<%=intl._("UDP port:")%>
|
||||
<input name ="udpPort" type="text" size="5" maxlength="5" value="<jsp:getProperty name="nethelper" property="configuredUdpPort" />" ><br>
|
||||
|
@ -52,7 +52,7 @@ public abstract class TransportUtil {
|
||||
}
|
||||
|
||||
private static final Map<String, IPv6Config> BY_NAME = new HashMap<String, IPv6Config>();
|
||||
private static final IPv6Config DEFAULT_IPV6_CONFIG = IPv6Config.IPV6_DISABLED;
|
||||
public static final IPv6Config DEFAULT_IPV6_CONFIG = IPv6Config.IPV6_DISABLED;
|
||||
|
||||
static {
|
||||
for (IPv6Config cfg : IPv6Config.values()) {
|
||||
|
Reference in New Issue
Block a user