use of com.github.joschi.jadconfig.ParameterException in project graylog2-server by Graylog2.
the class HttpConfiguration method getDefaultHttpUri.
private URI getDefaultHttpUri(String path) {
final HostAndPort bindAddress = getHttpBindAddress();
final URI publishUri;
final InetAddress inetAddress = toInetAddress(bindAddress.getHost());
if (inetAddress != null && Tools.isWildcardInetAddress(inetAddress)) {
final InetAddress guessedAddress;
try {
guessedAddress = Tools.guessPrimaryNetworkAddress(inetAddress instanceof Inet4Address);
if (guessedAddress.isLoopbackAddress()) {
LOG.debug("Using loopback address {}", guessedAddress);
}
} catch (Exception e) {
LOG.error("Could not guess primary network address for \"http_publish_uri\". Please configure it in your Graylog configuration.", e);
throw new ParameterException("No http_publish_uri.", e);
}
try {
publishUri = new URI(getUriScheme(), null, guessedAddress.getHostAddress(), bindAddress.getPort(), path, null, null);
} catch (URISyntaxException e) {
throw new RuntimeException("Invalid http_publish_uri.", e);
}
} else {
try {
publishUri = new URI(getUriScheme(), null, getHttpBindAddress().getHost(), getHttpBindAddress().getPort(), path, null, null);
} catch (URISyntaxException e) {
throw new RuntimeException("Invalid http_publish_uri.", e);
}
}
return publishUri;
}
Aggregations