@@ -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}
0 commit comments