java.lang.Object
net.i2p.router.web.HelperBase
net.i2p.router.web.helpers.ConfigNetHelper

public class ConfigNetHelperextends HelperBase
Helper for network configuration page rendering and form processing. Used for both /config and /confignet pages.
  • Field Details

  • Constructor Details

    • ConfigNetHelper

      public ConfigNetHelper()
      Creates a new instance of the network configuration helper.
  • Method Details

    • getUdphostname

      public String getUdphostname()
      Get the external UDP hostname.
      Returns:
      the configured external host, which may list several entries separated by commas, semicolons or whitespace; empty if unset
    • getNtcphostname

      public String getNtcphostname()
      Get the NTCP hostname.
      Returns:
      the configured NTCP host; empty if unset
    • getNtcpport

      public String getNtcpport()
      Get the NTCP port.
      Returns:
      the configured NTCP port, unparsed; empty if unset
    • getUdpIP

      public String getUdpIP()
      Get the UDP IP address.
      Returns:
      host or "unknown"
    • getUdpPort

      public String getUdpPort()
      To reduce confusion caused by NATs, this is the current internal SSU port, not the external port.
      Returns:
      the internal SSU port
    • getConfiguredUdpPort

      public String getConfiguredUdpPort()
      This should always be the actual internal SSU port, as UDPTransport updates the config when it changes.
      Returns:
      the configured SSU port
    • getDynamicKeysChecked

      public String getDynamicKeysChecked()
      Get checked attribute for dynamic keys.
      Returns:
      the checked attribute
    • getLaptopChecked

      public String getLaptopChecked()
      Get checked attribute for laptop mode.
      Returns:
      the checked attribute
    • getIPv4FirewalledChecked

      public String getIPv4FirewalledChecked()
      Get checked attribute for IPv4 firewalled setting.
      Returns:
      the checked attribute
    • getIPv6FirewalledChecked

      public String getIPv6FirewalledChecked()
      Get checked attribute for IPv6 firewalled setting.
      Returns:
      the checked attribute
    • getTcpAutoPortChecked

      public String getTcpAutoPortChecked(int mode)
      Get checked attribute for TCP auto port.
      Parameters:
      mode - the mode to check
      Returns:
      the checked attribute
    • getTcpAutoIPChecked

      public String getTcpAutoIPChecked(int mode)
      Get checked attribute for TCP auto IP.
      Parameters:
      mode - the mode to check
      Returns:
      the checked attribute
    • getUdpAutoIPChecked

      public String getUdpAutoIPChecked(int mode)
      Get checked attribute for UDP auto IP.
      Parameters:
      mode - the mode to check
      Returns:
      the checked attribute
    • getUpnpChecked

      public String getUpnpChecked()
      Whether UPnP is enabled.
      Returns:
      the checked attribute if UPnP is enabled
    • getUdpDisabledChecked

      public String getUdpDisabledChecked()
      Default false, inverse of default true property.
      Returns:
      the checked attribute if UDP is disabled
    • getUdpEnabledChecked

      public String getUdpEnabledChecked()
      Default true.
      Returns:
      the checked attribute if UDP is enabled
    • getIPv6Checked

      public String getIPv6Checked(String mode)
      Combined SSU/NTCP Use SSU setting, then NTCP setting, then default.
      Parameters:
      mode - the IPv6 configuration mode
      Returns:
      the checked attribute for the matching mode
    • getAddresses

      public Set<String> getAddresses()
      Get the set of addresses.
      Returns:
      every address the router publishes, including IPv6 but excluding local and IPv6 temporary addresses
    • getAddressSelector

      public String getAddressSelector()
      Get the HTML for an address selector input.
      Returns:
      the HTML for the address selector
    • getInboundRate

      public String getInboundRate()
      Get the inbound rate as a decimal.
      Returns:
      the inbound rate in kB/s, where kB is 1000 bytes, rounded to a whole number
    • getOutboundRate

      public String getOutboundRate()
      Get the outbound rate as a decimal.
      Returns:
      the outbound rate in kB/s, where kB is 1000 bytes, rounded to a whole number
    • getInboundBurstRateBits

      public String getInboundBurstRateBits()
      Get the inbound burst rate in bits as a decimal.
      Returns:
      an HTML fragment showing the inbound burst rate in bps alongside the monthly data transfer it would allow
    • getOutboundBurstRateBits

      public String getOutboundBurstRateBits()
      Get the outbound burst rate in bits as a decimal.
      Returns:
      an HTML fragment showing the outbound burst rate in bps alongside the monthly data transfer it would allow
    • getShareRateBits

      public String getShareRateBits()
      Get the share rate in bits as a decimal.
      Returns:
      an HTML fragment showing the share rate in bps alongside the monthly data transfer it would allow
    • getShareRateMegabits

      public String getShareRateMegabits()
      Get the share rate in megabits as a decimal.
      Returns:
      the share bandwidth in megabits per second, to two decimal places
    • kbytesToBits

      private String kbytesToBits(float kbytes)
      Convert KB/s to a bit-rate string.
      Parameters:
      kbytes - the rate in binary kilobytes per second
      Returns:
      the formatted rate and monthly data HTML span
    • getInboundBurstRate

      public String getInboundBurstRate()
      Get the inbound burst rate as a decimal.
      Returns:
      the inbound burst rate in kB/s, where kB is 1000 bytes, rounded to a whole number
    • getOutboundBurstRate

      public String getOutboundBurstRate()
      Get the outbound burst rate as a decimal.
      Returns:
      the outbound burst rate in kB/s, where kB is 1000 bytes, rounded to a whole number
    • getSharePercentageBox

      public String getSharePercentageBox()
      Get the share percentage selection box HTML.
      Returns:
      the select element for the share percentage, with the current percentage marked as the selected option
    • getShareBandwidth

      public int getShareBandwidth()
      Get the share bandwidth.
      Returns:
      in binary KBytes per second