/** * Return the server port as a byte array. * * @return the server port */ public byte[] getPort() { byte[] port = new byte[2]; int p = (getEndpointAddress() == null ? this.port : getEndpointAddress().getPort()); port[1] = (byte) p; port[0] = (byte) (p >> 8); return port; }
/** * Perform the handshake. * * @param nextFilter the next filter */ @Override public void doHandshake(final NextFilter nextFilter) { logger.debug(" doHandshake()"); // Send request writeRequest(nextFilter, request); }
/** * Handle 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 server response data buffer */ @Override public void messageReceived(final NextFilter nextFilter, final IoBuffer buf) { try { if (buf.remaining() >= SocksProxyConstants.SOCKS_4_RESPONSE_SIZE) { handleResponse(buf); } } catch (Exception ex) { closeSession("Proxy handshake failed: ", ex); } }
/** * 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)); }
/** * @see AbstractSocksLogicHandler#AbstractSocksLogicHandler(ProxyIoSession) * * @param proxyIoSession The original session */ public Socks5LogicHandler(final ProxyIoSession proxyIoSession) { super(proxyIoSession); getSession().setAttribute(HANDSHAKE_STEP, SocksProxyConstants.SOCKS5_GREETING_STEP); }
/** * Encodes the initial greeting packet. * * @param request the socks proxy request data * @return the encoded buffer */ private IoBuffer encodeInitialGreetingPacket(final SocksProxyRequest request) { byte nbMethods = (byte) SocksProxyConstants.SUPPORTED_AUTH_METHODS.length; IoBuffer buf = IoBuffer.allocate(2 + nbMethods); buf.put(request.getProtocolVersion()); buf.put(nbMethods); buf.put(SocksProxyConstants.SUPPORTED_AUTH_METHODS); return buf; }
/** * Return the server port as a byte array. * * @return the server port */ public byte[] getPort() { byte[] port = new byte[2]; int p = (getEndpointAddress() == null ? this.port : getEndpointAddress().getPort()); port[1] = (byte) p; port[0] = (byte) (p >> 8); return port; }
/** * Handle 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 server response data buffer */ public void messageReceived(final NextFilter nextFilter, final IoBuffer buf) { try { if (buf.remaining() >= SocksProxyConstants.SOCKS_4_RESPONSE_SIZE) { handleResponse(buf); } } catch (Exception ex) { closeSession("Proxy handshake failed: ", ex); } }
/** * Perform the handshake. * * @param nextFilter the next filter */ @Override public void doHandshake(final NextFilter nextFilter) { logger.debug(" doHandshake()"); // Send request writeRequest(nextFilter, 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); }
/** * Encodes the initial greeting packet. * * @param request the socks proxy request data * @return the encoded buffer */ private IoBuffer encodeInitialGreetingPacket(final SocksProxyRequest request) { byte nbMethods = (byte) SocksProxyConstants.SUPPORTED_AUTH_METHODS.length; IoBuffer buf = IoBuffer.allocate(2 + nbMethods); buf.put(request.getProtocolVersion()); buf.put(nbMethods); buf.put(SocksProxyConstants.SUPPORTED_AUTH_METHODS); return buf; }
/** * Return the server port as a byte array. * * @return the server port */ public byte[] getPort() { byte[] port = new byte[2]; int p = (getEndpointAddress() == null ? this.port : getEndpointAddress().getPort()); port[1] = (byte) p; port[0] = (byte) (p >> 8); return port; }
/** * Perform the handshake. * * @param nextFilter the next filter */ public void doHandshake(final NextFilter nextFilter) { logger.debug(" doHandshake()"); // Send request writeRequest(nextFilter, request); }
/** * {@inheritDoc} */ public Socks5LogicHandler(final ProxyIoSession proxyIoSession) { super(proxyIoSession); getSession().setAttribute(HANDSHAKE_STEP, SocksProxyConstants.SOCKS5_GREETING_STEP); }
/** * Encodes the initial greeting packet. * * @param request the socks proxy request data * @return the encoded buffer */ private IoBuffer encodeInitialGreetingPacket(final SocksProxyRequest request) { byte nbMethods = (byte) SocksProxyConstants.SUPPORTED_AUTH_METHODS.length; IoBuffer buf = IoBuffer.allocate(2 + nbMethods); buf.put(request.getProtocolVersion()); buf.put(nbMethods); buf.put(SocksProxyConstants.SUPPORTED_AUTH_METHODS); return buf; }
/** * Return the server host name. * * @return the server host name */ public synchronized final String getHost() { if (host == null) { InetSocketAddress adr = getEndpointAddress(); if (adr != null && !adr.isUnresolved()) { host = getEndpointAddress().getHostName(); } } return host; }
/** * Return the server host name. * * @return the server host name */ public synchronized final String getHost() { if (host == null) { InetSocketAddress adr = getEndpointAddress(); if ( adr != null && !adr.isUnresolved()) { host = getEndpointAddress().getHostName(); } } return host; }
/** * Return the server host name. * * @return the server host name */ public synchronized final String getHost() { if (host == null) { InetSocketAddress adr = getEndpointAddress(); if (adr != null && !adr.isUnresolved()) { host = getEndpointAddress().getHostName(); } } return host; }
/** * @return the endpoint address resulting from the {@link #getEndpointAddress()}. * If not set, it will return the {@link SocksProxyConstants#FAKE_IP} constant * value which will be ignored in a SOCKS v4 request. */ public byte[] getIpAddress() { if (getEndpointAddress() == null) { return SocksProxyConstants.FAKE_IP; } return getEndpointAddress().getAddress().getAddress(); }
/** * @return the endpoint address resulting from the {@link #getEndpointAddress()}. * If not set, it will return the {@link SocksProxyConstants#FAKE_IP} constant * value which will be ignored in a SOCKS v4 request. */ public byte[] getIpAddress() { if (getEndpointAddress() == null) { return SocksProxyConstants.FAKE_IP; } return getEndpointAddress().getAddress().getAddress(); }