示例#1
0
 def resolved(results):
     answers, authority, additional = results
     self.assertEqual(
         (RRHeader(b"ip6-multiple", AAAA, IN, self.ttl,
                   Record_AAAA("::3", self.ttl)),
          RRHeader(b"ip6-multiple", AAAA, IN, self.ttl,
                   Record_AAAA("::4", self.ttl))),
         answers)
示例#2
0
 def test_lookupIPV6Address(self):
     """
     L{hosts.Resolver.lookupIPV6Address} returns a L{Deferred} which fires
     with AAAA records from the hosts file.
     """
     d = self.resolver.lookupIPV6Address(b'ip6-multiple')
     answers, authority, additional = self.successResultOf(d)
     self.assertEqual((RRHeader(b"ip6-multiple", AAAA, IN, self.ttl,
                                Record_AAAA("::3", self.ttl)),
                       RRHeader(b"ip6-multiple", AAAA, IN, self.ttl,
                                Record_AAAA("::4", self.ttl))), answers)
示例#3
0
 def test_lookupIPV6Malformed(self):
     """
     Like L{test_lookupAddressMalformed}, but for
     L{hosts.Resolver.lookupIPV6Address}.
     """
     d = self.resolver.lookupIPV6Address(b"malformed")
     [answer], authority, additional = self.successResultOf(d)
     self.assertEqual(
         RRHeader(b"malformed", AAAA, IN, self.ttl, Record_AAAA("::5", self.ttl)),
         answer,
     )
示例#4
0
async def get_response(query: Query):
    name = query.name.name
    if name.endswith(b'.'): name = name[:-1]
    if not name.endswith(b'.lo0.wtf'): raise DomainError()
    results = []
    if query.type in (AAAA, ALL_RECORDS):
        name = name[:-8]
        vhost, username = name.rsplit(b'.', 1)
        vhost_hash = CityHash32(vhost)
        username_hash = CityHash32(username)
        ip = NETWORK[(username_hash << 32) + vhost_hash]
        results.append(
            RRHeader(
                name=query.name.name,
                type=AAAA,
                ttl=60,
                payload=Record_AAAA(address=str(ip).encode('ascii')),
            ))
    if query.type in (SOA, ALL_RECORDS) and name == b'':
        results.append(SOA_OBJ)
    return results
示例#5
0
 def resolved((results, authority, additional)):
     self.assertEqual((RRHeader("ip6-multiple", AAAA, IN, self.ttl,
                                Record_AAAA("::3", self.ttl)),
                       RRHeader("ip6-multiple", AAAA, IN, self.ttl,
                                Record_AAAA("::4", self.ttl))), results)