Package net.i2p.util
Class PortMapper
java.lang.Object
net.i2p.util.PortMapper
public class PortMapper extends Object
Map services to internal or external application ports
for this context. Not intended for the router's NTCP or SSU ports.
- Since:
- 0.8.12
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_CONSOLE_PORTstatic StringDEFAULT_HOSTstatic intDEFAULT_HTTPS_CONSOLE_PORTstatic StringPROP_PREFER_HTTPSstatic StringSVC_BOBstatic StringSVC_CONSOLEstatic StringSVC_EEPSITEstatic StringSVC_HTTP_I2PCONTROLstatic StringSVC_HTTP_PROXYstatic StringSVC_HTTPS_CONSOLEstatic StringSVC_HTTPS_EEPSITEstatic StringSVC_HTTPS_I2PCONTROLstatic StringSVC_HTTPS_PROXYstatic StringSVC_I2CPnot necessary, already in config?static StringSVC_I2CP_SSLstatic StringSVC_I2PSNARKTo indicate presence, alternative to WebAppStarter.isWebappRunning().static StringSVC_I2PTUNNELTo indicate presence, alternative to WebAppStarter.isWebappRunning().static StringSVC_IMAGEGENTo indicate presence, alternative to WebAppStarter.isWebappRunning().static StringSVC_IRCstatic StringSVC_JSONRPCTo indicate presence, alternative to WebAppStarter.isWebappRunning().static StringSVC_POPstatic StringSVC_SAMstatic StringSVC_SAM_SSLstatic StringSVC_SAM_UDPstatic StringSVC_SMTPstatic StringSVC_SOCKSstatic StringSVC_SUSIDNSTo indicate presence, alternative to WebAppStarter.isWebappRunning().static StringSVC_SUSIMAILTo indicate presence, alternative to WebAppStarter.isWebappRunning().static StringSVC_TAHOE -
Constructor Summary
Constructors Constructor Description PortMapper(I2PAppContext context) -
Method Summary
Modifier and Type Method Description StringgetActualHost(String service, String def)Get the actual host for a service.StringgetConsoleURL()If PROP_PREFER_HTTPS is true or unset, return https URL unless console is http only.StringgetConsoleURL(boolean preferHTTPS)If preferHTTPS is true, return https URL unless console is http only.List<String>getEepsiteURLs()StringgetHost(String service, String def)Get the registered host for a service.intgetPort(String service)Get the registered port for a serviceintgetPort(String service, int def)Get the registered port for a servicebooleanisRegistered(String service)Is the service registered?booleanregister(String service, int port)Add the servicebooleanregister(String service, String host, int port)Add the service.voidrenderStatusHTML(Writer out)For debugging onlyvoidunregister(String service)Remove the servicevoidunregister(String service, int port)Remove the service, only if it is registered with the supplied port.
-
Field Details
-
PROP_PREFER_HTTPS
- See Also:
- Constant Field Values
-
SVC_CONSOLE
- See Also:
- Constant Field Values
-
SVC_HTTPS_CONSOLE
- See Also:
- Constant Field Values
-
SVC_HTTP_PROXY
- See Also:
- Constant Field Values
-
SVC_HTTPS_PROXY
- See Also:
- Constant Field Values
-
SVC_EEPSITE
- See Also:
- Constant Field Values
-
SVC_HTTPS_EEPSITE
- Since:
- 0.9.34
- See Also:
- Constant Field Values
-
SVC_IRC
- See Also:
- Constant Field Values
-
SVC_SOCKS
- See Also:
- Constant Field Values
-
SVC_TAHOE
- See Also:
- Constant Field Values
-
SVC_SMTP
- See Also:
- Constant Field Values
-
SVC_POP
- See Also:
- Constant Field Values
-
SVC_SAM
- See Also:
- Constant Field Values
-
SVC_SAM_UDP
- Since:
- 0.9.24
- See Also:
- Constant Field Values
-
SVC_SAM_SSL
- Since:
- 0.9.24
- See Also:
- Constant Field Values
-
SVC_BOB
- See Also:
- Constant Field Values
-
SVC_I2CP
not necessary, already in config?- See Also:
- Constant Field Values
-
SVC_I2CP_SSL
- Since:
- 0.9.23
- See Also:
- Constant Field Values
-
SVC_HTTP_I2PCONTROL
- Since:
- 0.9.34
- See Also:
- Constant Field Values
-
SVC_HTTPS_I2PCONTROL
- Since:
- 0.9.34
- See Also:
- Constant Field Values
-
SVC_I2PSNARK
To indicate presence, alternative to WebAppStarter.isWebappRunning(). For actual base URL, use getConsoleURL()- Since:
- 0.9.34
- See Also:
- Constant Field Values
-
SVC_I2PTUNNEL
To indicate presence, alternative to WebAppStarter.isWebappRunning(). For actual base URL, use getConsoleURL()- Since:
- 0.9.34
- See Also:
- Constant Field Values
-
SVC_IMAGEGEN
To indicate presence, alternative to WebAppStarter.isWebappRunning(). For actual base URL, use getConsoleURL()- Since:
- 0.9.34
- See Also:
- Constant Field Values
-
SVC_SUSIDNS
To indicate presence, alternative to WebAppStarter.isWebappRunning(). For actual base URL, use getConsoleURL()- Since:
- 0.9.34
- See Also:
- Constant Field Values
-
SVC_SUSIMAIL
To indicate presence, alternative to WebAppStarter.isWebappRunning(). For actual base URL, use getConsoleURL()- Since:
- 0.9.34
- See Also:
- Constant Field Values
-
SVC_JSONRPC
To indicate presence, alternative to WebAppStarter.isWebappRunning(). For actual base URL, use getConsoleURL()- Since:
- 0.9.39
- See Also:
- Constant Field Values
-
DEFAULT_CONSOLE_PORT
public static final int DEFAULT_CONSOLE_PORT- Since:
- 0.9.34
- See Also:
- Constant Field Values
-
DEFAULT_HTTPS_CONSOLE_PORT
public static final int DEFAULT_HTTPS_CONSOLE_PORT- Since:
- 0.9.34
- See Also:
- Constant Field Values
-
DEFAULT_HOST
- Since:
- 0.9.34
- See Also:
- Constant Field Values
-
-
Constructor Details
-
PortMapper
- Parameters:
context- unused for now
-
-
Method Details
-
register
Add the service- Parameters:
port- > 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 in getEepsites()- Parameters:
port- > 0- Returns:
- success, false if already registered
- Since:
- 0.9.21
-
isRegistered
Is the service registered?- Since:
- 0.9.34
-
unregister
Remove the service -
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()- Since:
- 0.9.34
-
getPort
Get the registered port for a service- Returns:
- -1 if not registered
-
getPort
Get the registered port for a service- Parameters:
def- default- Returns:
- def if not registered
-
getHost
Get the registered host for a service. Will return "127.0.0.1" if the service was registered without a host.- Parameters:
def- default- Returns:
- def if not registered
- Since:
- 0.9.21
-
getActualHost
Get 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:
def- default- Returns:
- def if not registered
- Since:
- 0.9.24
-
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/- Since:
- 0.9.33 consolidated from i2ptunnel and desktopgui
-
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/- Since:
- 0.9.34
-
getEepsiteURLs
- Returns:
- unsorted, non-empty, or null if none
- Since:
- 0.9.50
-
renderStatusHTML
For debugging only- Throws:
IOException- Since:
- 0.9.20
-