Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tayoji-io/socks_proxy

dart package,http/socks4/socks5 proxy
https://github.com/tayoji-io/socks_proxy

dart flutter proxy socks4 socks5

Last synced: 27 days ago
JSON representation

dart package,http/socks4/socks5 proxy

Awesome Lists containing this project

README

        

# flutter_socks_proxy

**flutter_socks_proxy** is a dart package, HTTP/Socks4/Socks5 proxy

## Flutter version scope

| flutter_socks_proxy | Flutter |
| ------------- | ------------- |
| 0.0.1 | < 3.0 |
| 0.0.2 | >= 3.0 |

## Usage

### Use global

```dart
import 'dart:convert';
import 'dart:io';
import 'package:flutter_socks_proxy/socks_proxy.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();
// proxy -> "SOCKS5/SOCKS4/PROXY username:password@host:port;" or "DIRECT"
SocksProxy.initProxy(proxy: 'SOCKS5 192.168.31.180:7891');
await HttpClient()
.getUrl(Uri.parse('https://raw.githubusercontent.com/tayoji-io/socks_proxy/master/README.md'))
.then((value) {
return value.close();
})
.then((value) {
return value.transform(utf8.decoder);
})
.then((value) {
return value.fold(
'', (dynamic previous, element) => previous + element);
})
.then((value) => print(value))
.catchError((e) => print(e));
});
runApp(MyApp());
}
```

### Use independent
``` dart
import 'dart:convert';
import 'dart:io';
import 'package:flutter_socks_proxy/socks_proxy.dart';

void requset() async {
// proxy -> "SOCKS5/SOCKS4/PROXY username:password@host:port;" or "DIRECT"
final http = createProxyHttpClient()
..findProxy = (url) => 'SOCKS5 192.168.31.180:7891';
await http
.getUrl(Uri.parse('https://raw.githubusercontent.com/tayoji-io/socks_proxy/master/README.md'))
.then((value) {
return value.close();
})
.then((value) {
return value.transform(utf8.decoder);
})
.then((value) {
return value.fold(
'', (dynamic previous, element) => previous + element);
})
.then((value) => print(value))
.catchError((e) => print(e));
}

```