flutter_socks_proxy
flutter_socks_proxy is a dart package, http/socks4/socks5 proxy
usage
use global
import 'dart:convert';
import 'dart:io';
import 'package:socks_proxy/socks_proxy.dart';
void main() async {
widgetsflutterbinding.ensureinitialized();
// proxy -> "socks5/socks4/proxy username:[email protected]: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
import 'dart:convert';
import 'dart:io';
import 'package:socks_proxy/socks_proxy.dart';
void requset() async {
// proxy -> "socks5/socks4/proxy username:[email protected]: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));
}
Comments are closed.