11using System ;
2+ using System . Net . Sockets ;
23using System . Windows . Input ;
34using ShecanDesktop . Core ;
45using ShecanDesktop . Core . Network ;
@@ -13,13 +14,22 @@ public class MainPageViewModel : BaseViewModel
1314
1415 public MainPageViewModel ( )
1516 {
16- var preferredServer = Properties . Resources . PreferredServer ;
17- var alternateServer = Properties . Resources . AlternateServer ;
18- _shecanDns = new Dns ( preferredServer , alternateServer ) ;
19-
2017 _dnsService = new DnsService ( Launcher . LauncherInfo . PowerShellScriptFile ) ;
2118 _dnsService . DnsChanged += OnDnsChanged ;
2219
20+ var shecanDnsProvider = Properties . Resources . ShecanDnsProvider ;
21+
22+ try
23+ {
24+ _shecanDns = _dnsService . GetDnsFromUrl ( shecanDnsProvider ) ;
25+ }
26+ catch ( SocketException exception )
27+ {
28+ InternetSnackbarVisibility = true ;
29+ Launcher . Logger . LogError ( exception . Message ) ;
30+ }
31+
32+
2333 RegisterCommands ( ) ;
2434 SetStatus ( ) ;
2535 }
@@ -72,10 +82,10 @@ private void EnableShecanDesktop(object parameter)
7282 {
7383 _dnsService . Set ( _shecanDns ) ;
7484 }
75- catch ( Exception exception )
85+ catch ( SocketException exception )
7686 {
77- Launcher . Logger . LogError ( exception . Message ) ;
7887 InternetSnackbarVisibility = true ;
88+ Launcher . Logger . LogError ( exception . Message ) ;
7989 }
8090 }
8191
@@ -85,10 +95,10 @@ private void DisableShecanDesktop(object parameter)
8595 {
8696 _dnsService . Unset ( ) ;
8797 }
88- catch ( Exception exception )
98+ catch ( SocketException exception )
8999 {
90- Launcher . Logger . LogError ( exception . Message ) ;
91100 InternetSnackbarVisibility = true ;
101+ Launcher . Logger . LogError ( exception . Message ) ;
92102 }
93103 }
94104
0 commit comments