org.littleshoot.proxy.UnknownTransportProtocolException Java Examples
The following examples show how to use
org.littleshoot.proxy.UnknownTransportProtocolException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProxyToServerConnection.java From PowerTunnel with MIT License | 5 votes |
@Override protected Future<?> execute() { Bootstrap cb = new Bootstrap() .group(proxyServer.getProxyToServerWorkerFor(transportProtocol)) .resolver(remoteAddressResolver); switch (transportProtocol) { case TCP: LOG.debug("Connecting to server with TCP"); cb.channelFactory(NioSocketChannel::new); break; case UDT: LOG.debug("Connecting to server with UDT"); cb.channelFactory(NioUdtProvider.BYTE_CONNECTOR) .option(ChannelOption.SO_REUSEADDR, true); break; default: throw new UnknownTransportProtocolException(transportProtocol); } cb.handler(new ChannelInitializer<Channel>() { protected void initChannel(Channel ch) { initChannelPipeline(ch.pipeline(), initialRequest); } }); cb.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, proxyServer.getConnectTimeout()); if (localAddress != null) { return cb.connect(remoteAddress, localAddress); } else { return cb.connect(remoteAddress); } }
Example #2
Source File: ServerGroup.java From g4proxy with Apache License 2.0 | 5 votes |
/** * Retrieves the {@link ProxyThreadPools} for the specified transport protocol. Lazily initializes the thread pools * for the transport protocol if they have not yet been initialized. If the protocol has already been initialized, * this method returns immediately, without synchronization. If initialization is necessary, the initialization * process creates the acceptor and worker threads necessary to service requests to/from the proxy. * <p> * This method is thread-safe; no external locking is necessary. * * @param protocol transport protocol to retrieve thread pools for * @return thread pools for the specified transport protocol */ private ProxyThreadPools getThreadPoolsForProtocol(TransportProtocol protocol) { // if the thread pools have not been initialized for this protocol, initialize them if (protocolThreadPools.get(protocol) == null) { synchronized (THREAD_POOL_INIT_LOCK) { if (protocolThreadPools.get(protocol) == null) { log.debug("Initializing thread pools for {} with {} acceptor threads, {} incoming worker threads, and {} outgoing worker threads", protocol, incomingAcceptorThreads, incomingWorkerThreads, outgoingWorkerThreads); SelectorProvider selectorProvider = TRANSPORT_PROTOCOL_SELECTOR_PROVIDERS.get(protocol); if (selectorProvider == null) { throw new UnknownTransportProtocolException(protocol); } ProxyThreadPools threadPools = new ProxyThreadPools(selectorProvider, incomingAcceptorThreads, incomingWorkerThreads, outgoingWorkerThreads, name, serverGroupId); protocolThreadPools.put(protocol, threadPools); } } } return protocolThreadPools.get(protocol); }
Example #3
Source File: ProxyToServerConnection.java From g4proxy with Apache License 2.0 | 5 votes |
@Override protected Future<?> execute() { Bootstrap cb = new Bootstrap().group(proxyServer.getProxyToServerWorkerFor(transportProtocol)); switch (transportProtocol) { case TCP: LOG.debug("Connecting to server with TCP"); cb.channelFactory(new ChannelFactory<Channel>() { @Override public Channel newChannel() { return new NioSocketChannel(); } }); break; case UDT: LOG.debug("Connecting to server with UDT"); // cb.channelFactory(NioUdtProvider.BYTE_CONNECTOR) // .option(ChannelOption.SO_REUSEADDR, true); // break; throw new UnsupportedOperationException("unsupport udt proxy portocal"); default: throw new UnknownTransportProtocolException(transportProtocol); } cb.handler(new ChannelInitializer<Channel>() { protected void initChannel(Channel ch) throws Exception { initChannelPipeline(ch.pipeline(), initialRequest); }; }); cb.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, proxyServer.getConnectTimeout()); if (localAddress != null) { return cb.connect(remoteAddress, localAddress); } else { return cb.connect(remoteAddress); } }
Example #4
Source File: ProxyToServerConnection.java From yfs with Apache License 2.0 | 5 votes |
@Override protected Future<?> execute() { Bootstrap cb = new Bootstrap().group(proxyServer.getProxyToServerWorkerFor(transportProtocol)); switch (transportProtocol) { case TCP: LOG.debug("Connecting to server with TCP"); cb.channelFactory(new ChannelFactory<Channel>() { @Override public Channel newChannel() { return new NioSocketChannel(); } }); break; case UDT: LOG.debug("Connecting to server with UDT"); cb.channelFactory(NioUdtProvider.BYTE_CONNECTOR) .option(ChannelOption.SO_REUSEADDR, true); break; default: throw new UnknownTransportProtocolException(transportProtocol); } cb.handler(new ChannelInitializer<Channel>() { protected void initChannel(Channel ch) throws Exception { initChannelPipeline(ch.pipeline(), initialRequest); }; }); cb.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, proxyServer.getConnectTimeout()); if (localAddress != null) { return cb.connect(remoteAddress, localAddress); } else { return cb.connect(remoteAddress); } }