private static void ipv6toStr(StringBuilder sb, byte[] src, int fromHextet, int toHextet) { int i; toHextet --; for (i = fromHextet; i < toHextet; i++) { appendHextet(sb, src, i); sb.append(ipv6hextetSeparator); } appendHextet(sb, src, i); }
String host = SocksCommonUtils.readUsAscii(byteBuf, fieldLength); int port = byteBuf.readUnsignedShort(); out.add(new SocksCmdRequest(cmdType, addressType, host, port)); byte[] bytes = new byte[16]; byteBuf.readBytes(bytes); String host = SocksCommonUtils.ipv6toStr(bytes); int port = byteBuf.readUnsignedShort(); out.add(new SocksCmdRequest(cmdType, addressType, host, port));
/** * Converts numeric IPv6 to standard (non-compressed) format. */ public static String ipv6toStr(byte[] src) { assert src.length == 16; StringBuilder sb = new StringBuilder(39); ipv6toStr(sb, src, 0, 8); return sb.toString(); }
@Override protected void decode(ChannelHandlerContext ctx, ByteBuf byteBuf, List<Object> out) throws Exception { switch (state()) { case CHECK_PROTOCOL_VERSION: { if (byteBuf.readByte() != SocksSubnegotiationVersion.AUTH_PASSWORD.byteValue()) { out.add(SocksCommonUtils.UNKNOWN_SOCKS_REQUEST); break; } checkpoint(State.READ_USERNAME); } case READ_USERNAME: { int fieldLength = byteBuf.readByte(); username = SocksCommonUtils.readUsAscii(byteBuf, fieldLength); checkpoint(State.READ_PASSWORD); } case READ_PASSWORD: { int fieldLength = byteBuf.readByte(); String password = SocksCommonUtils.readUsAscii(byteBuf, fieldLength); out.add(new SocksAuthRequest(username, password)); break; } default: { throw new Error(); } } ctx.pipeline().remove(this); }
/** * Converts numeric IPv6 to standard (non-compressed) format. */ public static String ipv6toStr(byte[] src) { assert src.length == 16; StringBuilder sb = new StringBuilder(39); ipv6toStr(sb, src, 0, 8); return sb.toString(); }
@Override protected void decode(ChannelHandlerContext ctx, ByteBuf byteBuf, List<Object> out) throws Exception { switch (state()) { case CHECK_PROTOCOL_VERSION: { if (byteBuf.readByte() != SocksSubnegotiationVersion.AUTH_PASSWORD.byteValue()) { out.add(SocksCommonUtils.UNKNOWN_SOCKS_REQUEST); break; } checkpoint(State.READ_USERNAME); } case READ_USERNAME: { int fieldLength = byteBuf.readByte(); username = SocksCommonUtils.readUsAscii(byteBuf, fieldLength); checkpoint(State.READ_PASSWORD); } case READ_PASSWORD: { int fieldLength = byteBuf.readByte(); String password = SocksCommonUtils.readUsAscii(byteBuf, fieldLength); out.add(new SocksAuthRequest(username, password)); break; } default: { throw new Error(); } } ctx.pipeline().remove(this); }
String host = SocksCommonUtils.readUsAscii(byteBuf, fieldLength); int port = byteBuf.readUnsignedShort(); out.add(new SocksCmdResponse(cmdStatus, addressType, host, port)); byte[] bytes = new byte[16]; byteBuf.readBytes(bytes); String host = SocksCommonUtils.ipv6toStr(bytes); int port = byteBuf.readUnsignedShort(); out.add(new SocksCmdResponse(cmdStatus, addressType, host, port));
/** * Converts numeric IPv6 to standard (non-compressed) format. */ public static String ipv6toStr(byte[] src) { assert src.length == 16; StringBuilder sb = new StringBuilder(39); ipv6toStr(sb, src, 0, 8); return sb.toString(); }
private static void ipv6toStr(StringBuilder sb, byte[] src, int fromHextet, int toHextet) { int i; toHextet --; for (i = fromHextet; i < toHextet; i++) { appendHextet(sb, src, i); sb.append(ipv6hextetSeparator); } appendHextet(sb, src, i); }
@Override protected void decode(ChannelHandlerContext ctx, ByteBuf byteBuf, List<Object> out) throws Exception { switch (state()) { case CHECK_PROTOCOL_VERSION: { if (byteBuf.readByte() != SocksSubnegotiationVersion.AUTH_PASSWORD.byteValue()) { out.add(SocksCommonUtils.UNKNOWN_SOCKS_REQUEST); break; } checkpoint(State.READ_USERNAME); } case READ_USERNAME: { int fieldLength = byteBuf.readByte(); username = SocksCommonUtils.readUsAscii(byteBuf, fieldLength); checkpoint(State.READ_PASSWORD); } case READ_PASSWORD: { int fieldLength = byteBuf.readByte(); String password = SocksCommonUtils.readUsAscii(byteBuf, fieldLength); out.add(new SocksAuthRequest(username, password)); break; } default: { throw new Error(); } } ctx.pipeline().remove(this); }
String host = SocksCommonUtils.readUsAscii(byteBuf, fieldLength); int port = byteBuf.readUnsignedShort(); out.add(new SocksCmdResponse(cmdStatus, addressType, host, port)); byte[] bytes = new byte[16]; byteBuf.readBytes(bytes); String host = SocksCommonUtils.ipv6toStr(bytes); int port = byteBuf.readUnsignedShort(); out.add(new SocksCmdResponse(cmdStatus, addressType, host, port));
private static void ipv6toStr(StringBuilder sb, byte[] src, int fromHextet, int toHextet) { int i; toHextet --; for (i = fromHextet; i < toHextet; i++) { appendHextet(sb, src, i); sb.append(ipv6hextetSeparator); } appendHextet(sb, src, i); }
String host = SocksCommonUtils.readUsAscii(byteBuf, fieldLength); int port = byteBuf.readUnsignedShort(); out.add(new SocksCmdRequest(cmdType, addressType, host, port)); byte[] bytes = new byte[16]; byteBuf.readBytes(bytes); String host = SocksCommonUtils.ipv6toStr(bytes); int port = byteBuf.readUnsignedShort(); out.add(new SocksCmdRequest(cmdType, addressType, host, port));
String host = SocksCommonUtils.readUsAscii(byteBuf, fieldLength); int port = byteBuf.readUnsignedShort(); out.add(new SocksCmdRequest(cmdType, addressType, host, port)); byte[] bytes = new byte[16]; byteBuf.readBytes(bytes); String host = SocksCommonUtils.ipv6toStr(bytes); int port = byteBuf.readUnsignedShort(); out.add(new SocksCmdRequest(cmdType, addressType, host, port));
String host = SocksCommonUtils.readUsAscii(byteBuf, fieldLength); int port = byteBuf.readUnsignedShort(); out.add(new SocksCmdResponse(cmdStatus, addressType, host, port)); byte[] bytes = new byte[16]; byteBuf.readBytes(bytes); String host = SocksCommonUtils.ipv6toStr(bytes); int port = byteBuf.readUnsignedShort(); out.add(new SocksCmdResponse(cmdStatus, addressType, host, port));