From a34fe38e372bb51641371a3e60785f22374a1069 Mon Sep 17 00:00:00 2001 From: Matthew Fosse Date: Tue, 5 Dec 2023 09:19:41 -0700 Subject: [PATCH] re-enable tor --- cw_core/lib/node.dart | 8 +++--- cw_core/pubspec.yaml | 8 +++--- lib/src/screens/settings/tor_page.dart | 34 +++++++++++++------------- pubspec_base.yaml | 8 +++--- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/cw_core/lib/node.dart b/cw_core/lib/node.dart index bd96e1395..01aab1a45 100644 --- a/cw_core/lib/node.dart +++ b/cw_core/lib/node.dart @@ -6,7 +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'; +import 'package:tor/tor.dart'; part 'node.g.dart'; @@ -220,9 +220,9 @@ class Node extends HiveObject with Keyable { String? proxy = socksProxyAddress; - // if ((proxy?.isEmpty ?? true) && Tor.instance.enabled) { - // proxy = "${InternetAddress.loopbackIPv4.address}:${Tor.instance.port}"; - // } + if ((proxy?.isEmpty ?? true) && Tor.instance.enabled) { + proxy = "${InternetAddress.loopbackIPv4.address}:${Tor.instance.port}"; + } if (proxy == null) { return false; } diff --git a/cw_core/pubspec.yaml b/cw_core/pubspec.yaml index 04a840d4e..533b578ad 100644 --- a/cw_core/pubspec.yaml +++ b/cw_core/pubspec.yaml @@ -20,10 +20,10 @@ dependencies: intl: ^0.18.0 encrypt: ^5.0.1 socks5_proxy: ^1.0.4 -# tor: -# git: -# url: https://github.com/cake-tech/tor.git -# ref: main + tor: + git: + url: https://github.com/cake-tech/tor.git + ref: main dev_dependencies: flutter_test: diff --git a/lib/src/screens/settings/tor_page.dart b/lib/src/screens/settings/tor_page.dart index ae1ef1677..8256d0bfa 100644 --- a/lib/src/screens/settings/tor_page.dart +++ b/lib/src/screens/settings/tor_page.dart @@ -4,7 +4,7 @@ import 'dart:io'; import 'package:cake_wallet/src/screens/base_page.dart'; import 'package:cake_wallet/store/app_store.dart'; import 'package:flutter/material.dart'; -// import 'package:tor/tor.dart'; +import 'package:tor/tor.dart'; class TorPage extends BasePage { final AppStore appStore; @@ -40,22 +40,22 @@ class _TorPageBodyState extends State { connecting = true; // Update flag }); - // await Tor.init(); - // - // // Start the proxy - // await Tor.instance.start(); - // - // // Toggle started flag. - // setState(() { - // torEnabled = Tor.instance.enabled; // Update flag - // connecting = false; - // }); - // - // final node = widget.appStore.settingsStore.getCurrentNode(widget.appStore.wallet!.type); - // if (node.socksProxyAddress?.isEmpty ?? true) { - // node.socksProxyAddress = "${InternetAddress.loopbackIPv4.address}:${Tor.instance.port}"; - // } - // widget.appStore.wallet!.connectToNode(node: node); + await Tor.init(); + + // Start the proxy + await Tor.instance.start(); + + // Toggle started flag. + setState(() { + torEnabled = Tor.instance.enabled; // Update flag + connecting = false; + }); + + final node = widget.appStore.settingsStore.getCurrentNode(widget.appStore.wallet!.type); + if (node.socksProxyAddress?.isEmpty ?? true) { + node.socksProxyAddress = "${InternetAddress.loopbackIPv4.address}:${Tor.instance.port}"; + } + widget.appStore.wallet!.connectToNode(node: node); print('Done awaiting; tor should be running'); } diff --git a/pubspec_base.yaml b/pubspec_base.yaml index a4738bf82..d0a295047 100644 --- a/pubspec_base.yaml +++ b/pubspec_base.yaml @@ -98,10 +98,10 @@ dependencies: url: https://github.com/cake-tech/bitcoin_flutter.git ref: cake-update-v3 fluttertoast: 8.1.4 -# tor: -# git: -# url: https://github.com/cake-tech/tor.git -# ref: main + tor: + git: + url: https://github.com/cake-tech/tor.git + ref: main socks5_proxy: ^1.0.4 flutter_svg: ^2.0.9 polyseed: