Skip to content

Commit

Permalink
Merge pull request #66 from ServiceInventoryManagementSystem/fix/netw…
Browse files Browse the repository at this point in the history
…orkInterfaceConfig

network config fix
  • Loading branch information
arwassa authored May 29, 2018
2 parents 4b0e2c9 + fff5fd2 commit d2058c3
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/main/java/org/sims/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,24 @@ public SimsConfig(Environment env){

try{
if(!iface.isEmpty()){
System.out.println("Using if: " + iface);
networkInterface = NetworkInterface.getByName(iface);
Enumeration<InetAddress> addresses = networkInterface.getInetAddresses();
while(addresses.hasMoreElements()){
InetAddress addr = addresses.nextElement();
if(!addr.isLoopbackAddress()){
address = addr;
break;
if(networkInterface != null) {
Enumeration<InetAddress> addresses = networkInterface.getInetAddresses();
while (addresses.hasMoreElements()) {
InetAddress addr = addresses.nextElement();
if (!addr.isLoopbackAddress()) {
address = addr;
break;
}
}
}else {
System.err.println("Could not find interface! Trying with ip...");
}
}

if(!ip.isEmpty()){
System.out.println("Using ip: " + ip);
address = Inet4Address.getByName(ip);
}

Expand Down

0 comments on commit d2058c3

Please # to comment.