org.rx.net.shadowsocks.ProtocolCodec Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rxlib Show documentation
Show all versions of rxlib Show documentation
A set of utilities for Java
package org.rx.net.shadowsocks;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.socket.DatagramPacket;
import io.netty.handler.codec.MessageToMessageCodec;
import io.netty.handler.codec.socks.SocksAddressType;
import lombok.extern.slf4j.Slf4j;
import org.rx.io.Bytes;
import org.rx.net.Sockets;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetSocketAddress;
import java.util.List;
/**
* https://www.shadowsocks.org/en/spec/Protocol.html
* [1-byte type][variable-length host][2-byte port]
* The following address types are defined:
*
* 0x01: host is a 4-byte IPv4 address.
* 0x03: host is a variable length string, starting with a 1-byte length, followed by up to 255-byte domain name.
* 0x04: host is a 16-byte IPv6 address.
* The port number is a 2-byte big-endian unsigned integer.
**/
@Slf4j
public class ProtocolCodec extends MessageToMessageCodec