Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def operate(id, event, qstate, qdata):
- if (event == MODULE_EVENT_NEW) or (event == MODULE_EVENT_PASS):
- name = qstate.qinfo.qname_str.rstrip('.')
- # Find out source IP address
- rl = qstate.mesh_info.reply_list
- while (rl):
- if rl.query_reply:
- q = rl.query_reply
- break
- rl = rl.next
- # Careful with this conditional
- try: addr = q.addr
- except NameError: addr = None
- if (addr == "192.168.1.13") and (name == "test.inbox2.eu"):
- msg = DNSMessage(qstate.qinfo.qname_str, RR_TYPE_A, RR_CLASS_IN, PKT_QR | PKT_RA | PKT_AA)
- if (qstate.qinfo.qtype == RR_TYPE_A) or (qstate.qinfo.qtype == RR_TYPE_ANY):
- msg.answer.append("%s 10 IN A %s" % (qstate.qinfo.qname_str, "192.168.1.254"))
- if not msg.set_return_msg(qstate):
- qstate.ext_state[id] = MODULE_ERROR
- return True
- qstate.return_msg.rep.security = 2
- qstate.return_rcode = RCODE_NOERROR
- qstate.ext_state[id] = MODULE_FINISHED
- return True
- # not the name we are interested in
- else:
- qstate.ext_state[id] = MODULE_WAIT_MODULE
- return True
- if event == MODULE_EVENT_MODDONE:
- qstate.ext_state[id] = MODULE_FINISHED
- return True
- qstate.ext_state[id] = MODULE_ERROR
- return True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement