MCPcopy Create free account
hub / github.com/Cryptogenic/PS5-IPV6-Kernel-Exploit / match

Method match

fakedns.py:581–623  ·  view source on GitHub ↗

See if the request matches any rules in the rule list by calling the match function of each rule in the list The rule checks two things before it continues so I imagine this is probably still fast

(self, query, addr)

Source from the content-addressed store, hash-verified

579
580
581 def match(self, query, addr):
582 """
583 See if the request matches any rules in the rule list by calling the
584 match function of each rule in the list
585 The rule checks two things before it continues so I imagine this is
586 probably still fast
587 """
588 for rule in self.rule_list:
589 result = rule.match(query.type, query.domain, addr)
590 if result is not None:
591 response_data = result
592
593 # Return Nonefound if the rule says "none"
594 if response_data.lower() == 'none':
595 return NONEFOUND(query).make_packet()
596
597 response = CASE[query.type](query, response_data)
598
599 print(">> Matched Request - " + query.domain.decode())
600 return response.make_packet()
601
602 # if we got here, we didn't match.
603 # Forward a request that we didnt have a rule for to someone else
604
605 # if the user said not to forward requests, and we are here, it's time to send a NONEFOUND
606 if args.noforward:
607 print(">> Don't Forward %s" % query.domain.decode())
608 return NONEFOUND(query).make_packet()
609 try:
610 s = socket.socket(type=socket.SOCK_DGRAM)
611 s.settimeout(3.0)
612 addr = ('%s' % (args.dns), 53)
613 s.sendto(query.data, addr)
614 data = s.recv(1024)
615 s.close()
616 print("Unmatched Request " + query.domain.decode())
617 return data
618 except socket.error as e:
619 # We shouldn't wind up here but if we do, don't drop the request
620 # send the client *something*
621 print(">> Error was handled by sending NONEFOUND")
622 print(e)
623 return NONEFOUND(query).make_packet()
624
625
626# Convenience method for threading.

Callers

nothing calls this directly

Calls 4

NONEFOUNDClass · 0.85
printFunction · 0.85
make_packetMethod · 0.80
matchMethod · 0.45

Tested by

no test coverage detected