1

In LittleProxy, how to set proxy ip and port? The sample in their website :

HttpProxyServer server = DefaultHttpProxyServer.bootstrap() .withPort(8080) .start();

Kudi
  • 49
  • 1
  • 8

2 Answers2

2

This is a tested code derived using the comment of johnstlr.

ChainedProxyAdapter adapter = new ChainedProxyAdapter() {
    @Override
    public InetSocketAddress getChainedProxyAddress() {
        return new InetSocketAddress("your.proxy.address", 1234);
    }
};
ChainedProxyManager manager = new ChainedProxyManager() {
    @Override
    public void lookupChainedProxies(HttpRequest httpRequest, Queue<ChainedProxy> chainedProxies) {
        chainedProxies.add(adapter);
    }
};

HttpProxyServer server = DefaultHttpProxyServer.bootstrap().withChainProxyManager(manager).withPort(8080).start();
Community
  • 1
  • 1
Gobinath
  • 904
  • 1
  • 15
  • 23
0

Looking at the source code you should be able to do something like

HttpProxyServer server = DefaultHttpProxyServer.bootstrap()
  .withAddress(new InetSocketAddress("127.0.0.1", 8080)).start();
johnstlr
  • 1,431
  • 7
  • 6
  • I want to forward the messgae(request) to a real proxy server, Can littleproxy do this? if can, where to set the host and port of a real proxy server? thanks. – Kudi Nov 23 '14 at 12:06
  • 2
    I think you need bootstrap().withChainProxyManager(chainProxyManager). Implement ChainedProxyManager to return a list of ChainedProxy implementations. You possibly only need to extend ChainedProxyAdapter and override getChainedProxyAddress. Sorry I can't be more specific as I've not tried it myself. – johnstlr Nov 23 '14 at 13:12