Add Circuit Info To Peer Settings
This commit is contained in:
parent
24787adc9c
commit
daa89bf6e7
|
@ -351,6 +351,10 @@ class CwtchNotifier {
|
||||||
case "DoneStorageMigration":
|
case "DoneStorageMigration":
|
||||||
appState.SetModalState(ModalState.none);
|
appState.SetModalState(ModalState.none);
|
||||||
break;
|
break;
|
||||||
|
case "ACNInfo":
|
||||||
|
var handle = data["Handle"];
|
||||||
|
profileCN.getProfile(data["ProfileOnion"])?.contactList.findContact(handle)?.acnCircuit = data["Data"];
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
EnvironmentConfig.debugLog("unhandled event: $type");
|
EnvironmentConfig.debugLog("unhandled event: $type");
|
||||||
}
|
}
|
||||||
|
|
|
@ -565,6 +565,8 @@ class ContactInfoState extends ChangeNotifier {
|
||||||
String? _server;
|
String? _server;
|
||||||
late bool _archived;
|
late bool _archived;
|
||||||
|
|
||||||
|
String? _acnCircuit;
|
||||||
|
|
||||||
ContactInfoState(this.profileOnion, this.identifier, this.onion,
|
ContactInfoState(this.profileOnion, this.identifier, this.onion,
|
||||||
{nickname = "",
|
{nickname = "",
|
||||||
isGroup = false,
|
isGroup = false,
|
||||||
|
@ -598,6 +600,11 @@ class ContactInfoState extends ChangeNotifier {
|
||||||
|
|
||||||
String get savePeerHistory => this._savePeerHistory;
|
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
|
// Indicated whether the conversation is archived, in which case it will
|
||||||
// be moved to the very bottom of the active conversations list until
|
// be moved to the very bottom of the active conversations list until
|
||||||
// new messages appear
|
// new messages appear
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'dart:ui';
|
||||||
import 'package:cwtch/cwtch_icons_icons.dart';
|
import 'package:cwtch/cwtch_icons_icons.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:cwtch/model.dart';
|
import 'package:cwtch/model.dart';
|
||||||
|
@ -47,6 +48,33 @@ class _PeerSettingsViewState extends State<PeerSettingsView> {
|
||||||
Widget _buildSettingsList() {
|
Widget _buildSettingsList() {
|
||||||
return Consumer<Settings>(builder: (context, settings, child) {
|
return Consumer<Settings>(builder: (context, settings, child) {
|
||||||
return LayoutBuilder(builder: (BuildContext context, BoxConstraints viewportConstraints) {
|
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(
|
return Scrollbar(
|
||||||
isAlwaysShown: true,
|
isAlwaysShown: true,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
|
@ -104,6 +132,16 @@ class _PeerSettingsViewState extends State<PeerSettingsView> {
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 20,
|
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(
|
SwitchListTile(
|
||||||
title: Text(AppLocalizations.of(context)!.blockBtn, style: TextStyle(color: settings.current().mainTextColor)),
|
title: Text(AppLocalizations.of(context)!.blockBtn, style: TextStyle(color: settings.current().mainTextColor)),
|
||||||
value: Provider.of<ContactInfoState>(context).isBlocked,
|
value: Provider.of<ContactInfoState>(context).isBlocked,
|
||||||
|
|
Loading…
Reference in New Issue