Ejemplo n.º 1
0
        /// <summary> Does the necessary actions, when this as a response.</summary>
        internal override bool HandleResponse(mDNS dns)
        {
            Address dnsAddress = dns.LocalHost.GetDNSAddressRecord(this);

            if (dnsAddress != null)
            {
                if (dnsAddress.SameType(this) && dnsAddress.SameName(this) && (!dnsAddress.SameValue(this)))
                {
                    logger.Debug("handleResponse() Denial detected");

                    if (dns.State.Probing)
                    {
                        dns.LocalHost.IncrementHostName();
                        dns.Cache.clear();
                        foreach (ServiceInfo info in dns.services)
                        {
                            info.RevertState();
                        }
                    }
                    dns.RevertState();
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
        /// <summary> Does the necessary actions, when this as a query.</summary>
        internal override bool HandleQuery(mDNS dns, long expirationTime)
        {
            Address dnsAddress = dns.LocalHost.GetDNSAddressRecord(this);

            if (dnsAddress != null)
            {
                if (dnsAddress.SameType(this) && dnsAddress.SameName(this) && (!dnsAddress.SameValue(this)))
                {
                    logger.Debug("handleQuery() Conflicting probe detected. dns state " + dns.State + " lex compare " + lexCompare(dnsAddress));
                    // Tie-breaker test
                    if (dns.State.Probing && lexCompare(dnsAddress) >= 0)
                    {
                        // We lost the tie-break. We have to choose a different name.
                        dns.LocalHost.IncrementHostName();
                        dns.Cache.clear();

                        foreach (ServiceInfo info in dns.services)
                        {
                            info.RevertState();
                        }
                    }
                    dns.RevertState();
                    return(true);
                }
            }
            return(false);
        }