Ticket #6645: use-edns-6839-2.patch

File use-edns-6839-2.patch, 30.0 KB (added by rwall, 2 years ago)

A patch showing what I think will be the simplest way to introduce _EDNSMessage. For discussion.

  • twisted/names/authority.py

     
    224224                    if rec.TYPE != dns.SOA:
    225225                        results.append(dns.RRHeader(k, rec.TYPE, dns.IN, ttl, rec, auth=True))
    226226            results.append(results[0])
    227             return defer.succeed((results, (), ()))
     227            return defer.succeed((results, [], []))
    228228        return defer.fail(failure.Failure(dns.DomainError(name)))
    229229
    230230    def _cbAllRecords(self, results):
  • twisted/names/client.py

     
    451451
    452452    def connectionMade(self, protocol):
    453453        # dig saids recursion-desired to 0, so I will too
    454         message = dns.Message(protocol.pickID(), recDes=0)
     454        message = dns._EDNSMessage(protocol.pickID(), recDes=0)
    455455        message.queries = [dns.Query(self.name, dns.AXFR, dns.IN)]
    456456        protocol.writeMessage(message)
    457457
  • twisted/names/dns.py

     
    25132513            # Assign the lower 4 bits to the message
    25142514            rCode=self.rCode & 0xf,
    25152515            authenticData=self.authenticData,
    2516             checkingDisabled=self.checkingDisabled)
     2516            checkingDisabled=self.checkingDisabled,
     2517            maxSize=self.maxSize)
    25172518
    25182519        m.queries = self.queries[:]
    25192520        m.answers = self.answers[:]
     
    26752676            query, or errbacked with any errors that could happen (exceptions
    26762677            during writing of the query, timeout errors, ...).
    26772678        """
    2678         m = Message(id, recDes=1)
     2679        m = _EDNSMessage(id, recDes=1)
    26792680        m.queries = queries
    26802681
    26812682        try:
     
    27372738        Read a datagram, extract the message in it and trigger the associated
    27382739        Deferred.
    27392740        """
    2740         m = Message()
     2741        m = _EDNSMessage()
    27412742        try:
    27422743            m.fromStr(data)
    27432744        except EOFError:
     
    28172818
    28182819        @type message: L{Message}
    28192820        """
     2821        # DNS messages should never be truncated over a stream transport.
     2822        # The way to prevent truncation (during encoding) is to set maxSize to 0
     2823        message.maxSize = 0
    28202824        s = message.toStr()
    28212825        self.transport.write(struct.pack('!H', len(s)) + s)
    28222826
     
    28462850
    28472851            if len(self.buffer) >= self.length:
    28482852                myChunk = self.buffer[:self.length]
    2849                 m = Message()
     2853                m = _EDNSMessage()
    28502854                m.fromStr(myChunk)
    28512855
    28522856                try:
  • twisted/names/server.py

     
    5959
    6060    protocol = dns.DNSProtocol
    6161    cache = None
    62     _messageFactory = dns.Message
     62    _messageFactory = dns._EDNSMessage
    6363
    6464
    6565    def __init__(self, authorities=None, caches=None, clients=None, verbose=0):
     
    147147        @type protocol: L{dns.DNSDatagramProtocol} or L{dns.DNSProtocol}
    148148
    149149        @param message: The DNS message to be sent.
    150         @type message: L{dns.Message}
     150        @type message: L{dns._EDNSMessage}
    151151
    152152        @param address: The address to which the message will be sent or L{None}
    153153            if C{protocol} is a stream protocol.
     
    248248        # here until #6949 is resolved.
    249249        response.maxSize = message.maxSize
    250250
     251        # Force EDNS off for now. This should mean that the server will behave
     252        # exactly as before. Then in the future we can turn this to 1 and also
     253        # set the maxSize appropriatly
     254        response.ednsVersion = None
     255
    251256        response.answers = answers
    252257        response.authority = authority
    253258        response.additional = additional
     
    284289
    285290        @param message: The original DNS query message for which a response
    286291            message will be constructed.
    287         @type message: L{dns.Message}
     292        @type message: L{dns._EDNSMessage}
    288293
    289294        @param address: The address to which the response message will be sent
    290295            or L{None} if C{protocol} is a stream protocol.
     
    324329
    325330        @param message: The original DNS query message for which a response
    326331            message will be constructed.
    327         @type message: L{dns.Message}
     332        @type message: L{dns._EDNSMessage}
    328333
    329334        @param address: The address to which the response message will be sent
    330335            or L{None} if C{protocol} is a stream protocol.
     
    365370
    366371        @param message: The original DNS query message for which a response
    367372            message will be constructed.
    368         @type message: L{dns.Message}
     373        @type message: L{dns._EDNSMessage}
    369374
    370375        @param address: The address to which the response message will be sent
    371376            or L{None} if C{protocol} is a stream protocol.
     
    401406
    402407        @param message: The original DNS query message for which a response
    403408            message will be constructed.
    404         @type message: L{dns.Message}
     409        @type message: L{dns._EDNSMessage}
    405410
    406411        @param address: The address to which the response message will be sent
    407412            or L{None} if C{protocol} is a stream protocol.
     
    429434
    430435        @param message: The original DNS query message for which a response
    431436            message will be constructed.
    432         @type message: L{dns.Message}
     437        @type message: L{dns._EDNSMessage}
    433438
    434439        @param address: The address to which the response message will be sent
    435440            or L{None} if C{protocol} is a stream protocol.
     
    457462
    458463        @param message: The original DNS query message for which a response
    459464            message will be constructed.
    460         @type message: L{dns.Message}
     465        @type message: L{dns._EDNSMessage}
    461466
    462467        @param address: The address to which the response message will be sent
    463468            or L{None} if C{protocol} is a stream protocol.
     
    485490
    486491        @param message: The original DNS query message for which a response
    487492            message will be constructed.
    488         @type message: L{dns.Message}
     493        @type message: L{dns._EDNSMessage}
    489494
    490495        @param address: The address to which the response message will be sent
    491496            or L{None} if C{protocol} is a stream protocol.
     
    518523        logged in more or less detail depending on the value of C{verbose}.
    519524
    520525        @param message: The DNS message that was received.
    521         @type message: L{dns.Message}
     526        @type message: L{dns._EDNSMessage}
    522527
    523528        @param proto: The DNS protocol instance which received the message
    524529        @type proto: L{dns.DNSDatagramProtocol} or L{dns.DNSProtocol}
     
    571576        Override in a subclass to implement alternative policies.
    572577
    573578        @param message: The DNS message that was received.
    574         @type message: L{dns.Message}
     579        @type message: L{dns._EDNSMessage}
    575580
    576581        @param protocol: The DNS protocol instance which received the message
    577582        @type protocol: L{dns.DNSDatagramProtocol} or L{dns.DNSProtocol}
  • twisted/names/test/test_client.py

     
    379379        # The response to the first query should be sent in response to both
    380380        # queries.
    381381        answer = object()
    382         response = dns.Message()
     382        response = dns._EDNSMessage()
    383383        response.answers.append(answer)
    384384        queries.pop()[-1].callback(response)
    385385
     
    438438        self.assertEqual(len(queries), 1)
    439439
    440440        # Deliver the response.
    441         queries.pop()[-1].callback(dns.Message())
     441        queries.pop()[-1].callback(dns._EDNSMessage())
    442442
    443443        # Repeating the first query should touch the protocol again.
    444444        resolver.query(query)
     
    518518
    519519            def query(self, address, query, timeout=10, id=None):
    520520                protocols.append(self)
    521                 return defer.succeed(dns.Message())
     521                return defer.succeed(dns._EDNSMessage())
    522522
    523523        resolver._connectedProtocol = FakeProtocol
    524524        resolver.query(dns.Query(b'foo.example.com'))
     
    554554        resolver = client.Resolver(servers=[('example.com', 53)])
    555555        protocols = []
    556556        results = [defer.fail(failure.Failure(DNSQueryTimeoutError(None))),
    557                    defer.succeed(dns.Message())]
     557                   defer.succeed(dns._EDNSMessage())]
    558558
    559559        class FakeProtocol(object):
    560560            def __init__(self):
     
    591591        resolver.query(dns.Query(b'foo.example.com'))
    592592
    593593        self.assertFalse(protocols[0].transport.disconnected)
    594         result.callback(dns.Message())
     594        result.callback(dns._EDNSMessage())
    595595        self.assertTrue(protocols[0].transport.disconnected)
    596596
    597597
     
    619619        resolver.query(dns.Query(b'foo.example.com'))
    620620
    621621        self.assertFalse(protocols[1].transport.disconnected)
    622         result.callback(dns.Message())
     622        result.callback(dns._EDNSMessage())
    623623        self.assertTrue(protocols[1].transport.disconnected)
    624624
    625625
     
    10561056        Test that a truncated message results in an equivalent request made via
    10571057        TCP.
    10581058        """
    1059         m = dns.Message(trunc=True)
    1060         m.addQuery(b'example.com')
     1059        m = dns._EDNSMessage(trunc=True, queries=[dns.Query(b'example.com')])
    10611060
    10621061        def queryTCP(queries):
    10631062            self.assertEqual(queries, m.queries)
    1064             response = dns.Message()
     1063            response = dns._EDNSMessage()
    10651064            response.answers = ['answer']
    10661065            response.authority = ['authority']
    10671066            response.additional = ['additional']
     
    10741073
    10751074
    10761075    def _rcodeTest(self, rcode, exc):
    1077         m = dns.Message(rCode=rcode)
     1076        m = dns._EDNSMessage(rCode=rcode)
    10781077        err = self.resolver.filterAnswers(m)
    10791078        err.trap(exc)
    10801079
  • twisted/names/test/test_dns.py

     
    229229            b'\x01\x02\x03\x04'      # 1.2.3.4
    230230            )
    231231
    232         msg = dns.Message()
     232        msg = dns._EDNSMessage()
    233233        msg.fromStr(wire)
    234234
    235235        self.assertEqual(msg.queries, [
     
    11491149        """
    11501150        d = self.proto.query(('127.0.0.1', 21345), [dns.Query(b'foo')])
    11511151        self.assertEqual(len(self.proto.liveMessages.keys()), 1)
    1152         m = dns.Message()
     1152        m = dns._EDNSMessage()
    11531153        m.id = next(iter(self.proto.liveMessages.keys()))
    11541154        m.answers = [dns.RRHeader(payload=dns.Record_A(address='1.2.3.4'))]
    11551155        def cb(result):
     
    12071207        L{DNSDatagramProtocol.liveMessages} or L{DNSDatagramProtocol.resends},
    12081208        the message will be received by L{DNSDatagramProtocol.controller}.
    12091209        """
    1210         message = dns.Message()
     1210        message = dns._EDNSMessage()
    12111211        message.id = 1
    12121212        message.answers = [dns.RRHeader(
    12131213            payload=dns.Record_A(address='1.2.3.4'))]
     
    12851285        """
    12861286        d = self.proto.query([dns.Query(b'foo')])
    12871287        self.assertEqual(len(self.proto.liveMessages.keys()), 1)
    1288         m = dns.Message()
     1288        m = dns._EDNSMessage()
    12891289        m.id = next(iter(self.proto.liveMessages.keys()))
    12901290        m.answers = [dns.RRHeader(payload=dns.Record_A(address='1.2.3.4'))]
    12911291        def cb(result):
     
    13161316        When receiving a message whose id is not in L{DNSProtocol.liveMessages}
    13171317        the message will be received by L{DNSProtocol.controller}.
    13181318        """
    1319         message = dns.Message()
     1319        message = dns._EDNSMessage()
    13201320        message.id = 1
    13211321        message.answers = [dns.RRHeader(
    13221322            payload=dns.Record_A(address='1.2.3.4'))]
  • twisted/names/test/test_names.py

     
    1414from twisted.internet import reactor, defer, error
    1515from twisted.internet.defer import succeed
    1616from twisted.names import client, server, common, authority, dns
    17 from twisted.names.dns import Message
     17from twisted.names.dns import _EDNSMessage
    1818from twisted.names.error import DomainError
    1919from twisted.names.client import Resolver
    2020from twisted.names.secondary import (
     
    475475
    476476    def _makeMessage(self):
    477477        # hooray they all have the same message format
    478         return dns.Message(id=999, answer=1, opCode=0, recDes=0, recAv=1, auth=1, rCode=0, trunc=0, maxSize=0)
     478        return dns._EDNSMessage(id=999, answer=1, opCode=0, recDes=0, recAv=1, auth=1, rCode=0, trunc=0, maxSize=0)
    479479
    480480    def testBindAndTNamesStyle(self):
    481481        # Bind style = One big single message
     
    852852                         auth=False,
    853853                         payload=dns.Record_NS(name='ns.twistedmatrix.com',
    854854                         ttl=700))]
    855         m = dns.Message(id=999, answer=1, opCode=0, recDes=0, recAv=1, auth=1,
    856                         rCode=0, trunc=0, maxSize=0)
     855        m = dns._EDNSMessage(id=999, answer=1, opCode=0, recDes=0, recAv=1, auth=1,
     856                             rCode=0, trunc=0, maxSize=0)
    857857        m.answers = records
    858858        messages.append(m)
    859859        return self.assertFailure(
     
    965965        transport = StringTransport()
    966966        proto.makeConnection(transport)
    967967
    968         msg = Message()
     968        msg = _EDNSMessage()
    969969        # DNSProtocol.writeMessage length encodes the message by prepending a
    970970        # 2 byte message length to the buffered value.
    971         msg.decode(StringIO(transport.value()[2:]))
     971        msg.fromStr(transport.value()[2:])
    972972
    973973        self.assertEqual(
    974974            [dns.Query('example.com', dns.AXFR, dns.IN)], msg.queries)
  • twisted/names/test/test_rootresolve.py

     
    2121from twisted.names.root import Resolver
    2222from twisted.names.dns import (
    2323    IN, HS, A, NS, CNAME, OK, ENAME, Record_CNAME,
    24     Name, Query, Message, RRHeader, Record_A, Record_NS)
     24    Name, Query, _EDNSMessage, RRHeader, Record_A, Record_NS)
    2525from twisted.names.error import DNSNameError, ResolverError
    2626
    2727
     
    187187        # And a DNS packet sent.
    188188        [(packet, address)] = transport._sentPackets
    189189
    190         msg = Message()
     190        msg = _EDNSMessage()
    191191        msg.fromStr(packet)
    192192
    193193        # It should be a query with the parameters used above.
     
    230230        L{Message} instance.
    231231        """
    232232        message = self._queryTest(False)
    233         self.assertIsInstance(message, Message)
     233        self.assertIsInstance(message, _EDNSMessage)
    234234        self.assertEqual(message.queries, [])
    235235        self.assertEqual(
    236236            message.answers,
     
    254254
    255255        @return: A new L{Message} initialized with the given values.
    256256        """
    257         response = Message(rCode=rCode)
     257        response = _EDNSMessage(rCode=rCode)
    258258        for (section, data) in [(response.answers, answers),
    259259                                (response.authority, authority),
    260260                                (response.additional, additional)]:
  • twisted/names/test/test_server.py

     
    436436        L{server.DNSServerFactory.messageReceived} logs about an empty query if
    437437        the message had no queries and C{verbose} is C{>0}.
    438438        """
    439         m = dns.Message()
     439        m = dns._EDNSMessage()
    440440        f = NoResponseDNSServerFactory(verbose=1)
    441441
    442442        assertLogMessage(
     
    451451        L{server.DNSServerFactory.messageReceived} logs the query types of all
    452452        queries in the message if C{verbose} is set to C{1}.
    453453        """
    454         m = dns.Message()
    455         m.addQuery(name='example.com', type=dns.MX)
    456         m.addQuery(name='example.com', type=dns.AAAA)
     454        m = dns._EDNSMessage(
     455            queries= [dns.Query(name='example.com', type=dns.MX),
     456                      dns.Query(name='example.com', type=dns.AAAA)])
    457457        f = NoResponseDNSServerFactory(verbose=1)
    458458
    459459        assertLogMessage(
     
    468468        L{server.DNSServerFactory.messageReceived} logs the repr of all queries
    469469        in the message if C{verbose} is set to C{2}.
    470470        """
    471         m = dns.Message()
    472         m.addQuery(name='example.com', type=dns.MX)
    473         m.addQuery(name='example.com', type=dns.AAAA)
     471        m = dns._EDNSMessage(
     472            queries=[dns.Query(name='example.com', type=dns.MX),
     473                     dns.Query(name='example.com', type=dns.AAAA)])
    474474        f = NoResponseDNSServerFactory(verbose=2)
    475475
    476476        assertLogMessage(
     
    486486        L{server.DNSServerFactory.messageReceived} assigns a unix timestamp to
    487487        the received message.
    488488        """
    489         m = dns.Message()
     489        m = dns._EDNSMessage()
    490490        f = NoResponseDNSServerFactory()
    491491        t = object()
    492492        self.patch(server.time, 'time', lambda: t)
     
    501501        L{server.DNSServerFactory.allowQuery} along with the receiving protocol
    502502        and origin address.
    503503        """
    504         message = dns.Message()
     504        message = dns._EDNSMessage()
    505505        dummyProtocol = object()
    506506        dummyAddress = object()
    507507
     
    535535        e = self.assertRaises(
    536536            SendReplyException,
    537537            f.messageReceived,
    538             message=dns.Message(), proto=None, address=None)
     538            message=dns._EDNSMessage(), proto=None, address=None)
    539539        (proto, message, address), kwargs = e.args
    540540
    541541        self.assertEqual(message.rCode, dns.EREFUSED)
     
    552552
    553553        @param message: The message which is expected to be passed to the
    554554            C{methodName} method.
    555         @type message: L{dns.Message}
     555        @type message: L{dns._EDNSMessage}
    556556        """
    557557        # Make it appear to have some queries so that
    558558        # DNSServerFactory.allowQuery allows it.
     
    575575        C{OP_QUERY} on to L{DNSServerFactory.handleQuery}.
    576576        """
    577577        self._messageReceivedTest(
    578             'handleQuery', dns.Message(opCode=dns.OP_QUERY))
     578            'handleQuery', dns._EDNSMessage(opCode=dns.OP_QUERY))
    579579
    580580
    581581    def test_inverseQueryMessageReceived(self):
     
    584584        C{OP_INVERSE} on to L{DNSServerFactory.handleInverseQuery}.
    585585        """
    586586        self._messageReceivedTest(
    587             'handleInverseQuery', dns.Message(opCode=dns.OP_INVERSE))
     587            'handleInverseQuery', dns._EDNSMessage(opCode=dns.OP_INVERSE))
    588588
    589589
    590590    def test_statusMessageReceived(self):
     
    593593        C{OP_STATUS} on to L{DNSServerFactory.handleStatus}.
    594594        """
    595595        self._messageReceivedTest(
    596             'handleStatus', dns.Message(opCode=dns.OP_STATUS))
     596            'handleStatus', dns._EDNSMessage(opCode=dns.OP_STATUS))
    597597
    598598
    599599    def test_notifyMessageReceived(self):
     
    602602        C{OP_NOTIFY} on to L{DNSServerFactory.handleNotify}.
    603603        """
    604604        self._messageReceivedTest(
    605             'handleNotify', dns.Message(opCode=dns.OP_NOTIFY))
     605            'handleNotify', dns._EDNSMessage(opCode=dns.OP_NOTIFY))
    606606
    607607
    608608    def test_updateMessageReceived(self):
     
    613613        This may change if the implementation ever covers update messages.
    614614        """
    615615        self._messageReceivedTest(
    616             'handleOther', dns.Message(opCode=dns.OP_UPDATE))
     616            'handleOther', dns._EDNSMessage(opCode=dns.OP_UPDATE))
    617617
    618618
    619619    def test_connectionTracking(self):
     
    640640        supplied message and dispatches it to
    641641        L{server.DNSServerFactory.resolver.query}.
    642642        """
    643         m = dns.Message()
    644         m.addQuery(b'one.example.com')
    645         m.addQuery(b'two.example.com')
     643        m = dns._EDNSMessage(
     644            queries=[dns.Query(b'one.example.com'),
     645                     dns.Query(b'two.example.com')])
    646646        f = server.DNSServerFactory()
    647647        f.resolver = RaisingResolver()
    648648
     
    675675            gotResolverResponseArgs.append((args, kwargs))
    676676        f.gotResolverResponse = fakeGotResolverResponse
    677677
    678         m = dns.Message()
    679         m.addQuery(b'one.example.com')
     678        m = dns._EDNSMessage(queries=[dns.Query(b'one.example.com')])
    680679        stubProtocol = NoopProtocol()
    681680        dummyAddress = object()
    682681
     
    711710            gotResolverErrorArgs.append((args, kwargs))
    712711        f.gotResolverError = fakeGotResolverError
    713712
    714         m = dns.Message()
    715         m.addQuery(b'one.example.com')
     713        m = dns._EDNSMessage(queries=[dns.Query(b'one.example.com')])
    716714        stubProtocol = NoopProtocol()
    717715        dummyAddress = object()
    718716
     
    740738            RaisingProtocol.WriteMessageArguments,
    741739            f.gotResolverResponse,
    742740            (answers, authority, additional),
    743             protocol=RaisingProtocol(), message=dns.Message(), address=None)
     741            protocol=RaisingProtocol(), message=dns._EDNSMessage(), address=None)
    744742        (message,), kwargs = e.args
    745743
    746744        self.assertIs(message.answers, answers)
     
    756754        f = NoResponseDNSServerFactory()
    757755        f._responseFromMessage = raiser
    758756
    759         m = dns.Message()
     757        m = dns._EDNSMessage()
    760758        m.timeReceived = 1
    761759
    762760        e = self.assertRaises(
     
    778776        message which is a copy of the request message.
    779777        """
    780778        f = server.DNSServerFactory()
    781         request = dns.Message(answer=False, recAv=False)
     779        request = dns._EDNSMessage(answer=False, recAv=False)
    782780        response = f._responseFromMessage(message=request),
    783781
    784782        self.assertIsNot(request, response)
     
    792790        """
    793791        f = server.DNSServerFactory()
    794792        f.canRecurse = True
    795         response1 = f._responseFromMessage(message=dns.Message(recAv=False))
     793        response1 = f._responseFromMessage(message=dns._EDNSMessage(recAv=False))
    796794        f.canRecurse = False
    797         response2 = f._responseFromMessage(message=dns.Message(recAv=True))
     795        response2 = f._responseFromMessage(message=dns._EDNSMessage(recAv=True))
    798796        self.assertEqual(
    799797            (True, False),
    800798            (response1.recAv, response2.recAv))
     
    807805        on the request.
    808806        """
    809807        f = server.DNSServerFactory()
    810         request = dns.Message()
     808        request = dns._EDNSMessage()
    811809        request.timeReceived = 1234
    812810        response = f._responseFromMessage(message=request)
    813811
     
    824822        on the request.
    825823        """
    826824        f = server.DNSServerFactory()
    827         request = dns.Message()
     825        request = dns._EDNSMessage()
    828826        request.maxSize = 0
    829827        response = f._responseFromMessage(message=request)
    830828
     
    837835    def test_messageFactory(self):
    838836        """
    839837        L{server.DNSServerFactory} has a C{_messageFactory} attribute which is
    840         L{dns.Message} by default.
     838        L{dns._EDNSMessage} by default.
    841839        """
    842         self.assertIs(dns.Message, server.DNSServerFactory._messageFactory)
     840        self.assertIs(dns._EDNSMessage, server.DNSServerFactory._messageFactory)
    843841
    844842
    845843    def test_responseFromMessageCallsMessageFactory(self):
     
    854852        self.patch(
    855853            f._messageFactory, '_responseFromMessage', staticmethod(raiser))
    856854
    857         requestMessage = dns.Message()
     855        requestMessage = dns._EDNSMessage()
    858856        e = self.assertRaises(
    859857            RaisedArguments,
    860858            f._responseFromMessage,
     
    873871        message as authoritative if any of the answer records are authoritative.
    874872        """
    875873        f = server.DNSServerFactory()
    876         response1 = f._responseFromMessage(message=dns.Message(),
     874        response1 = f._responseFromMessage(message=dns._EDNSMessage(),
    877875                                           answers=[dns.RRHeader(auth=True)])
    878         response2 = f._responseFromMessage(message=dns.Message(),
     876        response2 = f._responseFromMessage(message=dns._EDNSMessage(),
    879877                                           answers=[dns.RRHeader(auth=False)])
    880878        self.assertEqual(
    881879            (True, False),
     
    898896            ["Lookup found 3 records"],
    899897            f.gotResolverResponse,
    900898            (answers, authority, additional),
    901             protocol=NoopProtocol(), message=dns.Message(), address=None)
     899            protocol=NoopProtocol(), message=dns._EDNSMessage(), address=None)
    902900
    903901
    904902    def test_gotResolverResponseCaching(self):
     
    908906        """
    909907        f = NoResponseDNSServerFactory(caches=[RaisingCache()])
    910908
    911         m = dns.Message()
    912         m.addQuery(b'example.com')
     909        m = dns._EDNSMessage(queries=[dns.Query(b'example.com')])
    913910        expectedAnswers = [dns.RRHeader()]
    914911        expectedAuthority = []
    915912        expectedAdditional = []
     
    935932        f = NoResponseDNSServerFactory()
    936933        f._responseFromMessage = raiser
    937934
    938         m = dns.Message()
     935        m = dns._EDNSMessage()
    939936        m.timeReceived = 1
    940937
    941938        e = self.assertRaises(
     
    971968            RaisingProtocol.WriteMessageArguments,
    972969            f.gotResolverError,
    973970            failure.Failure(responseError),
    974             protocol=RaisingProtocol(), message=dns.Message(), address=None)
     971            protocol=RaisingProtocol(), message=dns._EDNSMessage(), address=None)
    975972        (message,), kwargs = e.args
    976973
    977974        self.assertEqual(message.rCode, expectedMessageCode)
     
    10161013            ["Lookup failed"],
    10171014            f.gotResolverError,
    10181015            failure.Failure(error.DomainError()),
    1019             protocol=NoopProtocol(), message=dns.Message(), address=None)
     1016            protocol=NoopProtocol(), message=dns._EDNSMessage(), address=None)
    10201017
    10211018
    10221019    def test_sendReplyWithAddress(self):
     
    10251022        *and* an address tuple it will supply that address to
    10261023        C{protocol.writeMessage}.
    10271024        """
    1028         m = dns.Message()
     1025        m = dns._EDNSMessage()
    10291026        dummyAddress = object()
    10301027        f = server.DNSServerFactory()
    10311028        e = self.assertRaises(
     
    10451042        no address tuple it will supply only a message to
    10461043        C{protocol.writeMessage}.
    10471044        """
    1048         m = dns.Message()
     1045        m = dns._EDNSMessage()
    10491046        f = server.DNSServerFactory()
    10501047        e = self.assertRaises(
    10511048            RaisingProtocol.WriteMessageArguments,
     
    10641061        the supplied message has no answers.
    10651062        """
    10661063        self.patch(server.time, 'time', lambda: 2)
    1067         m = dns.Message()
     1064        m = dns._EDNSMessage()
    10681065        m.timeReceived = 1
    10691066        f = server.DNSServerFactory(verbose=2)
    10701067        assertLogMessage(
     
    10831080        those sections.
    10841081        """
    10851082        self.patch(server.time, 'time', lambda: 2)
    1086         m = dns.Message()
     1083        m = dns._EDNSMessage()
    10871084        m.answers.append(dns.RRHeader(payload=dns.Record_A('127.0.0.1')))
    10881085        m.authority.append(dns.RRHeader(payload=dns.Record_A('127.0.0.1')))
    10891086        m.additional.append(dns.RRHeader(payload=dns.Record_A('127.0.0.1')))
     
    11101107        e = self.assertRaises(
    11111108            RaisingProtocol.WriteMessageArguments,
    11121109            f.handleInverseQuery,
    1113             message=dns.Message(), protocol=RaisingProtocol(), address=None)
     1110            message=dns._EDNSMessage(), protocol=RaisingProtocol(), address=None)
    11141111        (message,), kwargs = e.args
    11151112
    11161113        self.assertEqual(message.rCode, dns.ENOTIMP)
     
    11261123            self,
    11271124            ["Inverse query from ('::1', 53)"],
    11281125            f.handleInverseQuery,
    1129             message=dns.Message(),
     1126            message=dns._EDNSMessage(),
    11301127            protocol=NoopProtocol(),
    11311128            address=('::1', 53))
    11321129
     
    11401137        e = self.assertRaises(
    11411138            RaisingProtocol.WriteMessageArguments,
    11421139            f.handleStatus,
    1143             message=dns.Message(), protocol=RaisingProtocol(), address=None)
     1140            message=dns._EDNSMessage(), protocol=RaisingProtocol(), address=None)
    11441141        (message,), kwargs = e.args
    11451142
    11461143        self.assertEqual(message.rCode, dns.ENOTIMP)
     
    11561153            self,
    11571154            ["Status request from ('::1', 53)"],
    11581155            f.handleStatus,
    1159             message=dns.Message(),
     1156            message=dns._EDNSMessage(),
    11601157            protocol=NoopProtocol(),
    11611158            address=('::1', 53))
    11621159
     
    11701167        e = self.assertRaises(
    11711168            RaisingProtocol.WriteMessageArguments,
    11721169            f.handleNotify,
    1173             message=dns.Message(), protocol=RaisingProtocol(), address=None)
     1170            message=dns._EDNSMessage(), protocol=RaisingProtocol(), address=None)
    11741171        (message,), kwargs = e.args
    11751172
    11761173        self.assertEqual(message.rCode, dns.ENOTIMP)
     
    11861183            self,
    11871184            ["Notify message from ('::1', 53)"],
    11881185            f.handleNotify,
    1189             message=dns.Message(),
     1186            message=dns._EDNSMessage(),
    11901187            protocol=NoopProtocol(),
    11911188            address=('::1', 53))
    11921189
     
    12001197        e = self.assertRaises(
    12011198            RaisingProtocol.WriteMessageArguments,
    12021199            f.handleOther,
    1203             message=dns.Message(), protocol=RaisingProtocol(), address=None)
     1200            message=dns._EDNSMessage(), protocol=RaisingProtocol(), address=None)
    12041201        (message,), kwargs = e.args
    12051202
    12061203        self.assertEqual(message.rCode, dns.ENOTIMP)
     
    12161213            self,
    12171214            ["Unknown op code (0) from ('::1', 53)"],
    12181215            f.handleOther,
    1219             message=dns.Message(),
     1216            message=dns._EDNSMessage(),
    12201217            protocol=NoopProtocol(),
    12211218            address=('::1', 53))