using System; using System.Collections; using System.Net.Sockets; using System.Runtime.CompilerServices; using System.Runtime.Remoting.Messaging; namespace System.Net { /// Provides simple domain name resolution functionality. // Token: 0x02000212 RID: 530 public static class Dns { // Token: 0x06001209 RID: 4617 RVA: 0x00035F54 File Offset: 0x00034154 static Dns() { global::System.Net.Sockets.Socket.CheckProtocolSupport(); } /// Begins an asynchronous request for information about the specified DNS host name. /// An instance that references the asynchronous request. /// The DNS name of the host. /// An delegate that references the method to invoke when the operation is complete. /// A user-defined object that contains information about the operation. This object is passed to the delegate when the operation is complete. /// /// is null. /// An error was encountered executing the DNS query. /// /// /// /// /// /// // Token: 0x0600120A RID: 4618 RVA: 0x00035F5C File Offset: 0x0003415C [Obsolete("Use BeginGetHostEntry instead")] public static IAsyncResult BeginGetHostByName(string hostName, AsyncCallback requestCallback, object stateObject) { if (hostName == null) { throw new ArgumentNullException("hostName"); } Dns.GetHostByNameCallback getHostByNameCallback = new Dns.GetHostByNameCallback(Dns.GetHostByName); return getHostByNameCallback.BeginInvoke(hostName, requestCallback, stateObject); } /// Begins an asynchronous request to resolve a DNS host name or IP address to an instance. /// An instance that references the asynchronous request. /// The DNS name of the host. /// An delegate that references the method to invoke when the operation is complete. /// A user-defined object that contains information about the operation. This object is passed to the delegate when the operation is complete. /// /// is null. /// The caller does not have permission to access DNS information. /// /// /// /// /// /// // Token: 0x0600120B RID: 4619 RVA: 0x00035F90 File Offset: 0x00034190 [Obsolete("Use BeginGetHostEntry instead")] public static IAsyncResult BeginResolve(string hostName, AsyncCallback requestCallback, object stateObject) { if (hostName == null) { throw new ArgumentNullException("hostName"); } Dns.ResolveCallback resolveCallback = new Dns.ResolveCallback(Dns.Resolve); return resolveCallback.BeginInvoke(hostName, requestCallback, stateObject); } /// Asynchronously returns the Internet Protocol (IP) addresses for the specified host. /// An instance that references the asynchronous request. /// The host name or IP address to resolve. /// An delegate that references the method to invoke when the operation is complete. /// A user-defined object that contains information about the operation. This object is passed to the delegate when the operation is complete. /// /// is null. /// The length of is greater than 126 characters. /// An error is encountered when resolving . /// /// is an invalid IP address. // Token: 0x0600120C RID: 4620 RVA: 0x00035FC4 File Offset: 0x000341C4 public static IAsyncResult BeginGetHostAddresses(string hostNameOrAddress, AsyncCallback requestCallback, object stateObject) { if (hostNameOrAddress == null) { throw new ArgumentNullException("hostName"); } if (hostNameOrAddress == "0.0.0.0" || hostNameOrAddress == "::0") { throw new ArgumentException("Addresses 0.0.0.0 (IPv4) and ::0 (IPv6) are unspecified addresses. You cannot use them as target address.", "hostNameOrAddress"); } Dns.GetHostAddressesCallback getHostAddressesCallback = new Dns.GetHostAddressesCallback(Dns.GetHostAddresses); return getHostAddressesCallback.BeginInvoke(hostNameOrAddress, requestCallback, stateObject); } /// Asynchronously resolves a host name or IP address to an instance. /// An instance that references the asynchronous request. /// The host name or IP address to resolve. /// An delegate that references the method to invoke when the operation is complete. /// A user-defined object that contains information about the operation. This object is passed to the delegate when the operation is complete. /// /// is null. /// The length of is greater than 126 characters. /// An error is encountered when resolving . /// /// is an invalid IP address. // Token: 0x0600120D RID: 4621 RVA: 0x00036028 File Offset: 0x00034228 public static IAsyncResult BeginGetHostEntry(string hostNameOrAddress, AsyncCallback requestCallback, object stateObject) { if (hostNameOrAddress == null) { throw new ArgumentNullException("hostName"); } if (hostNameOrAddress == "0.0.0.0" || hostNameOrAddress == "::0") { throw new ArgumentException("Addresses 0.0.0.0 (IPv4) and ::0 (IPv6) are unspecified addresses. You cannot use them as target address.", "hostNameOrAddress"); } Dns.GetHostEntryNameCallback getHostEntryNameCallback = new Dns.GetHostEntryNameCallback(Dns.GetHostEntry); return getHostEntryNameCallback.BeginInvoke(hostNameOrAddress, requestCallback, stateObject); } /// Asynchronously resolves an IP address to an instance. /// An instance that references the asynchronous request. /// The IP address to resolve. /// An delegate that references the method to invoke when the operation is complete. /// A user-defined object that contains information about the operation. This object is passed to the delegate when the operation is complete. /// /// is null. /// An error is encountered when resolving . /// /// is an invalid IP address. // Token: 0x0600120E RID: 4622 RVA: 0x0003608C File Offset: 0x0003428C public static IAsyncResult BeginGetHostEntry(IPAddress address, AsyncCallback requestCallback, object stateObject) { if (address == null) { throw new ArgumentNullException("address"); } Dns.GetHostEntryIPCallback getHostEntryIPCallback = new Dns.GetHostEntryIPCallback(Dns.GetHostEntry); return getHostEntryIPCallback.BeginInvoke(address, requestCallback, stateObject); } /// Ends an asynchronous request for DNS information. /// An object that contains DNS information about a host. /// An instance that is returned by a call to the method. /// /// is null. /// /// /// /// /// // Token: 0x0600120F RID: 4623 RVA: 0x000360C0 File Offset: 0x000342C0 [Obsolete("Use EndGetHostEntry instead")] public static IPHostEntry EndGetHostByName(IAsyncResult asyncResult) { if (asyncResult == null) { throw new ArgumentNullException("asyncResult"); } AsyncResult asyncResult2 = (AsyncResult)asyncResult; Dns.GetHostByNameCallback getHostByNameCallback = (Dns.GetHostByNameCallback)asyncResult2.AsyncDelegate; return getHostByNameCallback.EndInvoke(asyncResult); } /// Ends an asynchronous request for DNS information. /// An object that contains DNS information about a host. /// An instance that is returned by a call to the method. /// /// is null. /// /// /// /// /// // Token: 0x06001210 RID: 4624 RVA: 0x000360F8 File Offset: 0x000342F8 [Obsolete("Use EndGetHostEntry instead")] public static IPHostEntry EndResolve(IAsyncResult asyncResult) { if (asyncResult == null) { throw new ArgumentNullException("asyncResult"); } AsyncResult asyncResult2 = (AsyncResult)asyncResult; Dns.ResolveCallback resolveCallback = (Dns.ResolveCallback)asyncResult2.AsyncDelegate; return resolveCallback.EndInvoke(asyncResult); } /// Ends an asynchronous request for DNS information. /// An array of type that holds the IP addresses for the host specified by the parameter of . /// An instance returned by a call to the method. // Token: 0x06001211 RID: 4625 RVA: 0x00036130 File Offset: 0x00034330 public static IPAddress[] EndGetHostAddresses(IAsyncResult asyncResult) { if (asyncResult == null) { throw new ArgumentNullException("asyncResult"); } AsyncResult asyncResult2 = (AsyncResult)asyncResult; Dns.GetHostAddressesCallback getHostAddressesCallback = (Dns.GetHostAddressesCallback)asyncResult2.AsyncDelegate; return getHostAddressesCallback.EndInvoke(asyncResult); } /// Ends an asynchronous request for DNS information. /// An instance that contains address information about the host. /// An instance returned by a call to an method. /// /// is null. // Token: 0x06001212 RID: 4626 RVA: 0x00036168 File Offset: 0x00034368 public static IPHostEntry EndGetHostEntry(IAsyncResult asyncResult) { if (asyncResult == null) { throw new ArgumentNullException("asyncResult"); } AsyncResult asyncResult2 = (AsyncResult)asyncResult; if (asyncResult2.AsyncDelegate is Dns.GetHostEntryIPCallback) { return ((Dns.GetHostEntryIPCallback)asyncResult2.AsyncDelegate).EndInvoke(asyncResult); } Dns.GetHostEntryNameCallback getHostEntryNameCallback = (Dns.GetHostEntryNameCallback)asyncResult2.AsyncDelegate; return getHostEntryNameCallback.EndInvoke(asyncResult); } // Token: 0x06001213 RID: 4627 [MethodImpl(MethodImplOptions.InternalCall)] private static extern bool GetHostByName_internal(string host, out string h_name, out string[] h_aliases, out string[] h_addr_list); // Token: 0x06001214 RID: 4628 [MethodImpl(MethodImplOptions.InternalCall)] private static extern bool GetHostByAddr_internal(string addr, out string h_name, out string[] h_aliases, out string[] h_addr_list); // Token: 0x06001215 RID: 4629 [MethodImpl(MethodImplOptions.InternalCall)] private static extern bool GetHostName_internal(out string h_name); // Token: 0x06001216 RID: 4630 RVA: 0x000361C4 File Offset: 0x000343C4 private static IPHostEntry hostent_to_IPHostEntry(string h_name, string[] h_aliases, string[] h_addrlist) { IPHostEntry iphostEntry = new IPHostEntry(); ArrayList arrayList = new ArrayList(); iphostEntry.HostName = h_name; iphostEntry.Aliases = h_aliases; for (int i = 0; i < h_addrlist.Length; i++) { try { IPAddress ipaddress = IPAddress.Parse(h_addrlist[i]); if ((global::System.Net.Sockets.Socket.SupportsIPv6 && ipaddress.AddressFamily == global::System.Net.Sockets.AddressFamily.InterNetworkV6) || (global::System.Net.Sockets.Socket.SupportsIPv4 && ipaddress.AddressFamily == global::System.Net.Sockets.AddressFamily.InterNetwork)) { arrayList.Add(ipaddress); } } catch (ArgumentNullException) { } } if (arrayList.Count == 0) { throw new global::System.Net.Sockets.SocketException(11001); } iphostEntry.AddressList = arrayList.ToArray(typeof(IPAddress)) as IPAddress[]; return iphostEntry; } /// Creates an instance from the specified . /// An . /// An . /// /// is null. /// An error is encountered when resolving . /// /// /// /// /// /// // Token: 0x06001217 RID: 4631 RVA: 0x00036298 File Offset: 0x00034498 [Obsolete("Use GetHostEntry instead")] public static IPHostEntry GetHostByAddress(IPAddress address) { if (address == null) { throw new ArgumentNullException("address"); } return Dns.GetHostByAddressFromString(address.ToString(), false); } /// Creates an instance from an IP address. /// An instance. /// An IP address. /// /// is null. /// An error is encountered when resolving . /// /// is not a valid IP address. /// /// /// /// /// /// // Token: 0x06001218 RID: 4632 RVA: 0x000362B8 File Offset: 0x000344B8 [Obsolete("Use GetHostEntry instead")] public static IPHostEntry GetHostByAddress(string address) { if (address == null) { throw new ArgumentNullException("address"); } return Dns.GetHostByAddressFromString(address, true); } // Token: 0x06001219 RID: 4633 RVA: 0x000362D4 File Offset: 0x000344D4 private static IPHostEntry GetHostByAddressFromString(string address, bool parse) { if (address.Equals("0.0.0.0")) { address = "127.0.0.1"; parse = false; } if (parse) { IPAddress.Parse(address); } string text; string[] array; string[] array2; if (!Dns.GetHostByAddr_internal(address, out text, out array, out array2)) { throw new global::System.Net.Sockets.SocketException(11001); } return Dns.hostent_to_IPHostEntry(text, array, array2); } /// Resolves a host name or IP address to an instance. /// An instance that contains address information about the host specified in . /// The host name or IP address to resolve. /// The parameter is null. /// The length of parameter is greater than 126 characters. /// An error was encountered when resolving the parameter. /// The parameter is an invalid IP address. // Token: 0x0600121A RID: 4634 RVA: 0x00036330 File Offset: 0x00034530 public static IPHostEntry GetHostEntry(string hostNameOrAddress) { if (hostNameOrAddress == null) { throw new ArgumentNullException("hostNameOrAddress"); } if (hostNameOrAddress == "0.0.0.0" || hostNameOrAddress == "::0") { throw new ArgumentException("Addresses 0.0.0.0 (IPv4) and ::0 (IPv6) are unspecified addresses. You cannot use them as target address.", "hostNameOrAddress"); } IPAddress ipaddress; if (hostNameOrAddress.Length > 0 && IPAddress.TryParse(hostNameOrAddress, out ipaddress)) { return Dns.GetHostEntry(ipaddress); } return Dns.GetHostByName(hostNameOrAddress); } /// Resolves an IP address to an instance. /// An instance that contains address information about the host specified in . /// An IP address. /// /// is null. /// An error is encountered when resolving . /// /// is an invalid IP address. // Token: 0x0600121B RID: 4635 RVA: 0x000363A4 File Offset: 0x000345A4 public static IPHostEntry GetHostEntry(IPAddress address) { if (address == null) { throw new ArgumentNullException("address"); } return Dns.GetHostByAddressFromString(address.ToString(), false); } /// Returns the Internet Protocol (IP) addresses for the specified host. /// An array of type that holds the IP addresses for the host that is specified by the parameter. /// The host name or IP address to resolve. /// /// is null. /// The length of is greater than 126 characters. /// An error is encountered when resolving . /// /// is an invalid IP address. // Token: 0x0600121C RID: 4636 RVA: 0x000363C4 File Offset: 0x000345C4 public static IPAddress[] GetHostAddresses(string hostNameOrAddress) { if (hostNameOrAddress == null) { throw new ArgumentNullException("hostNameOrAddress"); } if (hostNameOrAddress == "0.0.0.0" || hostNameOrAddress == "::0") { throw new ArgumentException("Addresses 0.0.0.0 (IPv4) and ::0 (IPv6) are unspecified addresses. You cannot use them as target address.", "hostNameOrAddress"); } IPAddress ipaddress; if (hostNameOrAddress.Length > 0 && IPAddress.TryParse(hostNameOrAddress, out ipaddress)) { return new IPAddress[] { ipaddress }; } return Dns.GetHostEntry(hostNameOrAddress).AddressList; } /// Gets the DNS information for the specified DNS host name. /// An object that contains host information for the address specified in . /// The DNS name of the host. /// /// is null. /// The length of is greater than 126 characters. /// An error is encountered when resolving . /// /// /// /// /// /// // Token: 0x0600121D RID: 4637 RVA: 0x00036444 File Offset: 0x00034644 [Obsolete("Use GetHostEntry instead")] public static IPHostEntry GetHostByName(string hostName) { if (hostName == null) { throw new ArgumentNullException("hostName"); } string text; string[] array; string[] array2; if (!Dns.GetHostByName_internal(hostName, out text, out array, out array2)) { throw new global::System.Net.Sockets.SocketException(11001); } return Dns.hostent_to_IPHostEntry(text, array, array2); } /// Gets the host name of the local computer. /// A string that contains the DNS host name of the local computer. /// An error is encountered when resolving the local host name. /// /// /// // Token: 0x0600121E RID: 4638 RVA: 0x00036488 File Offset: 0x00034688 public static string GetHostName() { string text; if (!Dns.GetHostName_internal(out text)) { throw new global::System.Net.Sockets.SocketException(11001); } return text; } /// Resolves a DNS host name or IP address to an instance. /// An instance that contains address information about the host specified in . /// A DNS-style host name or IP address. /// /// is null. /// The length of is greater than 126 characters. /// An error is encountered when resolving . /// /// /// /// /// /// // Token: 0x0600121F RID: 4639 RVA: 0x000364B0 File Offset: 0x000346B0 [Obsolete("Use GetHostEntry instead")] public static IPHostEntry Resolve(string hostName) { if (hostName == null) { throw new ArgumentNullException("hostName"); } IPHostEntry iphostEntry = null; try { iphostEntry = Dns.GetHostByAddress(hostName); } catch { } if (iphostEntry == null) { iphostEntry = Dns.GetHostByName(hostName); } return iphostEntry; } // Token: 0x02000310 RID: 784 // (Invoke) Token: 0x06001C19 RID: 7193 private delegate IPHostEntry GetHostByNameCallback(string hostName); // Token: 0x02000311 RID: 785 // (Invoke) Token: 0x06001C1D RID: 7197 private delegate IPHostEntry ResolveCallback(string hostName); // Token: 0x02000312 RID: 786 // (Invoke) Token: 0x06001C21 RID: 7201 private delegate IPHostEntry GetHostEntryNameCallback(string hostName); // Token: 0x02000313 RID: 787 // (Invoke) Token: 0x06001C25 RID: 7205 private delegate IPHostEntry GetHostEntryIPCallback(IPAddress hostAddress); // Token: 0x02000314 RID: 788 // (Invoke) Token: 0x06001C29 RID: 7209 private delegate IPAddress[] GetHostAddressesCallback(string hostName); } }