当前位置: 首页>>代码示例>>Java>>正文


Java ProxyHandler类代码示例

本文整理汇总了Java中io.netty.handler.proxy.ProxyHandler的典型用法代码示例。如果您正苦于以下问题:Java ProxyHandler类的具体用法?Java ProxyHandler怎么用?Java ProxyHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ProxyHandler类属于io.netty.handler.proxy包,在下文中一共展示了ProxyHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: newProxyHandler

import io.netty.handler.proxy.ProxyHandler; //导入依赖的package包/类
/**
 * Return a new eventual {@link ProxyHandler}
 *
 * @return a new eventual {@link ProxyHandler}
 */
public final ProxyHandler newProxyHandler() {
	InetSocketAddress proxyAddr = this.address.get();
	String username = this.username;
	String password = Objects.nonNull(username) && Objects.nonNull(this.password) ?
			this.password.apply(username) : null;

	switch (this.type) {
		case HTTP:
			return Objects.nonNull(username) && Objects.nonNull(password) ?
					new HttpProxyHandler(proxyAddr, username, password) :
					new HttpProxyHandler(proxyAddr);
		case SOCKS4:
			return Objects.nonNull(username) ? new Socks4ProxyHandler(proxyAddr, username) :
					new Socks4ProxyHandler(proxyAddr);
		case SOCKS5:
			return Objects.nonNull(username) && Objects.nonNull(password) ?
					new Socks5ProxyHandler(proxyAddr, username, password) :
					new Socks5ProxyHandler(proxyAddr);
	}
	throw new IllegalArgumentException("Proxy type unsupported : " + this.type);
}
 
开发者ID:reactor,项目名称:reactor-netty,代码行数:27,代码来源:ClientProxyOptions.java

示例2: initBootStrap

import io.netty.handler.proxy.ProxyHandler; //导入依赖的package包/类
protected Bootstrap initBootStrap(Promise<Channel> promise, EventLoopGroup eventLoopGroup) {
    return new Bootstrap()
            .group(eventLoopGroup)
            .channel(NioSocketChannel.class)
            .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, NettySettings.CONNECT_TIMEOUT)
            .option(ChannelOption.SO_KEEPALIVE, true)
            .handler(new ChannelInitializer<SocketChannel>() {
                @Override
                protected void initChannel(SocketChannel ch) {
                    ProxyHandler proxyHandler = proxyHandlerSupplier.get();
                    if (proxyHandler != null) {
                        ch.pipeline().addLast(proxyHandler);
                    }
                    ch.pipeline().addLast(new ChannelActiveAwareHandler(promise));
                }
            });
}
 
开发者ID:hsiafan,项目名称:byproxy,代码行数:18,代码来源:TunnelProxyHandler.java

示例3: newProxyHandler

import io.netty.handler.proxy.ProxyHandler; //导入依赖的package包/类
public ProxyHandler newProxyHandler() {
    switch (proxySetting.getType()) {
        case ProxySetting.TYPE_HTTP:
            if (proxySetting.getUser().isEmpty()) {
                return new HttpProxyHandler(address);
            } else {
                return new HttpProxyHandler(address, proxySetting.getUser(), proxySetting.getPassword());
            }

        case ProxySetting.TYPE_SOCKS5:
            if (proxySetting.getUser().isEmpty()) {
                return new Socks5ProxyHandler(address);
            } else {
                return new Socks5ProxyHandler(address, proxySetting.getUser(), proxySetting.getPassword());
            }
        case ProxySetting.TYPE_SOCKS4:
            if (proxySetting.getUser().isEmpty()) {
                return new Socks4ProxyHandler(address);
            } else {
                return new Socks4ProxyHandler(address, proxySetting.getUser());
            }
        default:
            throw new RuntimeException("unknown proxy type: " + proxySetting.getType());
    }
}
 
开发者ID:hsiafan,项目名称:byproxy,代码行数:26,代码来源:ProxyHandlerSupplier.java

示例4: addProxyHandler

