Work around windows bugs

This commit is contained in:
md_5 2013-06-06 18:13:56 +10:00
parent ce8f1b44b6
commit 483fede234

View File

@ -8,6 +8,7 @@ import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption; import io.netty.channel.ChannelOption;
import io.netty.channel.socket.nio.NioSocketChannel; import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.util.internal.PlatformDependent;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@ -207,14 +208,18 @@ public final class UserConnection implements ProxiedPlayer
} }
} }
}; };
new Bootstrap() Bootstrap b = new Bootstrap()
.channel( NioSocketChannel.class ) .channel( NioSocketChannel.class )
.group( BungeeCord.getInstance().eventLoops ) .group( BungeeCord.getInstance().eventLoops )
.handler( initializer ) .handler( initializer )
.localAddress( getPendingConnection().getListener().getHost().getHostString(), 0 )
.option( ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000 ) // TODO: Configurable .option( ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000 ) // TODO: Configurable
.remoteAddress( target.getAddress() ) .remoteAddress( target.getAddress() );
.connect().addListener( listener ); // Windows is bugged, multi homed users will just have to live with random connecting IPs
if ( !PlatformDependent.isWindows() )
{
b.localAddress( getPendingConnection().getListener().getHost().getHostString(), 0 );
}
b.connect().addListener( listener );
} }
@Override @Override