/** * Checks the userConfig bind address is not 0.0.0.0 and replaces it with 127.0.0.1 if needed * * @return the userConfig bind address if not 0.0.0.0 else 127.0.0.1 * @since 5.7 */ public InetAddress getBindAddress() throws ConfigurationException { return getBindAddress(userConfig.getProperty(PARAM_BIND_ADDRESS)); }
private void evalLoopbackURL() throws ConfigurationException { String loopbackURL = userConfig.getProperty(PARAM_LOOPBACK_URL); if (loopbackURL != null) { log.debug("Using configured loop back url: " + loopbackURL); return; } InetAddress bindAddress = getBindAddress(); // Address and ports already checked by #checkAddressesAndPorts try { if (bindAddress.isAnyLocalAddress()) { boolean preferIPv6 = "false".equals(System.getProperty("java.net.preferIPv4Stack")) && "true".equals(System.getProperty("java.net.preferIPv6Addresses")); bindAddress = preferIPv6 ? InetAddress.getByName("::1") : InetAddress.getByName("127.0.0.1"); log.debug("Bind address is \"ANY\", using local address instead: " + bindAddress); } } catch (UnknownHostException e) { log.debug(e, e); log.error(e.getMessage()); } String httpPort = userConfig.getProperty(PARAM_HTTP_PORT); String contextPath = userConfig.getProperty(PARAM_CONTEXT_PATH); // Is IPv6 or IPv4 ? if (bindAddress instanceof Inet6Address) { loopbackURL = "http://[" + bindAddress.getHostAddress() + "]:" + httpPort + contextPath; } else { loopbackURL = "http://" + bindAddress.getHostAddress() + ":" + httpPort + contextPath; } log.debug("Set as loop back URL: " + loopbackURL); defaultConfig.setProperty(PARAM_LOOPBACK_URL, loopbackURL); }
@Override protected void checkNetwork() throws ConfigurationException { InetAddress bindAddress = generator.getBindAddress(); ConfigurationGenerator.checkPortAvailable(bindAddress, Integer.parseInt(generator.getUserConfig().getProperty(PARAM_HTTP_TOMCAT_ADMIN_PORT))); }
/** * Will check the configured addresses are reachable and Nuxeo required ports are available on those addresses. * Server specific implementations should override this method in order to check for server specific ports. * {@link #PARAM_BIND_ADDRESS} must be set before. * * @since 5.5 * @see ServerConfigurator#verifyInstallation() */ public void checkAddressesAndPorts() throws ConfigurationException { InetAddress bindAddress = getBindAddress(); // Sanity check if (bindAddress.isMulticastAddress()) { throw new ConfigurationException("Multicast address won't work: " + bindAddress); } checkAddressReachable(bindAddress); checkPortAvailable(bindAddress, Integer.parseInt(userConfig.getProperty(PARAM_HTTP_PORT))); }