private void logHttp(Connector connector) { log.info(String.format("HTTP connector enabled on port %d", connector.getPort())); }
public int getPortWithOffset() { int port = getPort(); // Zero is a special case and negative values are invalid if (port > 0) { return port + getPortOffset(); } return port; }
private String getPortsDescription(boolean localPort) { StringBuilder ports = new StringBuilder(); for (Connector connector : this.tomcat.getService().findConnectors()) { if (ports.length() != 0) { ports.append(' '); } int port = localPort ? connector.getLocalPort() : connector.getPort(); ports.append(port).append(" (").append(connector.getScheme()).append(')'); } return ports.toString(); }
private void checkConnectorHasStarted(Connector connector) { if (LifecycleState.FAILED.equals(connector.getState())) { throw new ConnectorStartFailedException(connector.getPort()); } }
@Test public void bind_to_specific_address() { Properties p = new Properties(); p.setProperty("sonar.web.port", "9000"); p.setProperty("sonar.web.host", "1.2.3.4"); TomcatConnectors.configure(tomcat, new Props(p)); verify(tomcat.getService()) .addConnector(argThat(c -> c.getScheme().equals("http") && c.getPort() == 9000 && ((InetAddress) c.getProperty("address")).getHostAddress().equals("1.2.3.4"))); }
@Test public void bind_to_all_addresses_by_default() { Properties p = new Properties(); p.setProperty("sonar.web.port", "9000"); TomcatConnectors.configure(tomcat, new Props(p)); verify(tomcat.getService()).addConnector(argThat(c -> c.getScheme().equals("http") && c.getPort() == 9000 && ((InetAddress) c.getProperty("address")).getHostAddress().equals("0.0.0.0"))); }
private void verifyHttpConnector(int expectedPort, Map<String, Object> expectedProps) { verify(tomcat.getService()).addConnector(argThat(c -> { if (!c.getScheme().equals("http")) { return false; } if (!c.getProtocol().equals(TomcatConnectors.HTTP_PROTOCOL)) { return false; } if (c.getPort() != expectedPort) { return false; } for (Map.Entry<String, Object> expectedProp : expectedProps.entrySet()) { if (!expectedProp.getValue().equals(c.getProperty(expectedProp.getKey()))) { return false; } } return true; })); } }
private int getHttpsPort() throws KeeperException, InterruptedException, IOException { int port = DEFAULT_HTTPS_PORT; for (Connector connector : httpsConnectors) { return connector.getPort(); } return port; }
/** * Gets the network port that this connector listens on. */ public int getPort() { return connector.getPort(); }
private int getHttpPort() { int port = DEFAULT_HTTP_PORT; for (Connector connector : httpConnectors) { return connector.getPort(); } return port; }
@Override public int getPort() { if (tomcat == null) { return -1; } return tomcat.getConnector().getPort(); }
protected ObjectName createObjectName(String domain, String type) throws MalformedObjectNameException { String encodedAddr = null; if (getProperty("address") != null) { encodedAddr = URLEncoder.encode(getProperty("address").toString()); } String addSuffix = (getProperty("address") == null) ? "" : ",address=" + encodedAddr; ObjectName _oname = new ObjectName(domain + ":type=" + type + ",port=" + getPort() + addSuffix); return _oname; }
protected ObjectName createObjectName(String domain, String type) throws MalformedObjectNameException { String encodedAddr = null; if (getProperty("address") != null) { encodedAddr = URLEncoder.encode(getProperty("address").toString()); } String addSuffix = (getProperty("address") == null) ? "" : ",address=" + encodedAddr; ObjectName _oname = new ObjectName(domain + ":type=" + type + ",port=" + getPort() + addSuffix); return _oname; }
protected ObjectName createObjectName(String domain, String type) throws MalformedObjectNameException { String encodedAddr = null; if (getAddress() != null) { encodedAddr = URLEncoder.encode(getProperty("address")); } String addSuffix = (getAddress() == null) ? "" : ",address=" + encodedAddr; ObjectName _oname = new ObjectName(domain + ":type=" + type + ",port=" + getPort() + addSuffix); return _oname; }
protected ObjectName createSipConnectorObjectName(Connector connector, String domain, String type) throws MalformedObjectNameException { String encodedAddr = null; if (connector.getProperty("address") != null) { encodedAddr = URLEncoder.encode(connector.getProperty("address").toString()); } String addSuffix = (connector.getProperty("address") == null) ? "" : ",address=" + encodedAddr; ObjectName _oname = new ObjectName(domain + ":type=" + type + ",port=" + connector.getPort() + ",transport=" + connector.getProperty("transport") + addSuffix); return _oname; }
protected ObjectName createObjectName(String domain, String type) throws MalformedObjectNameException { String encodedAddr = null; if (getProperty("address") != null) { encodedAddr = ObjectName.quote(getProperty("address").toString()); } String addSuffix = (getProperty("address") == null) ? "" : ",address=" + encodedAddr; ObjectName _oname = new ObjectName(domain + ":type=" + type + ",port=" + getPort() + addSuffix); return _oname; }
public int getPort(String protocol, boolean secure) { int result = -1; for (Connector connector : webserver.getService().findConnectors()) { if (connector.getProtocol().equals(protocol) && connector.getSecure() == secure) { return connector.getPort(); } } return result; } }
@Override public void invoke(Request request, Response response) throws IOException, ServletException { String property; if (getAddConnectorPort()) { property = request.getRequest().getRemoteAddr() + ";" + request.getConnector().getPort(); } else { property = request.getRequest().getRemoteAddr(); } process(property, request, response); }
@Override public void invoke(Request request, Response response) throws IOException, ServletException { String property; if (getAddConnectorPort()) { property = request.getRequest().getRemoteHost() + ";" + request.getConnector().getPort(); } else { property = request.getRequest().getRemoteHost(); } process(property, request, response); }