Skip to content

Aseeef/AseefianProxyPool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Download Jitpack Contributors Forks Stargazers Issues MIT License LinkedIn


Aseefian Proxy Pool [APP]

A pure-java library built for managing large number of proxies!
Explore the docs »

Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. License
  5. Contact

About The Project

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.

Features

  • 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

(back to top)

Getting Started

Prerequisites

APP requires at least Java 8 or higher.

Installation

APP maybe installed either via the maven repository jitpack or downloaded directly and then added as a dependency.

Gradle

repositories {
	...
	maven { url 'https://jitpack.io' }
}
dependencies {
    implementation ('com.github.Aseeef:AseefianProxyPool:latest.release')
}

Maven

<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>

(back to top)

Usage

    // 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

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Muhammad Aseef Imran - [email protected]

Project Link: https://github.com/Aseeef/AseefianProxyPool

(back to top)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages