Implements TSIG signing of DNS messages as per RFC2845
This class only supports the one hashing algorithim, hmac-sha256. It would be trivial to add more.
Inheritance: IMessageSecurityProvider
Exemplo n.º 1
0
        public DnsQueryResponse Resolve(string host, NsType queryType, NsClass queryClass, ProtocolType protocol, TsigMessageSecurityProvider provider)
        {
            string dnsServer = string.Empty;

            // Test for Unix/Linux OS
            if (Tools.IsPlatformLinuxUnix())
            {
                dnsServer = Tools.DiscoverUnixDnsServerAddress();
            }
            else
            {
                IPAddressCollection dnsServerCollection = Tools.DiscoverDnsServerAddresses();
                if (dnsServerCollection.Count == 0)
                    throw new Exception("Couldn't detect local DNS Server.");

                dnsServer = dnsServerCollection[0].ToString();
            }

            if (String.IsNullOrEmpty(dnsServer))
                throw new Exception("Couldn't detect local DNS Server.");

            return Resolve(dnsServer, host, queryType, queryClass, protocol, provider);
        }
Exemplo n.º 2
0
 public DnsQueryResponse Resolve(string host, NsType queryType, NsClass queryClass, ProtocolType protocol, TsigMessageSecurityProvider provider)
 {
     foreach (var server in GetDnsServers ()) {
         try {
             return Resolve (server, host, queryType, queryClass, protocol, provider);
         } catch (Exception ex) {
             Console.WriteLine (string.Format ("DnsQueryRequest.Resolve: Could not resolve host {0}: {1}", host, ex));
         }
     }
     return null;
 }