Skip to content

Commit 0c1b427

Browse files
committed
fix dns crash
1 parent 3a92ca3 commit 0c1b427

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

CloudVeilService/Platform/WindowsDns.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,17 @@ public WindowsDns()
3030

3131
public void SetDnsForNic(string nicName, IPAddress primary, IPAddress secondary)
3232
{
33-
3433
var ipVersion = "ipv4";
3534

36-
if(primary.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6)
35+
if(primary != null && primary.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6)
36+
{
37+
ipVersion = "ipv6";
38+
}
39+
else if (secondary != null && secondary.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6)
3740
{
3841
ipVersion = "ipv6";
3942
}
43+
4044
var command = $"interface {ipVersion} add dnsservers \"{nicName}\" address=";
4145
if (primary != null)
4246
{

0 commit comments

Comments
 (0)