Home / Class/ Socks5CommandRequestDecoderTest Class — netty Architecture

Socks5CommandRequestDecoderTest Class — netty Architecture

Architecture documentation for the Socks5CommandRequestDecoderTest class in Socks5CommandRequestDecoderTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  c1fe2676_ad04_03d5_49da_b916e772c7ab["Socks5CommandRequestDecoderTest"]
  b4aec41f_c752_c5e8_495e_edd79f4affff["Socks5CommandRequestDecoderTest.java"]
  c1fe2676_ad04_03d5_49da_b916e772c7ab -->|defined in| b4aec41f_c752_c5e8_495e_edd79f4affff
  f1cb7c8e_8115_47d0_8e85_39e49c6ce71b["test()"]
  c1fe2676_ad04_03d5_49da_b916e772c7ab -->|method| f1cb7c8e_8115_47d0_8e85_39e49c6ce71b
  3fe90d58_74d5_1efc_0b1c_319582f3d5e3["testCmdRequestDecoderIPv4()"]
  c1fe2676_ad04_03d5_49da_b916e772c7ab -->|method| 3fe90d58_74d5_1efc_0b1c_319582f3d5e3
  8bc3fa11_123c_7199_2e4c_5bbec4673861["testCmdRequestDecoderIPv6()"]
  c1fe2676_ad04_03d5_49da_b916e772c7ab -->|method| 8bc3fa11_123c_7199_2e4c_5bbec4673861
  51194caa_1e61_2f04_4deb_122e92748b64["testCmdRequestDecoderDomain()"]
  c1fe2676_ad04_03d5_49da_b916e772c7ab -->|method| 51194caa_1e61_2f04_4deb_122e92748b64

Relationship Graph

Source Code

codec-socks/src/test/java/io/netty/handler/codec/socksx/v5/Socks5CommandRequestDecoderTest.java lines 33–111

public class Socks5CommandRequestDecoderTest {
    private static final InternalLogger logger =
            InternalLoggerFactory.getInstance(Socks5CommandRequestDecoderTest.class);

    private static void test(
            Socks5CommandType type, Socks5AddressType dstAddrType, String dstAddr, int dstPort) {
        logger.debug(
                "Testing type: " + type + " dstAddrType: " + dstAddrType +
                " dstAddr: " + dstAddr + " dstPort: " + dstPort);

        Socks5CommandRequest msg =
                new DefaultSocks5CommandRequest(type, dstAddrType, dstAddr, dstPort);
        EmbeddedChannel embedder = new EmbeddedChannel(new Socks5CommandRequestDecoder());
        Socks5CommonTestUtils.writeFromClientToServer(embedder, msg);
        msg = embedder.readInbound();
        assertSame(msg.type(), type);
        assertSame(msg.dstAddrType(), dstAddrType);
        assertEquals(msg.dstAddr(), IDN.toASCII(dstAddr));
        assertEquals(msg.dstPort(), dstPort);
        assertNull(embedder.readInbound());
    }

    @Test
    public void testCmdRequestDecoderIPv4() {
        String[] hosts = {"127.0.0.1", };
        int[] ports = {1, 32769, 65535 };
        for (Socks5CommandType cmdType: Arrays.asList(Socks5CommandType.BIND,
                                                      Socks5CommandType.CONNECT,
                                                      Socks5CommandType.UDP_ASSOCIATE)) {
            for (String host : hosts) {
                for (int port : ports) {
                    test(cmdType, Socks5AddressType.IPv4, host, port);
                }
            }
        }
    }

    @Test
    public void testCmdRequestDecoderIPv6() throws UnknownHostException {
        String[] hosts = {
                NetUtil.bytesToIpAddress(SocketUtils.addressByName("::1").getAddress()) };
        int[] ports = {1, 32769, 65535};
        for (Socks5CommandType cmdType: Arrays.asList(Socks5CommandType.BIND,
                                                      Socks5CommandType.CONNECT,
                                                      Socks5CommandType.UDP_ASSOCIATE)) {
            for (String host : hosts) {
                for (int port : ports) {
                    test(cmdType, Socks5AddressType.IPv6, host, port);
                }
            }
        }
    }

    @Test
    public void testCmdRequestDecoderDomain() {
        String[] hosts = {"google.com" ,
                          "مثال.إختبار",
                          "παράδειγμα.δοκιμή",
                          "مثال.آزمایشی",
                          "пример.испытание",
                          "בײַשפּיל.טעסט",
                          "例子.测试",
                          "例子.測試",
                          "उदाहरण.परीक्षा",
                          "例え.テスト",
                          "실례.테스트",
                          "உதாரணம்.பரிட்சை"};
        int[] ports = {1, 32769, 65535};
        for (Socks5CommandType cmdType: Arrays.asList(Socks5CommandType.BIND,
                                                      Socks5CommandType.CONNECT,
                                                      Socks5CommandType.UDP_ASSOCIATE)) {
            for (String host : hosts) {
                for (int port : ports) {
                    test(cmdType, Socks5AddressType.DOMAIN, host, port);
                }
            }
        }
    }
}

Frequently Asked Questions

What is the Socks5CommandRequestDecoderTest class?
Socks5CommandRequestDecoderTest is a class in the netty codebase, defined in codec-socks/src/test/java/io/netty/handler/codec/socksx/v5/Socks5CommandRequestDecoderTest.java.
Where is Socks5CommandRequestDecoderTest defined?
Socks5CommandRequestDecoderTest is defined in codec-socks/src/test/java/io/netty/handler/codec/socksx/v5/Socks5CommandRequestDecoderTest.java at line 33.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free