Class PortConfig
java.lang.Object
com.iizix.comm.PortConfig
Class used to hold information of the started port.
- Author:
- Christopher Mindus
Field Summary
FieldsModifier and TypeFieldDescriptionfinal StringThe bind address,nullfor none.final IPortControllerInterface for the port control,nullif in iiziGo (for now).final StringThe external host name when front-end reverse-proxied, null for none.final StringThe name of the external host, including a potential ":port" addition, or none if it's matching the port number.final intThe external port number (1-65534) when front-end reverse-proxied, 0 for none.final booleanFlag for secure port by means of front-end proxy, even if theisHTTPSflag is false.final booleanFlag for HTTPS.final booleanThe secure connection flag.final StringThe name of the port configuration the connector was built from (WebServerPortConfig.NAME, or its atom name when none is set): what an application'sServerAppConfig.PORTSlist names (CC-FIX-APP-DEFINITIONS).final intThe (local) port number (1-65534) as configured, or 0 for a free port that the operating system picks when the connector binds: the port it got is thengetLocalPort()(CC-FIX-PORT-RANGE-A, R-D-14).Constructor Summary
ConstructorsConstructorDescriptionPortConfig(int port, boolean isHTTPS, boolean isFrontEndSecured, String bind, String externalHostName, int externalPort, IPortController controller) Constructor.PortConfig(int port, boolean isHTTPS, boolean isFrontEndSecured, String bind, String externalHostName, int externalPort, IPortController controller, String name) Constructor with the name of the port configuration (CC-FIX-APP-DEFINITIONS).Method Summary
Modifier and TypeMethodDescriptionintGets the port number the client uses: the external port when configured, otherwise 443 for a port secured by a front-end proxy (the proxy terminates TLS on the default HTTPS port), otherwise the local port.Gets the name of the external host with a potential":port", asexternalNameAndPort, but for the port the connector bound when the configured port was 0.intGets the local port: the port the connector bound once it is known, otherwise the configured one.getRemoteProtocolServerNameAndPort(HttpServletRequest servletRequest) Gets the remote protocol, server name and port, e.g.getRemoteProtocolServerNameAndPort(HttpServletRequest servletRequest, boolean omitDefaultPort) Gets the remote protocol, server name and port, e.g.getRemoteServerNameAndPort(HttpServletRequest servletRequest) Gets the remote server name and port.getRemoteServerNameAndPort(HttpServletRequest servletRequest, boolean omitDefaultPort) Gets the remote server name and port.booleanisSamePortConfig(PortConfig portConfig) Checks if two port configurations are equal: i.e.voidRestarts the Jetty (HTTPS) server connector after Let's Encrypt domain certificate renewal.voidsetBoundPort(int localPort) Sets the port the connector bound, read back from it by the web server after it opened the connector.
Field Details
port
public final int portThe (local) port number (1-65534) as configured, or 0 for a free port that the operating system picks when the connector binds: the port it got is thengetLocalPort()(CC-FIX-PORT-RANGE-A, R-D-14).isHTTPS
public final boolean isHTTPSFlag for HTTPS.isFrontEndSecured
public final boolean isFrontEndSecuredFlag for secure port by means of front-end proxy, even if theisHTTPSflag is false.isSecured
public final boolean isSecuredThe secure connection flag. The server may use a clear-text connection, but the client may use TLS if a front-end proxy is present.bind
The bind address,nullfor none.externalHostName
The external host name when front-end reverse-proxied, null for none.externalPort
public final int externalPortThe external port number (1-65534) when front-end reverse-proxied, 0 for none.externalNameAndPort
The name of the external host, including a potential ":port" addition, or none if it's matching the port number.controller
Interface for the port control,nullif in iiziGo (for now).name
The name of the port configuration the connector was built from (WebServerPortConfig.NAME, or its atom name when none is set): what an application'sServerAppConfig.PORTSlist names (CC-FIX-APP-DEFINITIONS).nullfor a connector built without a configuration name - iiziGo's preference ports and test fixtures - which never matches a name in such a list.
Constructor Details
PortConfig
public PortConfig(int port, boolean isHTTPS, boolean isFrontEndSecured, String bind, String externalHostName, int externalPort, IPortController controller) Constructor.- Parameters:
port- The port number, 0 for a free port the operating system picks when the connector binds, negative for the default port of the protocol (80 or 443).isHTTPS- Flag for HTTPS.isFrontEndSecured- Flag for secure port by means of front-end reverse-proxy, even if theisHTTPSflag is false.bind- The bind address, null for none.externalHostName- The external host name when front-end reverse-proxied, null for none.externalPort- The external port when front-end reverse-proxied, 0 for none.controller- The port controller, never null.
PortConfig
public PortConfig(int port, boolean isHTTPS, boolean isFrontEndSecured, String bind, String externalHostName, int externalPort, IPortController controller, String name) Constructor with the name of the port configuration (CC-FIX-APP-DEFINITIONS).- Parameters:
port- The port number, 0 for a free port the operating system picks when the connector binds, negative for the default port of the protocol (80 or 443).isHTTPS- Flag for HTTPS.isFrontEndSecured- Flag for secure port by means of front-end reverse-proxy, even if theisHTTPSflag is false.bind- The bind address, null for none.externalHostName- The external host name when front-end reverse-proxied, null for none.externalPort- The external port when front-end reverse-proxied, 0 for none.controller- The port controller, never null.name- The name of the port configuration, null for none.
Method Details
getClientPort
public int getClientPort()Gets the port number the client uses: the external port when configured, otherwise 443 for a port secured by a front-end proxy (the proxy terminates TLS on the default HTTPS port), otherwise the local port.- Returns:
- The port number used by the client side.
getLocalPort
public int getLocalPort()Gets the local port: the port the connector bound once it is known, otherwise the configured one.- Returns:
- The local port, 0 for a configured port 0 whose connector is not yet bound.
setBoundPort
public void setBoundPort(int localPort) Sets the port the connector bound, read back from it by the web server after it opened the connector.- Parameters:
localPort- The bound port, 1-65535.
getExternalNameAndPort
Gets the name of the external host with a potential":port", asexternalNameAndPort, but for the port the connector bound when the configured port was 0.- Returns:
- The name and port, or
nullwhen no external host name is configured.
restartConnector
public void restartConnector()Restarts the Jetty (HTTPS) server connector after Let's Encrypt domain certificate renewal.isSamePortConfig
Checks if two port configurations are equal: i.e. the same bind address (or none), the port number, front-end secured, the external host name and port, and the name.- Parameters:
portConfig- Another port configuration.- Returns:
trueif the port configurations match,falseotherwise.
getRemoteServerNameAndPort
Gets the remote server name and port. The port is omitted if 80 for unsecure or 443 for secured connections.- Parameters:
servletRequest- The servlet request.- Returns:
- The remote server name and port (perhaps omitted if default value).
getRemoteServerNameAndPort
public String getRemoteServerNameAndPort(HttpServletRequest servletRequest, boolean omitDefaultPort) Gets the remote server name and port. The port is optionally omitted if 80 for unsecure or 443 for secured connections.- Parameters:
servletRequest- The servlet request.omitDefaultPort- Flag to omit the default port.- Returns:
- The remote server name and port (perhaps omitted if default value).
getRemoteProtocolServerNameAndPort
Gets the remote protocol, server name and port, e.g.http://clear.text.server:8080orhttps://secure.server.com. The port is omitted if 80 for unsecure or 443 for secured connections.- Returns:
- The protocol, remote server name and port (perhaps omitted if default value).
getRemoteProtocolServerNameAndPort
public String getRemoteProtocolServerNameAndPort(HttpServletRequest servletRequest, boolean omitDefaultPort) Gets the remote protocol, server name and port, e.g.http://clear.text.server:8080orhttps://secure.server.com. The port is omitted if 80 for unsecure or 443 for secured connections.- Parameters:
servletRequest- The servlet request.omitDefaultPort- Flag to omit the default port.- Returns:
- The protocol, remote server name and port (perhaps omitted if default value).