Пример #1
0
        internal List <DnsRecordBase> ProcessQuery(DnsQuestion question)
        {
            IPAddress ip = null;

            if (state_.Config.Dns.CatchAll)
            {
                ip = CatchAllProcessQuery(question);
            }
            else
            {
                Interception interception = state_.Config.GetInterception(question.Name);
                if (interception == null)
                {
                    state_.Logger.Debug("No interception for '{0}' found", question.Name);
                    return(null);
                }

                ip = GetIp(interception);
            }

            if (null == ip)
            {
                state_.Logger.Information("No IP found for '{0}'", question.Name);
                return(null);
            }

            List <DnsRecordBase> result = new List <DnsRecordBase>();

            state_.Logger.Information("DNS {1} {0} TTL {2}", ip, question.Name, state_.Config.Dns.AnswerTtl);
            result.Add(new ARecord(question.Name, state_.Config.Dns.AnswerTtl, ip));
            return(result);
        }
Пример #2
0
        private IPAddress CatchAllProcessQuery(DnsQuestion question)
        {
            // If there is an interception configured, take it
            Interception interception = state_.Config.GetInterception(question.Name);

            if (interception != null)
            {
                return(GetIp(interception));
            }

            return(state_.AllocateIP(question.Name));
        }
Пример #3
0
        private IPAddress GetIp(Interception interception)
        {
            string configuredIp = GetConfiguredIp(interception);

            if (String.IsNullOrWhiteSpace(configuredIp))
            {
                state_.Logger.Debug("No IP configured, take the default one: {0}", defaultIp_);
                return(defaultIp_);
            }

            try
            {
                return(state_.AllocateIP(interception.Name, IPAddress.Parse(configuredIp)));
            }
            catch (FormatException)
            {
                state_.Logger.Error("{0} is not a valid IP address", configuredIp);
                return(null);
            }
        }
Пример #4
0
 protected override string GetConfiguredIp(Interception interception)
 {
     return(interception.IPv6);
 }
Пример #5
0
 protected abstract string GetConfiguredIp(Interception interception);
Пример #6
0
 protected override string GetConfiguredIp(Interception interception)
 {
     return interception.IPv4;
 }
Пример #7
0
        private IPAddress GetIp(Interception interception)
        {
            string configuredIp = GetConfiguredIp(interception);
            if(String.IsNullOrWhiteSpace(configuredIp))
            {
                state_.Logger.Debug("No IP configured, take the default one: {0}", defaultIp_);
                return defaultIp_;
            }

            try
            {
                return state_.AllocateIP(interception.Name, IPAddress.Parse(configuredIp));
            }
            catch(FormatException)
            {
                state_.Logger.Error("{0} is not a valid IP address", configuredIp);
                return null;
            }
        }
Пример #8
0
 protected abstract string GetConfiguredIp(Interception interception);