https://github.com/hacker1024/proxies
A collection of proxy API wrappers for Dart.
https://github.com/hacker1024/proxies
Last synced: 10 months ago
JSON representation
A collection of proxy API wrappers for Dart.
- Host: GitHub
- URL: https://github.com/hacker1024/proxies
- Owner: hacker1024
- License: mit
- Created: 2020-10-21T11:28:11.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-03-08T01:33:31.000Z (over 5 years ago)
- Last Synced: 2025-06-25T00:02:08.514Z (about 1 year ago)
- Language: Dart
- Homepage: https://pub.dev/packages/proxies
- Size: 49.8 KB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Proxies
A Dart package containing a collection of proxy API wrappers.
This package connects to different proxy services' APIs to create an IOClient
that uses the proxy.
## Supported proxy services
There aren't many at the moment - pull requests are welcome!
See the "Extending" section of this README if you'd like to contribute.
- Simple (host, port, username, password)
- [NordVPN](https://nordvpn.com) (requires a paid account)
- [Webshare](https://webshare.io) (requires a [free API key](https://proxy.webshare.io/userapi/keys))
## Usage
To use a proxy provider (read on to create one):
```dart
import 'dart:io';
import 'package:proxies/proxies.dart';
// Get a "Proxy" object from the provider (async because some providers fetch data from a server).
final proxy = await proxyProvider.getProxy();
// Create an IOClient from the Proxy
final client = proxy.createIOClient();
// Use the IOClient
final myHttpRequest = client.get('example.com');
```
To create a regular proxy provider with authentication:
```dart
final proxyProvider = SimpleProxyProvider('host.com', 8080, 'myUsername', 'myPassword');
```
To create a NordVPN proxy provider:
```dart
final proxyProvider = NordVPNProxyProvider(
username: r'myUsername',
password: r'myPassword',
countryCode: 'US',
);
```
Other providers are created in similar ways.
## Extending
Adding a proxy provider is fairly straightforward. The base class to extend
requires these functions to be implemented:
```dart
/// This class defines functions all proxy providers must implement.
abstract class ProxyProvider {
/// Returns a [Proxy] object future, to be used for necessary network operations.
Future getProxy();
/// If the proxy provider caches lists of available proxies, invalidate those caches.
Future invalidateCaches();
}
```
There's also an `AuthenticatedProxyProvider` that contains a few more
authentication-related things, which should be extended for any authentication-based services.
Take a look in `src/providers/nordvpn/` for an example of the implementation and
directory structure.
## Features and bugs
Please file feature requests and bugs at the [issue tracker][tracker].
[tracker]: https://github.com/hacker1024/proxies/issues