상속: IServerResponse
예제 #1
0
 protected void EnhanceService(Answer a)
 {
     switch (a.Type)
     {
         case Network.Dns.Type.A:
         case Network.Dns.Type.AAAA:
             foreach (Network.Dns.EndPoint ep in addresses)
             {
                 if (a.DomainName.ToString() == ep.DomainName.ToString())
                     ep.Resolve(a);
                 if (ep.Addresses.Count > 0)
                     resolved.Set();
             }
             break;
         case Network.Dns.Type.NS:
             break;
         case Network.Dns.Type.CNAME:
             break;
         case Network.Dns.Type.SOA:
             break;
         case Network.Dns.Type.WKS:
             break;
         case Network.Dns.Type.PTR:
             if (string.IsNullOrEmpty(Name))
                 Name = ((Ptr)a.ResponseData).DomainName[0];
             if (string.IsNullOrEmpty(Protocol))
                 Protocol = a.DomainName;
             break;
         case Network.Dns.Type.HINFO:
             break;
         case Network.Dns.Type.MINFO:
             break;
         case Network.Dns.Type.MX:
             break;
         case Network.Dns.Type.TXT:
             if (properties == null || properties.Count == 0)
                 properties = ((Txt)a.ResponseData).Properties;
             break;
         case Network.Dns.Type.SRV:
             if (HostName == null)
                 HostName = ((Srv)a.ResponseData).Target;
             if (Name == null)
                 Name = a.DomainName[0];
             if (Protocol == null)
                 Protocol = new DomainName(a.DomainName.Skip(1));
             if (addresses.Count == 0)
                 AddAddress(new Network.Dns.EndPoint() { DomainName = HostName, Port = ((Srv)a.ResponseData).Port });
             break;
         default:
             break;
     }
     if (a.Ttl == 0)
         State = State.Removed;
     else
         expiration = expiration.AddSeconds(a.Ttl);
 }
예제 #2
0
 public void Resolve(Answer a)
 {
     if (a.Type == Type.SRV)
     {
         DomainName = ((Srv)a.ResponseData).Target;
         Port = ((Srv)a.ResponseData).Port;
     }
     if (a.Type == Type.A || a.Type == Type.AAAA)
     {
         IPAddress address = ((HostAddress)a.ResponseData).Address;
         if (!Addresses.Contains(address))
             Addresses.Add(address);
     }
 }
예제 #3
0
 internal static Answer Get(System.IO.BinaryReader reader)
 {
     Answer a = new Answer();
     a.DomainName = DomainName.Get(reader);
     ushort s;
     Message.FromBytes(reader.ReadBytes(2), out s);
     a.Type = (Type)s;
     Message.FromBytes(reader.ReadBytes(2), out s);
     a.Class = (Class)s;
     uint ttl;
     Message.FromBytes(reader.ReadBytes(4), out ttl);
     a.Ttl = ttl;
     a.ResponseData = ResponseData.Get(a.Type, reader);
     return a;
 }
예제 #4
0
 private Service(Answer a)
     : this()
 {
     EnhanceService(a);
 }
예제 #5
0
 private static Service Build(Answer answer, Message message)
 {
     Service s = new Service(answer);
     foreach (Answer a in message.Additionals)
         s.EnhanceService(a);
     return s;
 }