개정판 f280a4ce
setup 수정
Change-Id: Idf0dc29933d3b2ce7d5cd54145ba73949c0b0fe1
DnsCheckTest/MainWindow.xaml.cs | ||
---|---|---|
2 | 2 |
using System; |
3 | 3 |
using System.Collections.Generic; |
4 | 4 |
using System.Linq; |
5 |
using System.Net; |
|
6 |
using System.Net.NetworkInformation; |
|
5 | 7 |
using System.Text; |
6 | 8 |
using System.Threading.Tasks; |
7 | 9 |
using System.Windows; |
... | ... | |
25 | 27 |
{ |
26 | 28 |
InitializeComponent(); |
27 | 29 |
|
30 |
DnsCheckOld(); |
|
28 | 31 |
DnsCheck(); |
29 | 32 |
} |
30 | 33 |
|
31 | 34 |
private void Button_Click(object sender, RoutedEventArgs e) |
32 | 35 |
{ |
36 |
DnsCheckOld(); |
|
33 | 37 |
DnsCheck(); |
34 | 38 |
} |
35 | 39 |
|
... | ... | |
59 | 63 |
|
60 | 64 |
txtHostInfo.Text = builder.ToString(); |
61 | 65 |
} |
66 |
|
|
67 |
private void DnsCheckOld() |
|
68 |
{ |
|
69 |
var ipaddress = GetDnsAdress(); |
|
70 |
|
|
71 |
StringBuilder builder = new StringBuilder(); |
|
72 |
|
|
73 |
var host = Dns.GetHostEntry(ipaddress); |
|
74 |
|
|
75 |
builder.AppendLine($"hostName : {host.HostName}"); |
|
76 |
|
|
77 |
builder.AppendLine(""); |
|
78 |
builder.AppendLine(" - Aliases"); |
|
79 |
|
|
80 |
foreach (var item in host.Aliases) |
|
81 |
{ |
|
82 |
builder.AppendLine($" {item}"); |
|
83 |
} |
|
84 |
|
|
85 |
builder.AppendLine(""); |
|
86 |
builder.AppendLine(" - Address List"); |
|
87 |
|
|
88 |
foreach (var item in host.AddressList) |
|
89 |
{ |
|
90 |
builder.AppendLine($" {item.AddressFamily.ToString()} : {item.ToString()}"); |
|
91 |
} |
|
92 |
|
|
93 |
txtHostInfoOld.Text = builder.ToString(); |
|
94 |
} |
|
95 |
|
|
96 |
public static IPAddress GetDnsAdress() |
|
97 |
{ |
|
98 |
NetworkInterface[] networkInterfaces = NetworkInterface.GetAllNetworkInterfaces(); |
|
99 |
|
|
100 |
foreach (NetworkInterface networkInterface in networkInterfaces) |
|
101 |
{ |
|
102 |
if (networkInterface.OperationalStatus == OperationalStatus.Up) |
|
103 |
{ |
|
104 |
IPInterfaceProperties ipProperties = networkInterface.GetIPProperties(); |
|
105 |
IPAddressCollection dnsAddresses = ipProperties.DnsAddresses; |
|
106 |
|
|
107 |
foreach (IPAddress dnsAdress in dnsAddresses) |
|
108 |
{ |
|
109 |
return dnsAdress; |
|
110 |
} |
|
111 |
} |
|
112 |
} |
|
113 |
return null; |
|
114 |
} |
|
62 | 115 |
} |
63 | 116 |
} |
내보내기 Unified diff