<div dir="ltr">Hi All,<br><br><br>I am working on feature for our DNS server to avoid forwarding queries to parent domains, if dns query already contains ip address where delimiter is: "-"<br>example:<br>ip-10-29-171-225.us-west-2.compute.internal.<br><br>The code looks like:<br>if query_domain.endswith(('compute.internal.','ec2.internal.', 'compute.amazonaws.com.', 'compute-1.amazonaws.com.')) or (len(query_domain.split(".")) == 1):<br>            parse_domain = re.match("(ip|ec2)-((?:\d{1,3}-){3}\d{1,3})$", query_domain.split(".")[0])<br><br>            if parse_domain:<br>                ip_address = parse_domain.groups()[1].replace("-", ".")<br><br>                #create instance of DNS message (packet) with given parameters<br>                msg = DNSMessage(query_domain, RR_TYPE_A, RR_CLASS_IN, PKT_QR | PKT_RA | PKT_AA)<br>                #append RR<br>                if (qstate.qinfo.qtype == RR_TYPE_A) or (qstate.qinfo.qtype == RR_TYPE_ANY):<br>                    log_info("[dnsrabbit] request to compute internal domain: %s response auto generated with ip: %s, type: %s" % (str(query_domain), str(ip_address), str(str(qstate.qinfo.qtype))))<br><br>                    msg.answer.append("%s 3600 IN A %s" % (query_domain, ip_address))<br>                #set qstate.return_msg<br>                if not msg.set_return_msg(qstate):<br>                    qstate.ext_state[id] = MODULE_ERROR<br>                    return True<br><br>                #we don't need validation, result is valid<br>                qstate.return_msg.rep.security = 2<br>                qstate.return_rcode = RCODE_NOERROR<br><br><br><br>                run_somefunction()<br><br><br>                qstate.ext_state[id] = MODULE_FINISHED<br>                return True<br><br><br>In my code I have next problem:<br>function: run_somefunction  calls for each dns query which is overloaded this function.<br>I tried to add: storeQueryInCache in my cache, and record successfully stored in cache, but new queries which arrived to my dns again processed my function:  run_somefunction<br><br>if there any possibility to check, if record already present in cache?<br><br><br></div>