mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-11-22 10:35:16 +01:00
Made webserver binding logging less confusing (#474)
People often think "0.0.0.0" is the IP they should connect to when BlueMap logs `WebServer bound to: /0.0.0.0:8100` Or they see the IPv6 address being logged, and think BlueMap is only running on IPv6.
This commit is contained in:
parent
c407ba6bd5
commit
7047df73d0
@ -28,10 +28,12 @@
|
|||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
import java.nio.channels.*;
|
import java.nio.channels.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public abstract class Server extends Thread implements Closeable, Runnable {
|
public abstract class Server extends Thread implements Closeable, Runnable {
|
||||||
|
|
||||||
@ -52,7 +54,20 @@ public void bind(SocketAddress address) throws IOException {
|
|||||||
server.bind(address);
|
server.bind(address);
|
||||||
this.server.add(server);
|
this.server.add(server);
|
||||||
|
|
||||||
Logger.global.logInfo("WebServer bound to: " + server.getLocalAddress());
|
if (checkIfBoundToAllInterfaces(address)) {
|
||||||
|
Logger.global.logInfo("WebServer bound to all network interfaces on port " + ((InetSocketAddress) address).getPort());
|
||||||
|
} else {
|
||||||
|
Logger.global.logInfo("WebServer bound to: " + server.getLocalAddress());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkIfBoundToAllInterfaces(SocketAddress address) {
|
||||||
|
if (address instanceof InetSocketAddress) {
|
||||||
|
InetSocketAddress inetAddress = (InetSocketAddress) address;
|
||||||
|
return Objects.equals(inetAddress.getAddress(), new InetSocketAddress(0).getAddress());
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user