Skip to content

Commit cc696c3

Browse files
feat: reconnect mode added (#199)
1 parent 9b620e3 commit cc696c3

2 files changed

Lines changed: 28 additions & 10 deletions

File tree

lib/modules/core/vpn.dart

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ class VPN {
132132
if (msg.startsWith("Data: VPN stopped")) {
133133
_closeTunnel();
134134
}
135+
if (msg.startsWith("Data: VPN connecting")) {
136+
_onLoading();
137+
}
135138
if (msg.startsWith("Data: Config label: ")) {
136139
final configLabel = msg.replaceAll("Data: Config label: ", "");
137140
_vpnBridge.setConnectionMethod(configLabel);
@@ -212,7 +215,10 @@ class VPN {
212215
return;
213216
}
214217

215-
await _createTunnel();
218+
final isTunnelRunning = await _vpnBridge.isTunnelRunning();
219+
if (!isTunnelRunning) {
220+
await _createTunnel();
221+
}
216222
connectionNotifier?.setConnected();
217223
vpnData?.enableVPN();
218224
await refreshPing();
@@ -235,6 +241,18 @@ class VPN {
235241
await _container?.read(flowlineServiceProvider).saveFlowline(false);
236242
}
237243

244+
Future<void> _onLoading() async {
245+
final connectionNotifier =
246+
_container?.read(connectionStateProvider.notifier);
247+
final loggerNotifier = _container?.read(loggerStateProvider.notifier);
248+
249+
final vpnData = await _container?.read(vpnDataProvider.future);
250+
251+
loggerNotifier?.setLoading();
252+
connectionNotifier?.setAnalyzing();
253+
await vpnData?.disableVPN();
254+
}
255+
238256
Future<void> refreshPing() async {
239257
_container?.read(flagLoadingProvider.notifier).state = true;
240258
_container?.read(pingLoadingProvider.notifier).state = true;
@@ -380,7 +398,7 @@ class VPN {
380398
final title = jsonData["title"] ?? "Unknown";
381399
jsonData.remove("title");
382400
final Map<String, String> stringMap =
383-
jsonData.map((key, value) => MapEntry(key, value.toString()));
401+
jsonData.map((key, value) => MapEntry(key, value.toString()));
384402
analyticsService.logCoreData(title, stringMap);
385403
}
386404
}

pubspec.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,10 @@ packages:
213213
dependency: transitive
214214
description:
215215
name: characters
216-
sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b
216+
sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
217217
url: "https://pub.dev"
218218
source: hosted
219-
version: "1.4.1"
219+
version: "1.4.0"
220220
checked_yaml:
221221
dependency: transitive
222222
description:
@@ -817,18 +817,18 @@ packages:
817817
dependency: transitive
818818
description:
819819
name: matcher
820-
sha256: "12956d0ad8390bbcc63ca2e1469c0619946ccb52809807067a7020d57e647aa6"
820+
sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
821821
url: "https://pub.dev"
822822
source: hosted
823-
version: "0.12.18"
823+
version: "0.12.17"
824824
material_color_utilities:
825825
dependency: transitive
826826
description:
827827
name: material_color_utilities
828-
sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b"
828+
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
829829
url: "https://pub.dev"
830830
source: hosted
831-
version: "0.13.0"
831+
version: "0.11.1"
832832
meta:
833833
dependency: transitive
834834
description:
@@ -1278,10 +1278,10 @@ packages:
12781278
dependency: transitive
12791279
description:
12801280
name: test_api
1281-
sha256: "93167629bfc610f71560ab9312acdda4959de4df6fac7492c89ff0d3886f6636"
1281+
sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55
12821282
url: "https://pub.dev"
12831283
source: hosted
1284-
version: "0.7.9"
1284+
version: "0.7.7"
12851285
timing:
12861286
dependency: transitive
12871287
description:

0 commit comments

Comments
 (0)