Esempio n. 1
0
 @Override
 public org.eclipse.jetty.io.Connection newConnection(
     EndPoint endPoint, Map<String, Object> context) throws IOException {
   @SuppressWarnings("unchecked")
   Promise<Connection> promise =
       (Promise<Connection>)
           context.get(HttpClientTransport.HTTP_CONNECTION_PROMISE_CONTEXT_KEY);
   final ProxyPromise proxyPromise = new ProxyPromise(endPoint, promise, context);
   // Replace the promise with the proxy one
   context.put(HttpClientTransport.HTTP_CONNECTION_PROMISE_CONTEXT_KEY, proxyPromise);
   return connectionFactory.newConnection(endPoint, context);
 }
Esempio n. 2
0
 private void tunnelSucceeded() {
   try {
     // Replace the promise back with the original
     context.put(HttpClientTransport.HTTP_CONNECTION_PROMISE_CONTEXT_KEY, promise);
     HttpDestination destination =
         (HttpDestination) context.get(HttpClientTransport.HTTP_DESTINATION_CONTEXT_KEY);
     HttpClient client = destination.getHttpClient();
     ClientConnectionFactory sslConnectionFactory =
         new SslClientConnectionFactory(
             client.getSslContextFactory(),
             client.getByteBufferPool(),
             client.getExecutor(),
             connectionFactory);
     org.eclipse.jetty.io.Connection oldConnection = endPoint.getConnection();
     org.eclipse.jetty.io.Connection newConnection =
         sslConnectionFactory.newConnection(endPoint, context);
     Helper.replaceConnection(oldConnection, newConnection);
     LOG.debug("HTTP tunnel established: {} over {}", oldConnection, newConnection);
   } catch (Throwable x) {
     tunnelFailed(x);
   }
 }
Esempio n. 3
0
 private void tunnel() {
   try {
     HttpDestination destination =
         (HttpDestination) context.get(HttpClientTransport.HTTP_DESTINATION_CONTEXT_KEY);
     HttpClient client = destination.getHttpClient();
     ClientConnectionFactory connectionFactory = this.connectionFactory;
     if (destination.isSecure())
       connectionFactory =
           new SslClientConnectionFactory(
               client.getSslContextFactory(),
               client.getByteBufferPool(),
               client.getExecutor(),
               connectionFactory);
     org.eclipse.jetty.io.Connection newConnection =
         connectionFactory.newConnection(getEndPoint(), context);
     getEndPoint().upgrade(newConnection);
     if (LOG.isDebugEnabled())
       LOG.debug("SOCKS4 tunnel established: {} over {}", this, newConnection);
   } catch (Throwable x) {
     failed(x);
   }
 }