Allow setting whether to bind to the local address.

This commit is contained in:
md_5 2013-08-04 18:56:48 +10:00
parent fb94612315
commit 14ac2dd308
3 changed files with 7 additions and 2 deletions

View File

@ -52,4 +52,8 @@ public class ListenerInfo
* Class used to build tab lists for this player. * Class used to build tab lists for this player.
*/ */
private final Class<? extends TabListHandler> tabList; private final Class<? extends TabListHandler> tabList;
/**
* Whether to set the local address when connecting to servers.
*/
private final boolean setLocalAddress;
} }

View File

@ -232,7 +232,7 @@ public final class UserConnection implements ProxiedPlayer
.option( ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000 ) // TODO: Configurable .option( ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000 ) // TODO: Configurable
.remoteAddress( target.getAddress() ); .remoteAddress( target.getAddress() );
// Windows is bugged, multi homed users will just have to live with random connecting IPs // 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 ); b.localAddress( getPendingConnection().getListener().getHost().getHostString(), 0 );
} }

View File

@ -212,8 +212,9 @@ public class YamlConfig implements ConfigurationAdapter
{ {
value = DefaultTabList.GLOBAL_PING; 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 ); ret.add( info );
} }