[Twisted-Python] Failed to load application: cannot import name app

Jesper Taxbøl jesper at taxboel.dk
Tue Jul 7 09:20:41 MDT 2009


Hi Guys,

I stumpled upon a small dns filter program, that I am having trouble
running, due to "twisted.internet.app" being deprecated. I get the following
output "Failed to load application: cannot import name app"

Im running "twistd (the Twisted daemon) 2.5.0"

Any advice on how to proceed?

Kind regards

Tax

#!/usr/bin/python
#
# Run this as root with the command
#   twistd -y dnsfilter.py

from twisted.internet import app, defer
from twisted.protocols import dns
from twisted.names import client, server

roots = [
('198.41.0.4',53), ('128.9.0.107',53), ('192.33.4.12',53),
('128.8.10.90',53),
('192.203.230.10',53), ('192.5.5.241',53), ('192.112.36.4',53),
('128.63.2.53',53), ('192.36.148.17',53), ('192.58.128.30',53),
('193.0.14.129',53), ('198.32.64.12',53), ('202.12.27.33',53), ]

#roots = [('202.129.64.42',53)]   # just use my ISP's DNS

VERISIGN='@^n\x0b' # 64.94.110.11

class AntiVerisignResolver(client.Resolver):
    def filterAnswers(self, message):
        if message.trunc:
            return
self.queryTCP(message.queries).addCallback(self.filterAnswers)
        else:
            for i in range(len(message.answers)):
                x = message.answers[i]
                if x.type==1 and x.payload and x.payload.address==VERISIGN:
                    message.answers[i] = None
            return (filter(lambda x:x,message.answers),
                    message.authority,
                    message.additional)

verbosity = 0
resolver = AntiVerisignResolver(servers=roots)
f = server.DNSServerFactory(clients=[resolver], verbose=verbosity)
p = dns.DNSDatagramProtocol(f)
f.noisy = p.noisy = verbosity

application = app.Application('Non caching anti-verisign domain name
resolver')
application.listenUDP(53, p)
application.listenTCP(53, f)


src:
http://osdir.com/ml/python.twisted/2003-09/msg00055.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20090707/28f63316/attachment.html>


More information about the Twisted-Python mailing list