geforkt von Mirrors/Velocity
A bit more
Dieser Commit ist enthalten in:
Ursprung
a9715be771
Commit
1d2110f2aa
@ -61,7 +61,7 @@ public class VelocityServer {
|
||||
|
||||
httpClient = new NettyHttpClient(this);
|
||||
|
||||
this.cm.bind(new InetSocketAddress(26671));
|
||||
this.cm.bind(configuration.getBind());
|
||||
}
|
||||
|
||||
public Bootstrap initializeGenericBootstrap() {
|
||||
|
@ -2,6 +2,7 @@ package com.velocitypowered.proxy.config;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.moandjiezana.toml.Toml;
|
||||
import com.velocitypowered.proxy.util.AddressUtil;
|
||||
import com.velocitypowered.proxy.util.LegacyChatColorUtils;
|
||||
import net.kyori.text.Component;
|
||||
import net.kyori.text.serializer.ComponentSerializers;
|
||||
@ -10,6 +11,7 @@ import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
@ -50,6 +52,13 @@ public class VelocityConfiguration {
|
||||
valid = false;
|
||||
}
|
||||
|
||||
try {
|
||||
AddressUtil.parseAddress(bind);
|
||||
} catch (IllegalArgumentException e) {
|
||||
logger.error("'bind' option does not specify a valid IP address.", e);
|
||||
valid = false;
|
||||
}
|
||||
|
||||
if (!onlineMode) {
|
||||
logger.info("Proxy is running in offline mode!");
|
||||
}
|
||||
@ -72,6 +81,15 @@ public class VelocityConfiguration {
|
||||
valid = false;
|
||||
}
|
||||
|
||||
for (Map.Entry<String, String> entry : servers.entrySet()) {
|
||||
try {
|
||||
AddressUtil.parseAddress(entry.getValue());
|
||||
} catch (IllegalArgumentException e) {
|
||||
logger.error("Server {} does not have a valid IP address.", entry.getKey(), e);
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
for (String s : attemptConnectionOrder) {
|
||||
if (!servers.containsKey(s)) {
|
||||
logger.error("Fallback server " + s + " doesn't exist!");
|
||||
@ -90,8 +108,8 @@ public class VelocityConfiguration {
|
||||
return valid;
|
||||
}
|
||||
|
||||
public String getBind() {
|
||||
return bind;
|
||||
public InetSocketAddress getBind() {
|
||||
return AddressUtil.parseAddress(bind);
|
||||
}
|
||||
|
||||
public String getMotd() {
|
||||
|
@ -92,8 +92,6 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||
if (ctx.channel().isActive()) {
|
||||
cause.printStackTrace();
|
||||
|
||||
if (sessionHandler != null) {
|
||||
sessionHandler.exception(cause);
|
||||
}
|
||||
|
16
src/main/java/com/velocitypowered/proxy/util/AddressUtil.java
Normale Datei
16
src/main/java/com/velocitypowered/proxy/util/AddressUtil.java
Normale Datei
@ -0,0 +1,16 @@
|
||||
package com.velocitypowered.proxy.util;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URI;
|
||||
|
||||
public enum AddressUtil {
|
||||
;
|
||||
|
||||
public static InetSocketAddress parseAddress(String ip) {
|
||||
Preconditions.checkNotNull(ip, "ip");
|
||||
URI uri = URI.create("tcp://" + ip);
|
||||
return new InetSocketAddress(uri.getHost(), uri.getPort());
|
||||
}
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren