diff --git a/api/src/main/java/net/md_5/bungee/api/config/ListenerInfo.java b/api/src/main/java/net/md_5/bungee/api/config/ListenerInfo.java index bb1c3f90..1ec6d5c2 100644 --- a/api/src/main/java/net/md_5/bungee/api/config/ListenerInfo.java +++ b/api/src/main/java/net/md_5/bungee/api/config/ListenerInfo.java @@ -52,4 +52,8 @@ public class ListenerInfo * Class used to build tab lists for this player. */ private final Class tabList; + /** + * Whether to set the local address when connecting to servers. + */ + private final boolean setLocalAddress; } diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java index 0f5fec03..c4427bdf 100644 --- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java @@ -232,7 +232,7 @@ public final class UserConnection implements ProxiedPlayer .option( ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000 ) // TODO: Configurable .remoteAddress( target.getAddress() ); // Windows is bugged, multi homed users will just have to live with random connecting IPs - if ( !PlatformDependent.isWindows() ) + if ( getPendingConnection().getListener().isSetLocalAddress() && !PlatformDependent.isWindows() ) { b.localAddress( getPendingConnection().getListener().getHost().getHostString(), 0 ); } diff --git a/proxy/src/main/java/net/md_5/bungee/config/YamlConfig.java b/proxy/src/main/java/net/md_5/bungee/config/YamlConfig.java index 5ab92daa..e88970d6 100644 --- a/proxy/src/main/java/net/md_5/bungee/config/YamlConfig.java +++ b/proxy/src/main/java/net/md_5/bungee/config/YamlConfig.java @@ -212,8 +212,9 @@ public class YamlConfig implements ConfigurationAdapter { value = DefaultTabList.GLOBAL_PING; } + boolean setLocalAddress = get( "bind_local_address", true, val ); - ListenerInfo info = new ListenerInfo( address, motd, maxPlayers, tabListSize, defaultServer, fallbackServer, forceDefault, forced, value.clazz ); + ListenerInfo info = new ListenerInfo( address, motd, maxPlayers, tabListSize, defaultServer, fallbackServer, forceDefault, forced, value.clazz, setLocalAddress ); ret.add( info ); }