buf = encodeInitialGreetingPacket(request); } else if (step == SocksProxyConstants.SOCKS5_AUTH_STEP) { buf = encodeAuthenticationPacket(request); buf = encodeProxyRequestPacket(request); writeData(nextFilter, buf); closeSession("Unable to send Socks request: ", ex);
/** * Handles incoming data during the handshake process. Should consume only the * handshake data from the buffer, leaving any extra data in place. * * @param nextFilter the next filter * @param buf the buffered data received */ @Override public synchronized void messageReceived(final NextFilter nextFilter, final IoBuffer buf) { try { int step = ((Integer) getSession().getAttribute(HANDSHAKE_STEP)).intValue(); if (step == SocksProxyConstants.SOCKS5_GREETING_STEP && buf.get(0) != SocksProxyConstants.SOCKS_VERSION_5) { throw new IllegalStateException("Wrong socks version running on server"); } if ((step == SocksProxyConstants.SOCKS5_GREETING_STEP || step == SocksProxyConstants.SOCKS5_AUTH_STEP) && buf.remaining() >= 2) { handleResponse(nextFilter, buf, step); } else if (step == SocksProxyConstants.SOCKS5_REQUEST_STEP && buf.remaining() >= 5) { handleResponse(nextFilter, buf, step); } } catch (Exception ex) { closeSession("Proxy handshake failed: ", ex); } }
/** * Performs the handshake process. * * @param nextFilter the next filter */ @Override public synchronized void doHandshake(final NextFilter nextFilter) { LOGGER.debug(" doHandshake()"); // Send request writeRequest(nextFilter, request, ((Integer) getSession().getAttribute(HANDSHAKE_STEP)).intValue()); }
getSession().setAttribute(SELECTED_AUTH_METHOD, Byte.valueOf(method)); byte method = ((Byte) getSession().getAttribute(Socks5LogicHandler.SELECTED_AUTH_METHOD)).byteValue(); byte[] token = new byte[s]; buf.get(token); getSession().setAttribute(GSS_TOKEN, token); len = 0; } else { setHandshakeComplete(); return; byte method = ((Byte) getSession().getAttribute(Socks5LogicHandler.SELECTED_AUTH_METHOD)).byteValue(); if (method == SocksProxyConstants.GSSAPI_AUTH) { GSSContext ctx = (GSSContext) getSession().getAttribute(GSS_CONTEXT); if (ctx == null || !ctx.isEstablished()) { isAuthenticating = true; getSession().setAttribute(HANDSHAKE_STEP, ++step); doHandshake(nextFilter);
byte method = ((Byte) getSession().getAttribute(Socks5LogicHandler.SELECTED_AUTH_METHOD)).byteValue(); getSession().setAttribute(HANDSHAKE_STEP, SocksProxyConstants.SOCKS5_REQUEST_STEP); break; return encodeGSSAPIAuthenticationPacket(request);
/** * @see AbstractSocksLogicHandler#AbstractSocksLogicHandler(ProxyIoSession) * * @param proxyIoSession The original session */ public Socks5LogicHandler(final ProxyIoSession proxyIoSession) { super(proxyIoSession); getSession().setAttribute(HANDSHAKE_STEP, SocksProxyConstants.SOCKS5_GREETING_STEP); }
handler = new Socks4LogicHandler(proxyIoSession); } else { handler = new Socks5LogicHandler(proxyIoSession);
getSession().setAttribute(SELECTED_AUTH_METHOD, Byte.valueOf(method)); byte method = ((Byte) getSession().getAttribute(Socks5LogicHandler.SELECTED_AUTH_METHOD)).byteValue(); byte[] token = new byte[s]; buf.get(token); getSession().setAttribute(GSS_TOKEN, token); len = 0; } else { setHandshakeComplete(); return; byte method = ((Byte) getSession().getAttribute(Socks5LogicHandler.SELECTED_AUTH_METHOD)).byteValue(); if (method == SocksProxyConstants.GSSAPI_AUTH) { GSSContext ctx = (GSSContext) getSession().getAttribute(GSS_CONTEXT); if (ctx == null || !ctx.isEstablished()) { isAuthenticating = true; getSession().setAttribute(HANDSHAKE_STEP, ++step); doHandshake(nextFilter);
/** * Performs the handshake process. * * @param nextFilter the next filter */ public synchronized void doHandshake(final NextFilter nextFilter) { LOGGER.debug(" doHandshake()"); // Send request writeRequest(nextFilter, request, (Integer) getSession().getAttribute( HANDSHAKE_STEP)); }
byte method = ((Byte) getSession().getAttribute(Socks5LogicHandler.SELECTED_AUTH_METHOD)).byteValue(); getSession().setAttribute(HANDSHAKE_STEP, SocksProxyConstants.SOCKS5_REQUEST_STEP); break; return encodeGSSAPIAuthenticationPacket(request);
/** * @see AbstractSocksLogicHandler#AbstractSocksLogicHandler(ProxyIoSession) * * @param proxyIoSession The original session */ public Socks5LogicHandler(final ProxyIoSession proxyIoSession) { super(proxyIoSession); getSession().setAttribute(HANDSHAKE_STEP, SocksProxyConstants.SOCKS5_GREETING_STEP); }
handler = new Socks4LogicHandler(proxyIoSession); } else { handler = new Socks5LogicHandler(proxyIoSession);
buf = encodeInitialGreetingPacket(request); } else if (step == SocksProxyConstants.SOCKS5_AUTH_STEP) { buf = encodeAuthenticationPacket(request); buf = encodeProxyRequestPacket(request); writeData(nextFilter, buf); closeSession("Unable to send Socks request: ", ex);
/** * Handles incoming data during the handshake process. Should consume only the * handshake data from the buffer, leaving any extra data in place. * * @param nextFilter the next filter * @param buf the buffered data received */ @Override public synchronized void messageReceived(final NextFilter nextFilter, final IoBuffer buf) { try { int step = ((Integer) getSession().getAttribute(HANDSHAKE_STEP)).intValue(); if (step == SocksProxyConstants.SOCKS5_GREETING_STEP && buf.get(0) != SocksProxyConstants.SOCKS_VERSION_5) { throw new IllegalStateException("Wrong socks version running on server"); } if ((step == SocksProxyConstants.SOCKS5_GREETING_STEP || step == SocksProxyConstants.SOCKS5_AUTH_STEP) && buf.remaining() >= 2) { handleResponse(nextFilter, buf, step); } else if (step == SocksProxyConstants.SOCKS5_REQUEST_STEP && buf.remaining() >= 5) { handleResponse(nextFilter, buf, step); } } catch (Exception ex) { closeSession("Proxy handshake failed: ", ex); } }
getSession().setAttribute(SELECTED_AUTH_METHOD, method); byte method = (Byte) getSession().getAttribute( Socks5LogicHandler.SELECTED_AUTH_METHOD); byte[] token = new byte[s]; buf.get(token); getSession().setAttribute(GSS_TOKEN, token); len = 0; } else { setHandshakeComplete(); return; byte method = (Byte) getSession().getAttribute( Socks5LogicHandler.SELECTED_AUTH_METHOD); if (method == SocksProxyConstants.GSSAPI_AUTH) { GSSContext ctx = (GSSContext) getSession().getAttribute( GSS_CONTEXT); if (ctx == null || !ctx.isEstablished()) { getSession().setAttribute(HANDSHAKE_STEP, ++step); doHandshake(nextFilter);
/** * Performs the handshake process. * * @param nextFilter the next filter */ @Override public synchronized void doHandshake(final NextFilter nextFilter) { LOGGER.debug(" doHandshake()"); // Send request writeRequest(nextFilter, request, ((Integer) getSession().getAttribute(HANDSHAKE_STEP)).intValue()); }
byte method = (Byte) getSession().getAttribute( Socks5LogicHandler.SELECTED_AUTH_METHOD); getSession().setAttribute(HANDSHAKE_STEP, SocksProxyConstants.SOCKS5_REQUEST_STEP); break; return encodeGSSAPIAuthenticationPacket(request);
/** * {@inheritDoc} */ public Socks5LogicHandler(final ProxyIoSession proxyIoSession) { super(proxyIoSession); getSession().setAttribute(HANDSHAKE_STEP, SocksProxyConstants.SOCKS5_GREETING_STEP); }
handler = new Socks4LogicHandler(proxyIoSession); } else { handler = new Socks5LogicHandler(proxyIoSession);
buf = encodeInitialGreetingPacket(request); } else if (step == SocksProxyConstants.SOCKS5_AUTH_STEP) { buf = encodeAuthenticationPacket(request); buf = encodeProxyRequestPacket(request); writeData(nextFilter, buf); closeSession("Unable to send Socks request: ", ex);