java.lang.Object
net.i2p.util.PortMapper
Map services to internal or external application ports for this context. Not intended for the router's NTCP or SSU ports.
Field Summary
Modifier and TypeFieldDescriptionprivate final ConcurrentHashMap<String, InetSocketAddress> Mapped ports, by tunnel name.Names that get the eepsite port mapping.static final intDefault HTTP console port.static final StringDefault host for local services.static final intDefault HTTPS console port.static final StringProperty to prefer HTTPS.static final StringBOB service.static final StringConsole service.static final StringEepsite service.static final StringHTTP I2PControl service name.static final StringHTTP proxy service.static final StringHTTPS console service.static final StringHTTPS eepsite service name.static final StringHTTPS I2PControl service name.static final StringHTTPS proxy service.static final StringNot necessary, already in config?static final StringI2CP-SSL service name.static final StringTo indicate presence, alternative toWebAppStarter.isWebappRunning().static final StringTo indicate presence, alternative toWebAppStarter.isWebappRunning().static final StringTo indicate presence, alternative toWebAppStarter.isWebappRunning().static final StringIRC service.static final StringTo indicate presence, alternative toWebAppStarter.isWebappRunning().static final StringPOP3 service.static final StringSAM service.static final StringSAM-SSL service name.static final StringSAM-UDP service name.static final StringSMTP service.static final StringSOCKS service.static final StringTo indicate presence, alternative toWebAppStarter.isWebappRunning().static final StringTo indicate presence, alternative toWebAppStarter.isWebappRunning().static final StringTahoe-LAFS service.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionprivate static StringconvertWildcard(String ip, String def) Like the public convertWildcard above, for the case where the caller already knows there is more than one address.static StringdisplayHost(String ip) Render a bind address the way the status tables show it: a wildcard becomes the router's display address or the default host.getActualHost(String service, String def) The actual host for a service.If PROP_PREFER_HTTPS is true or unset, return https URL unless console is http only.getConsoleURL(boolean preferHTTPS) If preferHTTPS is true, return https URL unless console is http only.Snapshot of the eepsite URLs registered with the port mapper.Eepsite URLs configured in this port mapper.Snapshot of the service names registered for port forwarding with their bound addresses, for the consolidated debug view.The registered host for a service.private StringThe console URL, https if the console is https only.private StringThe console URL, http if the console is http only.intThe registered port for a service.intThe registered port for a service.booleanisRegistered(String service) Is the service registered?booleanAdd the service.booleanAdd the service.voidrenderStatusHTML(Writer out) Table of registered services with host and port, plus eepsites.private static StringControl URL for the mapped service.voidunregister(String service) Remove the service.voidunregister(String service, int port) Remove the service, only if it is registered with the supplied port.
Field Details
_dir
Mapped ports, by tunnel name._eepsites
PROP_PREFER_HTTPS
SVC_CONSOLE
SVC_HTTPS_CONSOLE
SVC_HTTP_PROXY
SVC_HTTPS_PROXY
SVC_EEPSITE
SVC_HTTPS_EEPSITE
HTTPS eepsite service name.- See Also:
SVC_IRC
SVC_SOCKS
SVC_TAHOE
SVC_SMTP
SVC_POP
SVC_SAM
SVC_SAM_UDP
SVC_SAM_SSL
SVC_BOB
SVC_I2CP
SVC_I2CP_SSL
SVC_HTTP_I2PCONTROL
HTTP I2PControl service name.- See Also:
SVC_HTTPS_I2PCONTROL
HTTPS I2PControl service name.- See Also:
SVC_I2PSNARK
To indicate presence, alternative toWebAppStarter.isWebappRunning(). For actual base URL, usegetConsoleURL().- See Also:
SVC_I2PTUNNEL
To indicate presence, alternative toWebAppStarter.isWebappRunning(). For actual base URL, use getConsoleURL()Note: This is only the webapp. Also requires TCG running to be useful. The webapp does not start TCG.
- See Also:
SVC_IMAGEGEN
To indicate presence, alternative toWebAppStarter.isWebappRunning(). For actual base URL, use getConsoleURL().- See Also:
SVC_SUSIDNS
To indicate presence, alternative toWebAppStarter.isWebappRunning(). For actual base URL, use getConsoleURL().- See Also:
SVC_SUSIMAIL
To indicate presence, alternative toWebAppStarter.isWebappRunning(). For actual base URL, use getConsoleURL().- See Also:
SVC_JSONRPC
To indicate presence, alternative toWebAppStarter.isWebappRunning(). For actual base URL, use getConsoleURL().- See Also:
DEFAULT_CONSOLE_PORT
public static final int DEFAULT_CONSOLE_PORTDefault HTTP console port.- See Also:
DEFAULT_HTTPS_CONSOLE_PORT
public static final int DEFAULT_HTTPS_CONSOLE_PORTDefault HTTPS console port.- See Also:
DEFAULT_HOST
Default host for local services.- See Also:
Constructor Details
PortMapper
Method Details
register
Add the service.- Parameters:
service- the service nameport- > 0- Returns:
- success, false if already registered
register
Add the service. If service is SVC_EEPSITE or SVC_HTTPS_EEPSITE, the URL will be included ingetEepsites().- Parameters:
service- the service namehost- the hostname to map the service toport- > 0- Returns:
- success, false if already registered
isRegistered
Is the service registered?- Parameters:
service- the service name- Returns:
- true if registered
unregister
unregister
Remove the service, only if it is registered with the supplied port. If service is SVC_EEPSITE or SVC_HTTPS_EEPSITE, the URL will be removed from getEepsites().- Parameters:
service- the service nameport- the port number
getPort
The registered port for a service.- Parameters:
service- the service name- Returns:
- -1 if not registered
getPort
The registered port for a service.- Parameters:
service- the service namedef- value to return when the service is unregistered- Returns:
- def if not registered
getHost
getActualHost
The actual host for a service. Will return "127.0.0.1" if the service was registered without a host. If the service was registered with the host "0.0.0.0", "::", or "0:0:0:0:0:0:0:0", it will return a public IP if we have one, else a local IP if we have one, else def. If it was not registered with a wildcard address, it will return the registered host.- Parameters:
service- the registered service name to look updef- value to return for an unregistered service or a wildcard with no usable IP- Returns:
- def if not registered
convertWildcard
Like the public convertWildcard above, for the case where the caller already knows there is more than one address.- Parameters:
ip- the address to convertdef- the address to use when there is nothing to convert- Returns:
- def if there are no IPs, otherwise the converted address
getConsoleURL
If PROP_PREFER_HTTPS is true or unset, return https URL unless console is http only. Default https://127.0.0.1:7667/ If PROP_PREFER_HTTPS is set to false, return http URL unless console is https only. Default http://127.0.0.1:7657/- Returns:
- the console URL
getConsoleURL
If preferHTTPS is true, return https URL unless console is http only. Default https://127.0.0.1:7667/ If preferHTTPS is false, return http URL unless console is https only. Default http://127.0.0.1:7657/- Parameters:
preferHTTPS- if true, start from the https console URL, which still- Returns:
- the console URL
getHTTPConsoleURL
The console URL, https if the console is https only.- Returns:
- http URL unless console is https only. Default http://127.0.0.1:7657/
getHTTPSConsoleURL
The console URL, http if the console is http only.- Returns:
- https URL unless console is http only. Default http://127.0.0.1:7657/
getEepsiteURLs
toURL
Control URL for the mapped service.- Parameters:
svc- the service name, https:// is used only for the HTTPS eepsitehost- the bound host, wildcards become 127.0.0.1 and IPv6 hosts get bracketsport- the port number to append after the host- Returns:
- the control URL, terminated with a slash
getForwardedServices
Snapshot of the service names registered for port forwarding with their bound addresses, for the consolidated debug view.- Returns:
- a copy of the map of service name to address, never null
getEepsites
displayHost
renderStatusHTML
Table of registered services with host and port, plus eepsites.- Parameters:
out- writer to write HTML output to- Throws:
IOException- if writing to output fails