Add Circuit Info To Peer Settings

This commit is contained in:
Sarah Jamie Lewis 2022-01-13 15:21:09 -08:00
parent 24787adc9c
commit daa89bf6e7
3 changed files with 49 additions and 0 deletions

View File

@ -351,6 +351,10 @@ class CwtchNotifier {
case "DoneStorageMigration":
appState.SetModalState(ModalState.none);
break;
case "ACNInfo":
var handle = data["Handle"];
profileCN.getProfile(data["ProfileOnion"])?.contactList.findContact(handle)?.acnCircuit = data["Data"];
break;
default:
EnvironmentConfig.debugLog("unhandled event: $type");
}

View File

@ -565,6 +565,8 @@ class ContactInfoState extends ChangeNotifier {
String? _server;
late bool _archived;
String? _acnCircuit;
ContactInfoState(this.profileOnion, this.identifier, this.onion,
{nickname = "",
isGroup = false,
@ -598,6 +600,11 @@ class ContactInfoState extends ChangeNotifier {
String get savePeerHistory => this._savePeerHistory;
String? get acnCircuit => this._acnCircuit;
set acnCircuit(String? acnCircuit) {
this._acnCircuit = acnCircuit;
}
// Indicated whether the conversation is archived, in which case it will
// be moved to the very bottom of the active conversations list until
// new messages appear

View File

@ -1,4 +1,5 @@
import 'dart:convert';
import 'dart:ui';
import 'package:cwtch/cwtch_icons_icons.dart';
import 'package:flutter/services.dart';
import 'package:cwtch/model.dart';
@ -47,6 +48,33 @@ class _PeerSettingsViewState extends State<PeerSettingsView> {
Widget _buildSettingsList() {
return Consumer<Settings>(builder: (context, settings, child) {
return LayoutBuilder(builder: (BuildContext context, BoxConstraints viewportConstraints) {
String? acnCircuit = Provider.of<ContactInfoState>(context).acnCircuit;
Widget path = Text(Provider.of<ContactInfoState>(context, listen: false).status);
if (acnCircuit != null) {
var hops = acnCircuit.split(",");
if (hops.length == 3) {
List<Widget> paths = hops.map((String countryCodeAndIp) {
var parts = countryCodeAndIp.split(":");
var country = parts[0];
var ip = parts[1];
return RichText(
textAlign: TextAlign.left,
text: TextSpan(
text: "$country",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 10, fontFamily: "monospace"),
children: [TextSpan(text: " ($ip)", style: TextStyle(fontSize: 8, fontWeight: FontWeight.normal))]));
}).toList(growable: true);
paths.add(RichText(text: TextSpan(text: "Tor Network", style: TextStyle(fontWeight: FontWeight.normal, fontSize: 8, fontFamily: "monospace"))));
path = Column(
children: paths,
);
}
}
return Scrollbar(
isAlwaysShown: true,
child: SingleChildScrollView(
@ -104,6 +132,16 @@ class _PeerSettingsViewState extends State<PeerSettingsView> {
SizedBox(
height: 20,
),
ListTile(
leading: Icon(CwtchIcons.onion_on, color: settings.current().mainTextColor),
isThreeLine: true,
title: Text("ACN Circuit Info"),
subtitle: Text("In depth information about the path that the anonymous communication network is using to connect to this conversation"),
trailing: path,
),
SizedBox(
height: 20,
),
SwitchListTile(
title: Text(AppLocalizations.of(context)!.blockBtn, style: TextStyle(color: settings.current().mainTextColor)),
value: Provider.of<ContactInfoState>(context).isBlocked,