Skip to content

Instantly share code, notes, and snippets.

@machbot
Forked from FiloSottile/no-aaaa.py
Last active February 29, 2024 08:09
Show Gist options
  • Save machbot/9d58c310905fa167da48547d3f1fdceb to your computer and use it in GitHub Desktop.
Save machbot/9d58c310905fa167da48547d3f1fdceb to your computer and use it in GitHub Desktop.

Revisions

  1. machbot revised this gist Feb 16, 2022. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions no-aaaa.py
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,7 @@ def inform_super(id, qstate, superqstate, qdata):
    "nflxso.net.",
    "gov.sg.",
    "aaplimg.com.",
    "ftx.com."
    ]

    def operate(id, event, qstate, qdata):
  2. machbot revised this gist May 20, 2020. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions no-aaaa.py
    Original file line number Diff line number Diff line change
    @@ -11,6 +11,7 @@ def inform_super(id, qstate, superqstate, qdata):
    "netflix.com.",
    "nflxso.net.",
    "gov.sg.",
    "aaplimg.com.",
    ]

    def operate(id, event, qstate, qdata):
  3. machbot revised this gist May 20, 2020. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions no-aaaa.py
    Original file line number Diff line number Diff line change
    @@ -10,6 +10,7 @@ def inform_super(id, qstate, superqstate, qdata):
    domains = [
    "netflix.com.",
    "nflxso.net.",
    "gov.sg.",
    ]

    def operate(id, event, qstate, qdata):
  4. @FiloSottile FiloSottile created this gist Jun 25, 2017.
    44 changes: 44 additions & 0 deletions no-aaaa.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    def init(id, cfg):
    return True

    def deinit(id):
    return True

    def inform_super(id, qstate, superqstate, qdata):
    return True

    domains = [
    "netflix.com.",
    "nflxso.net.",
    ]

    def operate(id, event, qstate, qdata):
    if event == MODULE_EVENT_NEW or event == MODULE_EVENT_PASS:
    if qstate.qinfo.qtype != RR_TYPE_AAAA:
    qstate.ext_state[id] = MODULE_WAIT_MODULE
    return True

    for domain in domains:
    if qstate.qinfo.qname_str == domain or qstate.qinfo.qname_str.endswith("." + domain):
    msg = DNSMessage(qstate.qinfo.qname_str, RR_TYPE_A, RR_CLASS_IN, PKT_QR | PKT_RA | PKT_AA)
    if not msg.set_return_msg(qstate):
    qstate.ext_state[id] = MODULE_ERROR
    return True
    # We don't need validation, result is valid
    qstate.return_msg.rep.security = 2
    qstate.return_rcode = RCODE_NOERROR
    qstate.ext_state[id] = MODULE_FINISHED
    log_info("no-aaaa: blocking AAAA request for %s" % qstate.qinfo.qname_str)
    return True

    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

    log_info("pythonmod: script loaded")