Home / Class/ ProxyServer Class — netty Architecture

ProxyServer Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  8191386f_3cbb_1cbe_52f4_e98d4cb46d64["ProxyServer"]
  db43fe47_37b6_43cd_123c_8899d4fb6e75["ProxyServer.java"]
  8191386f_3cbb_1cbe_52f4_e98d4cb46d64 -->|defined in| db43fe47_37b6_43cd_123c_8899d4fb6e75
  2dcda6c3_4c0d_61b2_a17a_d1598005b3bc["ProxyServer()"]
  8191386f_3cbb_1cbe_52f4_e98d4cb46d64 -->|method| 2dcda6c3_4c0d_61b2_a17a_d1598005b3bc
  82e14154_53f4_492e_0dc8_1b7895a2de18["InetSocketAddress()"]
  8191386f_3cbb_1cbe_52f4_e98d4cb46d64 -->|method| 82e14154_53f4_492e_0dc8_1b7895a2de18
  12833ba2_733f_1108_42ed_f4f4fb1c1db1["configure()"]
  8191386f_3cbb_1cbe_52f4_e98d4cb46d64 -->|method| 12833ba2_733f_1108_42ed_f4f4fb1c1db1
  062e6ca1_88ba_0b80_9896_af72582faf86["recordException()"]
  8191386f_3cbb_1cbe_52f4_e98d4cb46d64 -->|method| 062e6ca1_88ba_0b80_9896_af72582faf86
  f8f010a9_19cb_d279_af4f_a2d971595e76["clearExceptions()"]
  8191386f_3cbb_1cbe_52f4_e98d4cb46d64 -->|method| f8f010a9_19cb_d279_af4f_a2d971595e76
  686ac6e4_a088_5397_64bc_88c0f1256778["checkExceptions()"]
  8191386f_3cbb_1cbe_52f4_e98d4cb46d64 -->|method| 686ac6e4_a088_5397_64bc_88c0f1256778
  8c591949_6ca9_7351_45fb_f2048a2b3eed["stop()"]
  8191386f_3cbb_1cbe_52f4_e98d4cb46d64 -->|method| 8c591949_6ca9_7351_45fb_f2048a2b3eed

Relationship Graph

Source Code

handler-proxy/src/test/java/io/netty/handler/proxy/ProxyServer.java lines 50–303

abstract class ProxyServer {

    protected final InternalLogger logger = InternalLoggerFactory.getInstance(getClass());

    private final ServerSocketChannel ch;
    private final Queue<Throwable> recordedExceptions = new LinkedBlockingQueue<Throwable>();
    protected final TestMode testMode;
    protected final String username;
    protected final String password;
    protected final InetSocketAddress destination;

    /**
     * Starts a new proxy server with disabled authentication for testing purpose.
     *
     * @param useSsl {@code true} if and only if implicit SSL is enabled
     * @param testMode the test mode
     * @param destination the expected destination. If the client requests proxying to a different destination, this
     * server will reject the connection request.
     */
    protected ProxyServer(boolean useSsl, TestMode testMode, InetSocketAddress destination) {
        this(useSsl, testMode, destination, null, null);
    }

    /**
     * Starts a new proxy server with disabled authentication for testing purpose.
     *
     * @param useSsl {@code true} if and only if implicit SSL is enabled
     * @param testMode the test mode
     * @param username the expected username. If the client tries to authenticate with a different username, this server
     * will fail the authentication request.
     * @param password the expected password. If the client tries to authenticate with a different password, this server
     * will fail the authentication request.
     * @param destination the expected destination. If the client requests proxying to a different destination, this
     * server will reject the connection request.
     */
    protected ProxyServer(
            final boolean useSsl, TestMode testMode,
            InetSocketAddress destination, String username, String password) {

        this.testMode = testMode;
        this.destination = destination;
        this.username = username;
        this.password = password;

        ServerBootstrap b = new ServerBootstrap();
        b.channel(NioServerSocketChannel.class);
        b.group(ProxyHandlerTest.group);
        b.childHandler(new ChannelInitializer<SocketChannel>() {
            @Override
            protected void initChannel(SocketChannel ch) throws Exception {
                ChannelPipeline p = ch.pipeline();
                if (useSsl) {
                    p.addLast(ProxyHandlerTest.serverSslCtx.newHandler(ch.alloc()));
                }

                configure(ch);
            }
        });

        ch = (ServerSocketChannel) b.bind(NetUtil.LOCALHOST, 0).syncUninterruptibly().channel();
    }

    public final InetSocketAddress address() {
        return new InetSocketAddress(NetUtil.LOCALHOST, ch.localAddress().getPort());
    }

    protected abstract void configure(SocketChannel ch) throws Exception;

    final void recordException(Throwable t) {
        logger.warn("Unexpected exception from proxy server:", t);
        recordedExceptions.add(t);
    }

    /**
     * Clears all recorded exceptions.
     */
    public final void clearExceptions() {
        recordedExceptions.clear();
    }

    /**

Frequently Asked Questions

What is the ProxyServer class?
ProxyServer is a class in the netty codebase, defined in handler-proxy/src/test/java/io/netty/handler/proxy/ProxyServer.java.
Where is ProxyServer defined?
ProxyServer is defined in handler-proxy/src/test/java/io/netty/handler/proxy/ProxyServer.java at line 50.

Analyze Your Own Codebase

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

Try Supermodel Free