A pure-java library built for managing large number of proxies!
Explore the docs »
Report Bug
·
Request Feature
Table of Contents
The Aseefian Proxy Pool (APP) is a thread safe framework for managing a large number of proxies. Written to be robust and flexible, the design philosophy of APP is written to give as much power over to the developers as possible. This flexibility lets you as the developer choose exactly how this proxy pool should behave.
- Built to be thread safe
- Lightweight (with a shaded jar of ~36kb)
- Comes with a simple and built in framework for making HTTP requests
- Built in with optional support for the Apache HTTP Client Framework
- Supports using both HTTP and SOCKS5 proxies
- Supports Proxy Authentication
- Ability to "rotate" which proxies from the pool are being used
- Built-in leak detections to analyze which requests are taking longer then they should.
- Built-in proxy health check to automatically remove dead proxies from the pool
- Vast flexibility to give developers full control over the high-level behavior of the pool
APP requires at least Java 8 or higher.
APP maybe installed either via the maven repository jitpack or downloaded directly and then added as a dependency.
repositories {
...
maven { url 'https://jitpack.io' }
}
dependencies {
implementation ('com.github.Aseeef:AseefianProxyPool:latest.release')
}
<repositories>
...
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.Aseeef</groupId>
<artifactId>AseefianProxyPool</artifactId>
<version>LATEST</version>
</dependency>
// configure the proxy pool's config
PoolConfig config = new PoolConfig()
.setProxyTimeoutMillis(3000)
.setProxyTestFrequency(15000)
.setConnectionLeakThreshold(30000)
.setTestProxies(true)
.setMaxConcurrency(Integer.MAX_VALUE)
.setLeakTestFrequencyMillis(10)
.setSortingMode(PoolConfig.SortingMode.LAST_USED);
// create a list of all proxies that this pool will have
List<AseefianProxy> proxies = new ArrayList<>();
proxies.add(new AseefianProxy("host1", 1234, Proxy.Type.HTTP));
proxies.add(new AseefianProxy("hos2t", 1234, Proxy.Type.HTTP, "username", "password"));
// create the proxy pool
pool = new AseefianProxyPool(proxies, config);
pool.init();
// now that the pool is created, grab a proxy connection from the pool
// and execute an http request
try (ProxyConnection connection = pool.getConnection()) {
// you don't have to use APP's built in HTTPProxyRequestBuilder.
// but in this example, I am...
HTTPProxyRequestBuilder requestBuilder = connection
.getRequestBuilder("https://some.site/api/v1/request")
.setHTTPMethod(HTTPProxyRequestBuilder.RequestMethod.POST) // we are making a post reqest
.setConnectionTimeoutMillis(1000)
.setContentType(HTTPProxyRequestBuilder.ContentType.APPLICATION_JSON)
.setContentBody("{\"example\":\"more example\"}");
HTTPProxyRequest request = requestBuilder.build(); // build the request
// first attempt to connect to the http server
request.connect();
// if there is an issue and the response code is not 200, then do something
if (request.getResponseCode() != 200) {
//do something
}
// get the response string
String response = request.getContentString();
System.out.println(response);
}
For more examples, please refer to the Documentation
Distributed under the MIT License. See LICENSE.txt
for more information.
Muhammad Aseef Imran - [email protected]
Project Link: https://github.com/Aseeef/AseefianProxyPool