java.lang.Object
net.i2p.router.web.FormHandler
net.i2p.router.web.helpers.ConfigNetHandler

public class ConfigNetHandlerextends FormHandler
Handler to deal with form submissions from the main config form and act upon the values.

Used for both /config and /confignet.

  • Field Details

    • _saveRequested

      private boolean _saveRequested
      True when the form was submitted to save.
    • _requireIntroductions

      private boolean _requireIntroductions
      Form flag for requiring introductions.
    • _hiddenMode

      private boolean _hiddenMode
      Form flag for hidden mode.
    • _dynamicKeys

      private boolean _dynamicKeys
      Form flag for dynamic key re-creation.
    • _ntcpHostname

      private String _ntcpHostname
      Form value for the NTCP bind address.
    • _ntcpPort

      private String _ntcpPort
      Form value for the NTCP port.
    • _udpHost1

      private String _udpHost1
      Form value for the UDP bind address.
    • _udpPort

      private String _udpPort
      Form value for the UDP port.
    • _udpAutoIP

      private String _udpAutoIP
      Form value for the UDP auto-detected IP.
    • _ntcpAutoIP

      private String _ntcpAutoIP
      Form value for the NTCP auto-detected IP.
    • _ntcpAutoPort

      private boolean _ntcpAutoPort
      Form flag for picking a random NTCP port.
    • _upnp

      private boolean _upnp
      Form flag for enabling UPnP.
    • _laptop

      private boolean _laptop
      Form flag for the laptop mode.
    • _inboundRate

      private String _inboundRate
      Form value for the inbound bandwidth limit.
    • _outboundRate

      private String _outboundRate
      Form value for the outbound bandwidth limit.
    • _sharePct

      private String _sharePct
      Form value for the share percentage.
    • _ratesOnly

      private boolean _ratesOnly
      True to save the bandwidth limits only.
    • _udpDisabled

      private boolean _udpDisabled
      Form flag for disabling UDP.
    • _ipv6Mode

      private String _ipv6Mode
      Form value for the IPv6 mode.
    • _ipv4Firewalled

      private boolean _ipv4Firewalled
      Form flag for forcing IPv4 firewalled.
    • _ipv6Firewalled

      private boolean _ipv6Firewalled
      Form flag for forcing IPv6 firewalled.
    • changes

      private final Map<String,String> changes
      Config changes to show after a save.
    • PROP_HIDDEN

      private static final String PROP_HIDDEN
      Config key for hidden mode.
      See Also:
    • DEF_BURST_PCT

      static final int DEF_BURST_PCT
      Default burst percentage.
      See Also:
    • DEF_BURST_TIME

      static final int DEF_BURST_TIME
      Default burst time.
      See Also:
  • Constructor Details

    • ConfigNetHandler

      public ConfigNetHandler()
      Create a new handler.
  • Method Details

    • processForm

      protected void processForm()
      Applies the submitted form, saving when a save was requested.
      Specified by:
      processForm in class FormHandler
    • setSave

      public void setSave(String moo)
      Set that the user wants to save.
      Parameters:
      moo - a placeholder for the setter signature; the value is never read
    • setRequireIntroductions

      public void setRequireIntroductions(String moo)
      Set that the user wants to require introducers.
      Parameters:
      moo - a placeholder for the setter signature; the value is never read
    • setDynamicKeys

      public void setDynamicKeys(String moo)
      Set that the user wants dynamic keys.
      Parameters:
      moo - a placeholder for the setter signature; the value is never read
    • setEnableloadtesting

      public void setEnableloadtesting(String moo)
      Enable load testing.
      Parameters:
      moo - a placeholder for the setter signature; the value is never read
    • setUdpAutoIP

      public void setUdpAutoIP(String mode)
      Set the UDP address detection mode and whether the address is withheld.
      Parameters:
      mode - comma-separated list of IP address detection sources to use ("local", "upnp", "ssu"), "fixed" to use the manually entered address, or "hidden" to withhold our address from the NetDb
    • setNtcpAutoIP

      public void setNtcpAutoIP(String mode)
      Set the NTCP auto IP mode.
      Parameters:
      mode - the auto IP mode
    • setNtcpAutoPort

      public void setNtcpAutoPort(String mode)
      Set the NTCP auto port mode.
      Parameters:
      mode - the auto port mode
    • setUpnp

      public void setUpnp(String moo)
      Set that the user wants UPnP enabled.
      Parameters:
      moo - a placeholder for the setter signature; the value is never read
    • setLaptop

      public void setLaptop(String moo)
      Set that the user wants laptop mode enabled.
      Parameters:
      moo - a placeholder for the setter signature; the value is never read
    • setIPv4Firewalled

      public void setIPv4Firewalled(String moo)
      Set whether IPv4 is firewalled.
      Parameters:
      moo - a placeholder for the setter signature; the value is never read
    • setIPv6Firewalled

      public void setIPv6Firewalled(String moo)
      Set whether IPv6 is firewalled.
      Parameters:
      moo - a placeholder for the setter signature; the value is never read
    • setNtcphost

      public void setNtcphost(String host)
      Set the NTCP hostname.
      Parameters:
      host - the hostname to store, trimmed of surrounding whitespace; null stores null
    • setNtcpport

      public void setNtcpport(String port)
      Set the NTCP port.
      Parameters:
      port - the port number
    • setUdpHost1

      public void setUdpHost1(String host)
      Set the first UDP host.
      Parameters:
      host - the hostname to store, trimmed of surrounding whitespace; null stores null
    • setUdpPort

      public void setUdpPort(String port)
      Set the UDP port.
      Parameters:
      port - the port number
    • setInboundrate

      public void setInboundrate(String rate)
      Set the inbound rate.
      Parameters:
      rate - the inbound rate
    • setOutboundrate

      public void setOutboundrate(String rate)
      Set the outbound rate.
      Parameters:
      rate - the outbound rate
    • setSharePercentage

      public void setSharePercentage(String pct)
      Set the share percentage.
      Parameters:
      pct - the percentage to store, trimmed of surrounding whitespace; null leaves the percentage out of the pending changes
    • setRatesOnly

      public void setRatesOnly(String foo)
      Set rates-only mode (skip IP/transport changes).
      Parameters:
      foo - a placeholder for the setter signature; the value is never read
    • setDisableUDP

      public void setDisableUDP(String foo)
      Set whether UDP transport is disabled.
      Parameters:
      foo - the disable UDP mode
    • setIpv6

      public void setIpv6(String mode)
      Set the IPv6 mode configuration.
      Parameters:
      mode - the IPv6 mode
    • saveChanges

      private void saveChanges()
      The user made changes to the network config and wants to save them, so lets go ahead and do so.
    • verifyAddress

      private boolean verifyAddress(String addr)
      Do basic verification of address here to prevent problems later.
      Parameters:
      addr - the address string to verify
      Returns:
      true if the address parses and is publicly routable; false adds a form error describing which check failed
    • hiddenSwitch

      private void hiddenSwitch()
      A full restart is required to apply a hidden mode change. The new keys are not built on shutdown: Router.PROP_REBUILD_KEYS has been saved as true, so the next startup kills the old keys. There is no rekey-only path here, and registerWrapperNotifier() is safe to call whether or not a wrapper is present - its shutdown task notifies the wrapper only when there is one.
    • updateRates

      private boolean updateRates()
      Apply the new rate settings, returning whether they changed.
      Returns:
      true if any rate or share property was staged in the pending changes map, meaning a restart is needed to apply it