@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; } } } }
byteBuf.writeByte(cmdStatus.byteValue()); byteBuf.writeByte(0x00); byteBuf.writeByte(addressType.byteValue()); switch (addressType) { case IPv4: {
public void encodeAsByteBuf(ByteBuf byteBuf) { byteBuf.writeByte(this.addressType.byteValue()); switch(this.addressType) { case IPv4: byteBuf.writeBytes(NetUtil.createByteArrayFromIpAddressString(this.host)); byteBuf.writeShort(this.port); break; case DOMAIN: byteBuf.writeByte(this.host.length()); byteBuf.writeBytes(this.host.getBytes(CharsetUtil.US_ASCII)); byteBuf.writeShort(this.port); break; case IPv6: byteBuf.writeBytes(NetUtil.createByteArrayFromIpAddressString(this.host)); byteBuf.writeShort(this.port); } }
@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; } } } }
byteBuf.writeByte(cmdStatus.byteValue()); byteBuf.writeByte(0x00); byteBuf.writeByte(addressType.byteValue()); switch (addressType) { case IPv4: {
int port = 0; int addressType = dataBuff.getUnsignedByte(0); if (addressType == SocksAddressType.IPv4.byteValue()) { if (dataBuff.readableBytes() < 7) { return; host = InetAddress.getByAddress(ipBytes).toString().substring(1); port = dataBuff.readShort(); } else if (addressType == SocksAddressType.DOMAIN.byteValue()) { int hostLength = dataBuff.getUnsignedByte(1); if (dataBuff.readableBytes() < hostLength + 4) {
byteBuf.writeByte(cmdStatus.byteValue()); byteBuf.writeByte(0x00); byteBuf.writeByte(addressType.byteValue()); switch (addressType) { case IPv4: {