Skip to content
This repository was archived by the owner on Aug 19, 2020. It is now read-only.

Commit 74c9839

Browse files
committed
Replace constant ip addresses with dynamic addresses in main page
1 parent 8ddfde5 commit 74c9839

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

Source/ShecanDesktop/ViewModels/MainPageViewModel.cs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Net.Sockets;
23
using System.Windows.Input;
34
using ShecanDesktop.Core;
45
using 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

Comments
 (0)