@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; } } } }
/** * @deprecated Use {@link #valueOf(byte)} instead. */ @Deprecated public static SocksCmdType fromByte(byte b) { return valueOf(b); }
public static SocksCmdType valueOf(byte b) { for (SocksCmdType code : values()) { if (code.b == b) { return code; } } return UNKNOWN; }
cmdType = SocksCmdType.valueOf(byteBuf.readByte()); byteBuf.skipBytes(1); // reserved addressType = SocksAddressType.valueOf(byteBuf.readByte());
public static SocksCmdType valueOf(byte b) { for (SocksCmdType code : values()) { if (code.b == b) { return code; } } return UNKNOWN; }
@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; } } } }
/** * @deprecated Use {@link #valueOf(byte)} instead. */ @Deprecated public static SocksCmdType fromByte(byte b) { return valueOf(b); }
public static SocksCmdType valueOf(byte b) { for (SocksCmdType code : values()) { if (code.b == b) { return code; } } return UNKNOWN; }
@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; } } } }
/** * @deprecated Use {@link #valueOf(byte)} instead. */ @Deprecated public static SocksCmdType fromByte(byte b) { return valueOf(b); }
cmdType = SocksCmdType.valueOf(byteBuf.readByte()); byteBuf.skipBytes(1); // reserved addressType = SocksAddressType.valueOf(byteBuf.readByte());
cmdType = SocksCmdType.valueOf(byteBuf.readByte()); byteBuf.skipBytes(1); // reserved addressType = SocksAddressType.valueOf(byteBuf.readByte());