mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-11-27 11:24:14 +01:00
CW-519 Enable built-in Tor (#1950)
* tor wip * Enable tor on iOS * Prevent app lag when node is exceptionally slow (usually over tor) * fix: logic in daemonBlockchainHeight refresh fix: storing tor state * Pin ledger_flutter_plus dependency to fix builds * bump arti version * wip * add single httpclient * route everything I was able to catch trough the built-in tor node * Enable proxy for http.Client [run tests] * add tor proxy support to cw_evm, cw_tron and cw_polygon [run tests] * remove log pollution, cleanup [skip slack] * fix tests not working in latest main [skip slack] [run tests] * remove cw_wownero import * fix build issues * migrate all remaining calls to use ProxyWrapper add a CI action to enforce using ProxyWrapper instead of http/http.dart to prevent leaks * fix tor background sync (will work on test builds after #2142 is merged and this PR is rebased on top) * wip [skip ci] * relicense to GPLv3 add socks5 license, build fixes * use ProxyWrapper instead of http in robinhood * Revert "relicense to GPLv3" * feat(cw_bitcoin): support socks proxy and CakeTor * fix(tor): migrate OCP and EVM over to ProxyWrapper() * chore: cleanup fix: show tor loading screen when app is starting * fix: tor switch properly dismisses fullscreen loading dialog fix: connectToNode after tor startup on app start * fix(tor): status check for xmr/wow/zano * fix(tor): onramper request fix * fix(api): ServicesResponse is now being cached and doesn't fetch data everytime DashboardViewModel is being rebuilt fix(tor): do not fallback to clearnet when tor failed. fix(tor): do not leak connections during app startup chore: refactor bootstrap() function to be separated into bootstrapOffline and bootstrapOnline fix(cw_bitcoin): migrate payjoin to use ProxyWrapper * [skip ci] remove print * address comments from review * fix: derusting tor implementation Instead of rust-based Arti I've moved back to the OG C++ tor implementation. This fixed all issues we had with Tor. - onion services now work - all requests are going through without random errors - we don't have to navigate a maze of multiple forks of multiple packages - fully working `torrc` config file (probably will be needed for Tari). - logging for Tor client - and so on. feat: network logging tab feat: use built-in proxy on Tails - this should resolve all issues for Tails users (needs testing though) * fix conflicts with main bump https to fix build issue relax store() call * fix(cw_wownero): tor connection fix(tor): connection issues * fix(cw_evm): add missing chainId fix(cw_core): solana rpc fix * feat: mark tor as experimental fix: drop anonpay onion authority fix: drop fiatapi onion authority fix: drop trocador onion authority fix: disable networkimage when tor is enabled fix: handle cakepay errors gracefully * fix re-formatting [skip ci] * changes from review * Delete android/.kotlin/sessions/kotlin-compiler-2468481326039681181.salive * fix missing imports * Update pubspec_base.yaml --------- Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
This commit is contained in:
@@ -0,0 +1,155 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/view_model/dev/network_requests_view_model.dart';
|
||||
import 'package:cw_core/utils/proxy_logger/abstract.dart';
|
||||
import 'package:cw_core/utils/proxy_logger/memory_proxy_logger.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
|
||||
class DevNetworkRequests extends BasePage {
|
||||
final NetworkRequestsViewModel viewModel = NetworkRequestsViewModel();
|
||||
|
||||
DevNetworkRequests() {
|
||||
viewModel.loadLogs();
|
||||
}
|
||||
|
||||
@override
|
||||
String? get title => "[dev] network requests";
|
||||
|
||||
@override
|
||||
Widget? trailing(BuildContext context) {
|
||||
return IconButton(
|
||||
icon: Icon(Icons.refresh),
|
||||
onPressed: () => viewModel.loadLogs(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) {
|
||||
return Observer(
|
||||
builder: (_) {
|
||||
if (viewModel.logs.isEmpty) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text("No logs loaded"),
|
||||
SizedBox(height: 16),
|
||||
ElevatedButton(
|
||||
onPressed: () => viewModel.loadLogs(),
|
||||
child: Text("Load Logs"),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return ListView.builder(
|
||||
itemCount: viewModel.logs.length,
|
||||
itemBuilder: (BuildContext context, int i) {
|
||||
final item = viewModel.logs[i];
|
||||
return ListTile(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return DevRequestDetails(item);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
leading: switch (item.network) {
|
||||
RequestNetwork.clearnet => Text("C"),
|
||||
RequestNetwork.tor => Text("T"),
|
||||
},
|
||||
trailing: switch (item.method) {
|
||||
RequestMethod.get => Text("GET"),
|
||||
RequestMethod.post => Text("POST"),
|
||||
RequestMethod.put => Text("PUT"),
|
||||
RequestMethod.delete => Text("DELETE"),
|
||||
RequestMethod.newHttpClient ||
|
||||
RequestMethod.newHttpIOClient ||
|
||||
RequestMethod.newProxySocket => null,
|
||||
},
|
||||
title: Text(item.time.toIso8601String()),
|
||||
subtitle: switch (item.method) {
|
||||
RequestMethod.get ||
|
||||
RequestMethod.post ||
|
||||
RequestMethod.put ||
|
||||
RequestMethod.delete => Text("${item.uri}"),
|
||||
RequestMethod.newHttpClient => Text("newHttpClient"),
|
||||
RequestMethod.newHttpIOClient => Text("newHttpIOClient"),
|
||||
RequestMethod.newProxySocket => Text("newProxySocket"),
|
||||
},
|
||||
tileColor: item.error != null ? Colors.red : null,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class DevRequestDetails extends BasePage {
|
||||
final MemoryProxyLoggerEntry req;
|
||||
DevRequestDetails(this.req);
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: _body(context),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _body(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_sectionTitle("Time"),
|
||||
SelectableText(req.time.toString()),
|
||||
|
||||
_sectionTitle("Method"),
|
||||
SelectableText(req.method.toString()),
|
||||
|
||||
_sectionTitle("URI"),
|
||||
SelectableText(req.uri?.toString() ?? "null"),
|
||||
|
||||
_sectionTitle("Network"),
|
||||
SelectableText(req.network.toString()),
|
||||
|
||||
_sectionTitle("Body (as UTF-8)"),
|
||||
SelectableText(_tryDecodeBody(req.body)),
|
||||
|
||||
_sectionTitle("Response"),
|
||||
SelectableText(req.response?.body ?? "null"),
|
||||
|
||||
_sectionTitle("Error"),
|
||||
SelectableText(req.error ?? "No error"),
|
||||
|
||||
_sectionTitle("Stack Trace"),
|
||||
SelectableText(req.trace.toString()),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _sectionTitle(String title) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: Text(
|
||||
title,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _tryDecodeBody(Uint8List body) {
|
||||
try {
|
||||
return utf8.decode(body);
|
||||
} catch (_) {
|
||||
return 'Binary data (${body.length} bytes)';
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user