Commit 15ba286c authored by legoc's avatar legoc
Browse files

Refined endpoint definition: if hostname is not available, try the IP address

parent 80ea3bf1
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<dependency> <dependency>
<groupId>fr.ill.ics</groupId> <groupId>fr.ill.ics</groupId>
<artifactId>cameo-server</artifactId> <artifactId>cameo-server</artifactId>
<version>0.1.5</version> <version>0.1.6</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>fr.ill.ics</groupId> <groupId>fr.ill.ics</groupId>
......
...@@ -162,11 +162,19 @@ public final class ConfigManager { ...@@ -162,11 +162,19 @@ public final class ConfigManager {
} }
public void setHost(String host) { public void setHost(String host) {
// If host is provided, set it.
if (host == null) { if (host == null) {
try { try {
// Otherwise try to get the hostname.
this.host = InetAddress.getLocalHost().getHostName(); this.host = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) { } catch (UnknownHostException e) {
this.host = "localhost"; try {
// Otherwise try to get the IP address.
this.host = InetAddress.getLocalHost().getHostAddress();
} catch (UnknownHostException e2) {
// Otherwise set localhost.
this.host = "localhost";
}
} }
} else { } else {
this.host = host; this.host = host;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment