mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 12:29:51 +00:00
Cw 519 tor connection (#1158)
* initial draft for tor feature * Configure nodes to use Tor proxy if enabled * Add socks proxy upon connecting to tor fix disconnect button * Try tor with github actions * accept defaults for rust installation * Merge main Change Tor tile name
This commit is contained in:
parent
e092509264
commit
ab83f5b67f
44 changed files with 548 additions and 113 deletions
|
@ -6,6 +6,7 @@ import 'package:hive/hive.dart';
|
|||
import 'package:cw_core/hive_type_ids.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:http/io_client.dart' as ioc;
|
||||
import 'package:tor/tor.dart';
|
||||
|
||||
part 'node.g.dart';
|
||||
|
||||
|
@ -129,9 +130,7 @@ class Node extends HiveObject with Keyable {
|
|||
try {
|
||||
switch (type) {
|
||||
case WalletType.monero:
|
||||
return useSocksProxy
|
||||
? requestNodeWithProxy(socksProxyAddress ?? '')
|
||||
: requestMoneroNode();
|
||||
return requestMoneroNode();
|
||||
case WalletType.bitcoin:
|
||||
return requestElectrumServer();
|
||||
case WalletType.litecoin:
|
||||
|
@ -154,6 +153,9 @@ class Node extends HiveObject with Keyable {
|
|||
}
|
||||
|
||||
Future<bool> requestMoneroNode() async {
|
||||
if (uri.toString().contains(".onion") || useSocksProxy) {
|
||||
return await requestNodeWithProxy();
|
||||
}
|
||||
final path = '/json_rpc';
|
||||
final rpcUri = isSSL ? Uri.https(uri.authority, path) : Uri.http(uri.authority, path);
|
||||
final realm = 'monero-rpc';
|
||||
|
@ -205,11 +207,20 @@ class Node extends HiveObject with Keyable {
|
|||
}
|
||||
}
|
||||
|
||||
Future<bool> requestNodeWithProxy(String proxy) async {
|
||||
if (proxy.isEmpty || !proxy.contains(':')) {
|
||||
Future<bool> requestNodeWithProxy() async {
|
||||
if ((socksProxyAddress == null ||
|
||||
socksProxyAddress!.isEmpty ||
|
||||
!socksProxyAddress!.contains(':')) &&
|
||||
!Tor.instance.enabled) {
|
||||
return false;
|
||||
}
|
||||
final proxyAddress = proxy.split(':')[0];
|
||||
|
||||
String? proxy = socksProxyAddress;
|
||||
|
||||
if ((proxy?.isEmpty ?? true) && Tor.instance.enabled) {
|
||||
proxy = "${InternetAddress.loopbackIPv4.address}:${Tor.instance.port}";
|
||||
}
|
||||
final proxyAddress = proxy!.split(':')[0];
|
||||
final proxyPort = int.parse(proxy.split(':')[1]);
|
||||
try {
|
||||
final socket = await Socket.connect(proxyAddress, proxyPort, timeout: Duration(seconds: 5));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue