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); }
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)); }
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); } }
protected override string GetConfiguredIp(Interception interception) { return(interception.IPv6); }
protected abstract string GetConfiguredIp(Interception interception);
protected override string GetConfiguredIp(Interception interception) { return interception.IPv4; }
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; } }
protected abstract string GetConfiguredIp(Interception interception);