@Override public void encodeAsByteBuf(ByteBuf byteBuf) { byteBuf.writeByte(protocolVersion().byteValue()); byteBuf.writeByte(cmdType.byteValue()); byteBuf.writeByte(0x00); byteBuf.writeByte(addressType.byteValue()); switch (addressType) { case IPv4: { byteBuf.writeBytes(NetUtil.createByteArrayFromIpAddressString(host)); byteBuf.writeShort(port); break; } case DOMAIN: { byteBuf.writeByte(host.length()); byteBuf.writeCharSequence(host, CharsetUtil.US_ASCII); byteBuf.writeShort(port); break; } case IPv6: { byteBuf.writeBytes(NetUtil.createByteArrayFromIpAddressString(host)); byteBuf.writeShort(port); break; } } } }
@Override public void encodeAsByteBuf(ByteBuf byteBuf) { byteBuf.writeByte(protocolVersion().byteValue()); byteBuf.writeByte(cmdType.byteValue()); byteBuf.writeByte(0x00); byteBuf.writeByte(addressType.byteValue()); switch (addressType) { case IPv4: { byteBuf.writeBytes(NetUtil.createByteArrayFromIpAddressString(host)); byteBuf.writeShort(port); break; } case DOMAIN: { byteBuf.writeByte(host.length()); byteBuf.writeCharSequence(host, CharsetUtil.US_ASCII); byteBuf.writeShort(port); break; } case IPv6: { byteBuf.writeBytes(NetUtil.createByteArrayFromIpAddressString(host)); byteBuf.writeShort(port); break; } } } }
@Override public void encodeAsByteBuf(ByteBuf byteBuf) { byteBuf.writeByte(protocolVersion().byteValue()); byteBuf.writeByte(cmdType.byteValue()); byteBuf.writeByte(0x00); byteBuf.writeByte(addressType.byteValue()); switch (addressType) { case IPv4: { byteBuf.writeBytes(NetUtil.createByteArrayFromIpAddressString(host)); byteBuf.writeShort(port); break; } case DOMAIN: { byteBuf.writeByte(host.length()); byteBuf.writeCharSequence(host, CharsetUtil.US_ASCII); byteBuf.writeShort(port); break; } case IPv6: { byteBuf.writeBytes(NetUtil.createByteArrayFromIpAddressString(host)); byteBuf.writeShort(port); break; } } } }