import io.netty.handler.proxy.ProxyHandler; //导入依赖的package包/类
static void addProxyHandler(ClientOptions clientOptions, ChannelPipeline pipeline, SocketAddress providedAddress) {
	ProxyHandler proxy = clientOptions.useProxy(providedAddress) ? clientOptions.getProxyOptions().newProxyHandler() : null;
	if (proxy != null) {
		pipeline.addFirst(NettyPipeline.ProxyHandler, proxy);
		if(log.isDebugEnabled()){
			pipeline.addFirst(new LoggingHandler("reactor.ipc.netty.proxy"));
		}
	}
}
 
开发者ID:reactor,项目名称:reactor-netty,代码行数:10,代码来源:ClientContextHandler.java

示例5: HttpTunnelProxyMatcher

import io.netty.handler.proxy.ProxyHandler; //导入依赖的package包/类
public HttpTunnelProxyMatcher(MessageListener messageListener,
                              ServerSSLContextManager sslContextManager,
                              Supplier<ProxyHandler> proxyHandlerSupplier) {
    this.messageListener = messageListener;
    this.sslContextManager = sslContextManager;
    this.proxyHandlerSupplier = proxyHandlerSupplier;
}
 
开发者ID:hsiafan,项目名称:byproxy,代码行数:8,代码来源:HttpTunnelProxyMatcher.java

示例6: get

import io.netty.handler.proxy.ProxyHandler; //导入依赖的package包/类
@Override
public ProxyHandler get() {
    if (!proxySetting.isUse()) {
        return null;
    }
    ProxyHandler proxyHandler = newProxyHandler();
    proxyHandler.setConnectTimeoutMillis(NettySettings.CONNECT_TIMEOUT);
    return proxyHandler;
}
 
开发者ID:hsiafan,项目名称:byproxy,代码行数:10,代码来源:ProxyHandlerSupplier.java

示例7: handleProxyData

import io.netty.handler.proxy.ProxyHandler; //导入依赖的package包/类
private void handleProxyData(Channel channel, Object msg, boolean isHttp)
    throws Exception {
  if (cf == null) {
    if (isHttp && !(msg instanceof HttpRequest)) {  //connection异常 还有HttpContent进来,不转发
      return;
    }
    ProxyHandler proxyHandler = ProxyHandleFactory.build(proxyConfig);
    /*
      添加SSL client hello的Server Name Indication extension(SNI扩展)
      有些服务器对于client hello不带SNI扩展时会直接返回Received fatal alert: handshake_failure(握手错误)
      例如:https://cdn.mdn.mozilla.net/static/img/favicon32.7f3da72dcea1.png
     */
    RequestProto requestProto = new RequestProto(host, port, isSsl);
    ChannelInitializer channelInitializer =
        isHttp ? new HttpProxyInitializer(channel, requestProto, proxyHandler)
            : new TunnelProxyInitializer(channel, proxyHandler);
    Bootstrap bootstrap = new Bootstrap();
    bootstrap.group(serverConfig.getLoopGroup()) // 注册线程池
        .channel(NioSocketChannel.class) // 使用NioSocketChannel来作为连接用的channel类
        .handler(channelInitializer);
    if (proxyConfig != null) {
      //代理服务器解析DNS和连接
      bootstrap.resolver(NoopAddressResolverGroup.INSTANCE);
    }
    requestList = new LinkedList();
    cf = bootstrap.connect(host, port);
    cf.addListener((ChannelFutureListener) future -> {
      if (future.isSuccess()) {
        future.channel().writeAndFlush(msg);
        synchronized (requestList) {
          requestList.forEach((obj) -> future.channel().write(obj));
          requestList.clear();
          isConnect = true;
        }
      } else {
        future.channel().close();
        channel.close();
      }
    });
  } else {
    synchronized (requestList) {
      if (isConnect) {
        cf.channel().writeAndFlush(msg);
      } else {
        requestList.add(msg);
      }
    }
  }
}
 
开发者ID:monkeyWie,项目名称:proxyee,代码行数:50,代码来源:HttpProxyServerHandle.java

示例8: HttpProxyInitializer

