mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-24 09:01:41 +01:00
Show any valid address if webserver is enabled (even game servers)
Affects issues: - Fixed #3251
This commit is contained in:
parent
d6065f497b
commit
549a26bcc8
@ -105,7 +105,7 @@ public class Addresses {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Optional<String> getProxyServerAddress() {
|
public Optional<String> getProxyServerAddress() {
|
||||||
return dbSystem.getDatabase().query(ServerQueries.fetchProxyServers())
|
return dbSystem.getDatabase().query(ServerQueries.fetchPlanServerInformationCollection())
|
||||||
.stream()
|
.stream()
|
||||||
.map(Server::getWebAddress)
|
.map(Server::getWebAddress)
|
||||||
.filter(this::isValidAddress)
|
.filter(this::isValidAddress)
|
||||||
@ -113,7 +113,12 @@ public class Addresses {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isValidAddress(String address) {
|
private boolean isValidAddress(String address) {
|
||||||
return address != null && !address.isEmpty() && !"0.0.0.0".equals(address);
|
return address != null
|
||||||
|
&& !address.isEmpty()
|
||||||
|
&& !"0.0.0.0".equals(address)
|
||||||
|
&& !"https://www.example.address".equals(address)
|
||||||
|
&& !"http://www.example.address".equals(address)
|
||||||
|
&& !"http://localhost:0".equals(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<String> getServerPropertyIP() {
|
public Optional<String> getServerPropertyIP() {
|
||||||
|
@ -90,7 +90,7 @@ public class ServerServerInfo extends ServerInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateStorage() {
|
private void updateStorage() {
|
||||||
String address = addresses.getAccessAddress().orElseGet(addresses::getFallbackLocalhostAddress);
|
String address = getAddress();
|
||||||
String name = config.get(PluginSettings.SERVER_NAME);
|
String name = config.get(PluginSettings.SERVER_NAME);
|
||||||
|
|
||||||
server.setName(name);
|
server.setName(name);
|
||||||
@ -101,6 +101,11 @@ public class ServerServerInfo extends ServerInfo {
|
|||||||
fromFile.save(server);
|
fromFile.save(server);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getAddress() {
|
||||||
|
return addresses.getAccessAddress()
|
||||||
|
.orElse(addresses.isWebserverEnabled() ? addresses.getFallbackLocalhostAddress() : null);
|
||||||
|
}
|
||||||
|
|
||||||
private Server registerNew() {
|
private Server registerNew() {
|
||||||
return registerNew(generateNewUUID());
|
return registerNew(generateNewUUID());
|
||||||
}
|
}
|
||||||
@ -117,7 +122,7 @@ public class ServerServerInfo extends ServerInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Server createServerObject(ServerUUID serverUUID) {
|
private Server createServerObject(ServerUUID serverUUID) {
|
||||||
String webAddress = addresses.getAccessAddress().orElseGet(addresses::getFallbackLocalhostAddress);
|
String webAddress = getAddress();
|
||||||
String name = config.get(PluginSettings.SERVER_NAME);
|
String name = config.get(PluginSettings.SERVER_NAME);
|
||||||
return new Server(serverUUID, name, webAddress, currentVersion);
|
return new Server(serverUUID, name, webAddress, currentVersion);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user