/** * Closes the session. * * @param message the error message */ protected void closeSession(final String message) { closeSession(message, null); }
/** * Creates a new proxy connector. * * @param connector The Connector used to establish proxy connections. * @param config The session confiugarion to use * @param executor The associated executor */ public ProxyConnector(final SocketConnector connector, IoSessionConfig config, Executor executor) { super(config, executor); setConnector(connector); }
/** * {@inheritDoc} */ @Override public void handleResponse(final HttpProxyResponse response) throws ProxyAuthException { // Should never get here ! throw new ProxyAuthException("Received error response code (" + response.getStatusLine() + ")."); } }
/** * Signals that the handshake has finished. */ protected final void setHandshakeComplete() { synchronized (this) { handshakeComplete = true; } ProxyIoSession proxyIoSession = getProxyIoSession(); proxyIoSession.getConnector().fireConnected(proxyIoSession.getSession()).awaitUninterruptibly(); LOGGER.debug(" handshake completed"); // Connected OK try { proxyIoSession.getEventQueue().flushPendingSessionEvents(); flushPendingWriteRequests(); } catch (Exception ex) { LOGGER.error("Unable to flush pending write requests", ex); } }
/** * Hooked session opened event. * * @param session the io session */ @Override public final void sessionOpened(IoSession session) throws Exception { ProxyIoSession proxyIoSession = (ProxyIoSession) session.getAttribute(ProxyIoSession.PROXY_SESSION); if (proxyIoSession.getRequest() instanceof SocksProxyRequest || proxyIoSession.isAuthenticationFailed() || proxyIoSession.getHandler().isHandshakeComplete()) { proxySessionOpened(session); } else { logger.debug("Filtered session opened event !"); } } }
/** * {@inheritDoc} */ @Override public void handleResponse(final HttpProxyResponse response) throws ProxyAuthException { if (response.getStatusCode() != 407) { throw new ProxyAuthException("Received error response code (" + response.getStatusLine() + ")."); } } }
/** * Sets the proxy session object of this connector. * @param proxyIoSession the configuration of this connector. */ public void setProxyIoSession(ProxyIoSession proxyIoSession) { if (proxyIoSession == null) { throw new IllegalArgumentException("proxySession object cannot be null"); } if (proxyIoSession.getProxyAddress() == null) { throw new IllegalArgumentException("proxySession.proxyAddress cannot be null"); } proxyIoSession.setConnector(this); setDefaultRemoteAddress(proxyIoSession.getProxyAddress()); this.proxyIoSession = proxyIoSession; }
/** * Enqueue a message to be written once handshaking is complete. */ public synchronized void enqueueWriteRequest(final NextFilter nextFilter, final WriteRequest writeRequest) { if (writeRequestQueue == null) { writeRequestQueue = new LinkedList<Event>(); } writeRequestQueue.offer(new Event(nextFilter, writeRequest)); }
/** * Hooked session opened event. * * @param session the io session */ @Override public final void sessionOpened(IoSession session) throws Exception { ProxyIoSession proxyIoSession = (ProxyIoSession) session.getAttribute(ProxyIoSession.PROXY_SESSION); if (proxyIoSession.getRequest() instanceof SocksProxyRequest || proxyIoSession.isAuthenticationFailed() || proxyIoSession.getHandler().isHandshakeComplete()) { proxySessionOpened(session); } else { logger.debug("Filtered session opened event !"); } } }
/** * {@inheritDoc} */ @Override public void handleResponse(final HttpProxyResponse response) throws ProxyAuthException { if (response.getStatusCode() != 407) { throw new ProxyAuthException("Received error response code (" + response.getStatusLine() + ")."); } } }
/** * {@inheritDoc} */ @Override public void handleResponse(final HttpProxyResponse response) throws ProxyAuthException { // Should never get here ! throw new ProxyAuthException("Received error response code (" + response.getStatusLine() + ")."); } }
/** * Closes the session. * * @param message the error message */ protected void closeSession(final String message) { closeSession(message, null); }
/** * Creates a new proxy connector. * @see AbstractIoConnector(IoSessionConfig, Executor). */ public ProxyConnector(final SocketConnector connector, IoSessionConfig config, Executor executor) { super(config, executor); setConnector(connector); }
/** * Enqueue a message to be written once handshaking is complete. */ public synchronized void enqueueWriteRequest(final NextFilter nextFilter, final WriteRequest writeRequest) { if (writeRequestQueue == null) { writeRequestQueue = new LinkedList<Event>(); } writeRequestQueue.offer(new Event(nextFilter, writeRequest)); }
/** * Hooked session opened event. * * @param session the io session */ @Override public final void sessionOpened(IoSession session) throws Exception { ProxyIoSession proxyIoSession = (ProxyIoSession) session .getAttribute(ProxyIoSession.PROXY_SESSION); if (proxyIoSession.getRequest() instanceof SocksProxyRequest || proxyIoSession.isAuthenticationFailed() || proxyIoSession.getHandler().isHandshakeComplete()) { proxySessionOpened(session); } else { logger.debug("Filtered session opened event !"); } } }
/** * {@inheritDoc} */ @Override public void handleResponse(final HttpProxyResponse response) throws ProxyAuthException { if (response.getStatusCode() != 407) { throw new ProxyAuthException("Received error response code (" + response.getStatusLine() + ")."); } } }
/** * {@inheritDoc} */ @Override public void handleResponse(final HttpProxyResponse response) throws ProxyAuthException { // Should never get here ! throw new ProxyAuthException("Received error response code (" + response.getStatusLine() + ")."); } }
/** * Closes the session. * * @param message the error message */ protected void closeSession(final String message) { closeSession(message, null); }
/** * Creates a new proxy connector. * * @param connector The Connector used to establish proxy connections. * @param config The session confiugarion to use * @param executor The associated executor */ public ProxyConnector(final SocketConnector connector, IoSessionConfig config, Executor executor) { super(config, executor); setConnector(connector); }
/** * Enqueue a message to be written once handshaking is complete. */ public synchronized void enqueueWriteRequest(final NextFilter nextFilter, final WriteRequest writeRequest) { if (writeRequestQueue == null) { writeRequestQueue = new LinkedList<>(); } writeRequestQueue.offer(new Event(nextFilter, writeRequest)); }