Hi Guys,<br><br>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"<br>
<br>Im running "twistd (the Twisted daemon) 2.5.0"<br><br>Any advice on how to proceed?<br><br>Kind regards<br><br>Tax<br><br>#!/usr/bin/python<br>#<br># Run this as root with the command<br># twistd -y dnsfilter.py<br>
<br>from twisted.internet import app, defer<br>from twisted.protocols import dns<br>from twisted.names import client, server<br><br>roots = [<br>('198.41.0.4',53), ('128.9.0.107',53), ('192.33.4.12',53), ('128.8.10.90',53),<br>
('192.203.230.10',53), ('192.5.5.241',53), ('192.112.36.4',53),<br>('128.63.2.53',53), ('192.36.148.17',53), ('192.58.128.30',53),<br>('193.0.14.129',53), ('198.32.64.12',53), ('202.12.27.33',53), ]<br>
<br>#roots = [('202.129.64.42',53)] # just use my ISP's DNS<br><br>VERISIGN='@^n\x0b' # 64.94.110.11<br><br>class AntiVerisignResolver(client.Resolver):<br> def filterAnswers(self, message):<br> if message.trunc:<br>
return self.queryTCP(message.queries).addCallback(self.filterAnswers)<br> else:<br> for i in range(len(message.answers)):<br> x = message.answers[i]<br> if x.type==1 and x.payload and x.payload.address==VERISIGN:<br>
message.answers[i] = None<br> return (filter(lambda x:x,message.answers),<br> message.authority,<br> message.additional)<br><br>verbosity = 0<br>resolver = AntiVerisignResolver(servers=roots)<br>
f = server.DNSServerFactory(clients=[resolver], verbose=verbosity)<br>p = dns.DNSDatagramProtocol(f)<br>f.noisy = p.noisy = verbosity<br><br>application = app.Application('Non caching anti-verisign domain name resolver')<br>
application.listenUDP(53, p)<br>application.listenTCP(53, f)<br><br><br>src:<br><a href="http://osdir.com/ml/python.twisted/2003-09/msg00055.html">http://osdir.com/ml/python.twisted/2003-09/msg00055.html</a><br>