Exemple #1
0
				public static RecordPTR Get(IPAddress target, IPAddress localAddress, byte attempts = 2, int timeout = 1000)
				{
					var packet = new LlmnrPacket();
					packet.Questions = new[] {new DnsLlmnrQuestion {Type = DnsLlmnrCodes.QTypes.PTR, Name = target.GetAddrArpaString()}};

					var responsePacket = packet.Send(Ipv4MulticastEndpoint, localAddress, attempts, timeout);
					if (responsePacket.Header.RCode != DnsLlmnrCodes.RCodes.NoError)
						throw new CfnException(responsePacket.Header.RCode.GetThrowMessage());

					return responsePacket.Answers[0].Record as RecordPTR;
				}
Exemple #2
0
					public static RecordPTR[] Get(IPAddress target, IPAddress dnsServer, IPAddress localAddress, int attempts = 2, int timeout = 1000)
					{
						if (dnsServer.AddressFamily != localAddress.AddressFamily)
							throw new CfnIpFamilyMismatchException();

						var requestPacket = new DnsPacket();
						requestPacket.Header.RecursionDesired = true;
						requestPacket.Questions = new[] {new DnsLlmnrQuestion {Name = target.GetAddrArpaString(), Type = DnsLlmnrCodes.QTypes.PTR}};

						var responsePacket = requestPacket.Send(dnsServer, 53, localAddress, attempts, timeout);
						if (responsePacket.Header.RCode != DnsLlmnrCodes.RCodes.NoError && responsePacket.Header.RCode != DnsLlmnrCodes.RCodes.NxDomain)
							throw new CfnException(responsePacket.Header.RCode.GetThrowMessage());

						return responsePacket.Answers.Where(x => x.Type == DnsLlmnrCodes.RrTypes.PTR).Select(x => ((RecordPTR) x.Record)).ToArray();
					}