ch.setVersion( handshake.getProtocolVersion() ); if ( handshake.getHost().contains( "\0" ) ) String[] split = handshake.getHost().split( "\0", 2 ); handshake.setHost( split[0] ); extraDataInHandshake = "\0" + split[1]; if ( handshake.getHost().endsWith( "." ) ) handshake.setHost( handshake.getHost().substring( 0, handshake.getHost().length() - 1 ) ); this.virtualHost = InetSocketAddress.createUnresolved( handshake.getHost(), handshake.getPort() ); if ( bungee.getConfig().isLogPings() ) switch ( handshake.getRequestedProtocol() ) ch.setProtocol( Protocol.LOGIN ); if ( !ProtocolConstants.SUPPORTED_VERSION_IDS.contains( handshake.getProtocolVersion() ) ) if ( handshake.getProtocolVersion() > bungee.getProtocolVersion() ) throw new IllegalArgumentException( "Cannot request protocol " + handshake.getRequestedProtocol() );
@Override public void read(ByteBuf buf) { protocolVersion = readVarInt( buf ); host = readString( buf ); port = buf.readUnsignedShort(); requestedProtocol = readVarInt( buf ); }
@Override public void write(ByteBuf buf) { writeVarInt( protocolVersion, buf ); writeString( host, buf ); buf.writeShort( port ); writeVarInt( requestedProtocol, buf ); }
@Override public void connected(ChannelWrapper channel) throws Exception { this.ch = channel; this.handshakeHandler = new ForgeServerHandler( user, ch, target ); Handshake originalHandshake = user.getPendingConnection().getHandshake(); Handshake copiedHandshake = new Handshake( originalHandshake.getProtocolVersion(), originalHandshake.getHost(), originalHandshake.getPort(), 2 ); if ( BungeeCord.getInstance().config.isIpForward() ) { String newHost = copiedHandshake.getHost() + "\00" + user.getAddress().getHostString() + "\00" + user.getUUID(); LoginResult profile = user.getPendingConnection().getLoginProfile(); if ( profile != null && profile.getProperties() != null && profile.getProperties().length > 0 ) { newHost += "\00" + BungeeCord.getInstance().gson.toJson( profile.getProperties() ); } copiedHandshake.setHost( newHost ); } else if ( !user.getExtraDataInHandshake().isEmpty() ) { // Only restore the extra data if IP forwarding is off. // TODO: Add support for this data with IP forwarding. copiedHandshake.setHost( copiedHandshake.getHost() + user.getExtraDataInHandshake() ); } channel.write( copiedHandshake ); channel.setProtocol( Protocol.LOGIN ); channel.write( new LoginRequest( user.getName() ) ); }
@Override public int getVersion() { return ( handshake == null ) ? -1 : handshake.getProtocolVersion(); }
@Override public void connected(ChannelWrapper channel) throws Exception { this.channel = channel; MinecraftEncoder encoder = new MinecraftEncoder( Protocol.HANDSHAKE, false, protocol ); channel.getHandle().pipeline().addAfter( PipelineUtils.FRAME_DECODER, PipelineUtils.PACKET_DECODER, new MinecraftDecoder( Protocol.STATUS, false, ProxyServer.getInstance().getProtocolVersion() ) ); channel.getHandle().pipeline().addAfter( PipelineUtils.FRAME_PREPENDER, PipelineUtils.PACKET_ENCODER, encoder ); channel.write( new Handshake( protocol, target.getAddress().getHostString(), target.getAddress().getPort(), 1 ) ); encoder.setProtocol( Protocol.STATUS ); channel.write( new StatusRequest() ); }
Handshake copiedHandshake = new Handshake( originalHandshake.getProtocolVersion(), originalHandshake.getHost(), originalHandshake.getPort(), 2 ); String newHost = copiedHandshake.getHost() + "\00" + user.getAddress().getHostString() + "\00" + user.getUUID(); copiedHandshake.setHost( newHost ); } else if ( !user.getExtraDataInHandshake().isEmpty() ) copiedHandshake.setHost( copiedHandshake.getHost() + user.getExtraDataInHandshake() );
( (BungeeServerInfo) forced ).ping( pingBack, handshake.getProtocolVersion() ); } else int protocol = ( ProtocolConstants.SUPPORTED_VERSION_IDS.contains( handshake.getProtocolVersion() ) ) ? handshake.getProtocolVersion() : bungee.getProtocolVersion(); pingBack.done( new ServerPing( new ServerPing.Protocol( bungee.getName() + " " + bungee.getGameVersion(), protocol ),
@Override public void connected(ChannelWrapper channel) throws Exception { this.channel = channel; MinecraftEncoder encoder = new MinecraftEncoder( Protocol.HANDSHAKE, false, protocol ); channel.getHandle().pipeline().addAfter( PipelineUtils.FRAME_DECODER, PipelineUtils.PACKET_DECODER, new MinecraftDecoder( Protocol.STATUS, false, ProxyServer.getInstance().getProtocolVersion() ) ); channel.getHandle().pipeline().addAfter( PipelineUtils.FRAME_PREPENDER, PipelineUtils.PACKET_ENCODER, encoder ); channel.write( new Handshake( protocol, target.getAddress().getHostString(), target.getAddress().getPort(), 1 ) ); encoder.setProtocol( Protocol.STATUS ); channel.write( new StatusRequest() ); }
ch.setVersion( handshake.getProtocolVersion() ); if ( handshake.getHost().contains( "\0" ) ) String[] split = handshake.getHost().split( "\0", 2 ); handshake.setHost( split[0] ); extraDataInHandshake = "\0" + split[1]; if ( handshake.getHost().endsWith( "." ) ) handshake.setHost( handshake.getHost().substring( 0, handshake.getHost().length() - 1 ) ); this.virtualHost = InetSocketAddress.createUnresolved( handshake.getHost(), handshake.getPort() ); switch ( handshake.getRequestedProtocol() ) ch.setProtocol( Protocol.LOGIN ); if ( !ProtocolConstants.SUPPORTED_VERSION_IDS.contains( handshake.getProtocolVersion() ) ) throw new IllegalArgumentException( "Cannot request protocol " + handshake.getRequestedProtocol() );
@Override public void read(ByteBuf buf) { protocolVersion = readVarInt( buf ); host = readString( buf ); port = buf.readUnsignedShort(); requestedProtocol = readVarInt( buf ); }
@Override public void write(ByteBuf buf) { writeVarInt( protocolVersion, buf ); writeString( host, buf ); buf.writeShort( port ); writeVarInt( requestedProtocol, buf ); }
@Override public int getVersion() { return ( handshake == null ) ? -1 : handshake.getProtocolVersion(); }
( (BungeeServerInfo) forced ).ping( pingBack, handshake.getProtocolVersion() ); } else int protocol = ( ProtocolConstants.SUPPORTED_VERSION_IDS.contains( handshake.getProtocolVersion() ) ) ? handshake.getProtocolVersion() : bungee.getProtocolVersion(); pingBack.done( new ServerPing( new ServerPing.Protocol( bungee.getName() + " " + bungee.getGameVersion(), protocol ),
this.loginRequest = loginRequest; if ( !ProtocolConstants.SUPPORTED_VERSION_IDS.contains( handshake.getProtocolVersion() ) )