import io.netty.handler.proxy.ProxyHandler; //导入依赖的package包/类
public HttpProxyInitializer(Channel clientChannel, RequestProto requestProto,
    ProxyHandler proxyHandler) {
  this.clientChannel = clientChannel;
  this.requestProto = requestProto;
  this.proxyHandler = proxyHandler;
}
 
开发者ID:monkeyWie,项目名称:proxyee,代码行数:7,代码来源:HttpProxyInitializer.java

示例9: TunnelProxyInitializer

import io.netty.handler.proxy.ProxyHandler; //导入依赖的package包/类
public TunnelProxyInitializer(Channel clientChannel,
    ProxyHandler proxyHandler) {
  this.clientChannel = clientChannel;
  this.proxyHandler = proxyHandler;
}
 
开发者ID:monkeyWie,项目名称:proxyee,代码行数:6,代码来源:TunnelProxyInitializer.java

示例10: getProxyHandler

import io.netty.handler.proxy.ProxyHandler; //导入依赖的package包/类
@Override
ProxyHandler getProxyHandler(ProxyProperties proxyProperties) {
	return new Socks5ProxyHandler(
			new InetSocketAddress(proxyProperties.getProxyAddress(),
					proxyProperties.getProxyPort()));
}
 
开发者ID:slyak,项目名称:slyak-commons,代码行数:7,代码来源:Socks5ProxyServer.java

示例11: Socks5ProxyMatcher

import io.netty.handler.proxy.ProxyHandler; //导入依赖的package包/类
public Socks5ProxyMatcher(MessageListener messageListener, ServerSSLContextManager sslContextManager,
                          Supplier<ProxyHandler> proxyHandlerSupplier) {
    this.messageListener = messageListener;
    this.sslContextManager = sslContextManager;
    this.proxyHandlerSupplier = proxyHandlerSupplier;
}
 
开发者ID:hsiafan,项目名称:byproxy,代码行数:7,代码来源:Socks5ProxyMatcher.java

示例12: Socks4ProxyMatcher

import io.netty.handler.proxy.ProxyHandler; //导入依赖的package包/类
public Socks4ProxyMatcher(MessageListener messageListener, ServerSSLContextManager sslContextManager,
                          Supplier<ProxyHandler> proxyHandlerSupplier) {
    this.messageListener = messageListener;
    this.sslContextManager = sslContextManager;
    this.proxyHandlerSupplier = proxyHandlerSupplier;
}
 
开发者ID:hsiafan,项目名称:byproxy,代码行数:7,代码来源:Socks4ProxyMatcher.java

示例13: HttpProxyMatcher

import io.netty.handler.proxy.ProxyHandler; //导入依赖的package包/类
public HttpProxyMatcher(MessageListener messageListener, Supplier<ProxyHandler> proxyHandlerSupplier) {
    this.messageListener = messageListener;
    this.proxyHandlerSupplier = proxyHandlerSupplier;
}
 
开发者ID:hsiafan,项目名称:byproxy,代码行数:5,代码来源:HttpProxyMatcher.java

示例14: TunnelProxyHandler

import io.netty.handler.proxy.ProxyHandler; //导入依赖的package包/类
public TunnelProxyHandler(MessageListener messageListener, ServerSSLContextManager sslContextManager,
                          Supplier<ProxyHandler> proxyHandlerSupplier) {
    this.messageListener = messageListener;
    this.sslContextManager = sslContextManager;
    this.proxyHandlerSupplier = proxyHandlerSupplier;
}
 
开发者ID:hsiafan,项目名称:byproxy,代码行数:7,代码来源:TunnelProxyHandler.java

示例15: Socks4ProxyHandler

import io.netty.handler.proxy.ProxyHandler; //导入依赖的package包/类
public Socks4ProxyHandler(MessageListener messageListener, ServerSSLContextManager sslContextManager,
                          Supplier<ProxyHandler> proxyHandlerSupplier) {
    super(messageListener, sslContextManager, proxyHandlerSupplier);
}
 
开发者ID:hsiafan,项目名称:byproxy,代码行数:5,代码来源:Socks4ProxyHandler.java


注:本文中的io.netty.handler.proxy.ProxyHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。