io.netty.handler.codec.socksx.v5.DefaultSocks5InitialRequest Java Examples
The following examples show how to use
io.netty.handler.codec.socksx.v5.DefaultSocks5InitialRequest.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProxyClientIntegrationTest.java From armeria with Apache License 2.0 | 6 votes |
@Override protected void channelRead0(ChannelHandlerContext ctx, Socks5Message msg) throws Exception { if (msg instanceof DefaultSocks5InitialRequest) { ctx.pipeline().addBefore(ctx.name(), Socks5CommandRequestDecoder.class.getName(), new Socks5CommandRequestDecoder()); ctx.writeAndFlush(new DefaultSocks5InitialResponse(Socks5AuthMethod.NO_AUTH)); } else if (msg instanceof DefaultSocks5CommandRequest) { final DefaultSocks5CommandRequest req = (DefaultSocks5CommandRequest) msg; ctx.pipeline().remove(Socks5CommandRequestDecoder.class); ctx.fireUserEventTriggered(new ProxySuccessEvent( new InetSocketAddress(req.dstAddr(), req.dstPort()), new DefaultSocks5CommandResponse(Socks5CommandStatus.SUCCESS, Socks5AddressType.IPv4))); } else { throw new IllegalStateException("unexpected msg: " + msg); } }
Example #2
Source File: ProxyToServerConnection.java From PowerTunnel with MIT License | 5 votes |
@Override protected Future<?> execute() { List<Socks5AuthMethod> authMethods = new ArrayList<>(2); authMethods.add(Socks5AuthMethod.NO_AUTH); if ((username != null) || (password != null)) { authMethods.add(Socks5AuthMethod.PASSWORD); } DefaultSocks5InitialRequest initialRequest = new DefaultSocks5InitialRequest(authMethods); addFirstOrReplaceHandler(SOCKS_ENCODER_NAME, Socks5ClientEncoder.DEFAULT); addFirstOrReplaceHandler(SOCKS_DECODER_NAME, new Socks5InitialResponseDecoder()); return writeToChannel(initialRequest); }