Skip to content

Commit

Permalink
chore: remove some slow logging (#4936)
Browse files Browse the repository at this point in the history
Co-authored-by: Nail Khanipov <foxflameless@gmail.com>
  • Loading branch information
Cervator and DarkWeird authored Nov 16, 2021
1 parent 7f2f0ca commit 85f9c82
Showing 1 changed file with 0 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,8 @@
import org.terasology.reflection.metadata.FieldMetadata;

import java.net.BindException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.InterfaceAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Collection;
import java.util.Enumeration;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -177,40 +172,18 @@ public void host(int port, boolean dedicatedServer) throws HostingFailedExceptio
logger.info("No server MOTD is defined");
}

// enumerate all network interfaces that listen
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();

while (interfaces.hasMoreElements()) {
NetworkInterface ifc = interfaces.nextElement();
if (!ifc.isLoopback()) {
for (InterfaceAddress ifadr : ifc.getInterfaceAddresses()) {
// Exclude interfaces with the following key words to avoid common virtual and otherwise unlikely useful nics
// TODO: Make this configurable via config.cfg?
if (ifc.getDisplayName().contains("VirtualBox") || ifc.getDisplayName().contains("ISATAP")) {
logger.info("Skipping filtered interface name {}", ifc.getDisplayName());
} else {
InetAddress adr = ifadr.getAddress();
logger.info("Listening on network interface \"{}\", hostname \"{}\" ({})",
ifc.getDisplayName(), adr.getCanonicalHostName(), adr.getHostAddress());
}
}
}
}
if (serverChannelFuture.isSuccess()) {
logger.info("Server started");
}
serverChannelFuture.sync();
nextNetworkTick = time.getRealTimeInMs();
} catch (SocketException e) {
throw new HostingFailedException("Could not identify network interfaces", e);
} catch (ChannelException e) {
if (e.getCause() instanceof BindException) {
throw new HostingFailedException("Port already in use (are you already hosting a game?)",
e.getCause());
} else {
throw new HostingFailedException("Failed to host game", e.getCause());
}

} catch (InterruptedException e) {
shutdown();
throw new HostingFailedException("Server has been interrupted", e.getCause());
Expand Down

0 comments on commit 85f9c82

Please sign in to comment.