The unified diff between revisions [302f7b3f..] and [1f414f68..] is displayed below. It can also be downloaded as a raw diff.
#
#
# add_file "twistedrbl.py"
# content [be28b7fcae565230b2cbdd157aa5d3707af6056c]
#
# patch "buildmt.sh"
# from [bfa09601fa7c8686f2b2d5ace821d47f63394df5]
# to [e5809a3784ae71fabefd255c6eed5254c77ba867]
#
# set "twistedrbl.py"
# attr "mtn:execute"
# value "true"
#
============================================================
--- twistedrbl.py be28b7fcae565230b2cbdd157aa5d3707af6056c
+++ twistedrbl.py be28b7fcae565230b2cbdd157aa5d3707af6056c
@@ -0,0 +1,44 @@
+#!/usr/bin/env python2.4
+
+from twisted.internet import stdio
+from twisted.protocols import basic
+from twisted.names import client
+import fcntl, os, sys, re
+
+spam_info_re = re.compile(r'^(?P<date>[^ ]+ [^ ]+ [^ ]+) (?P<scannerhost>[^ ]+) filter-module\[(?P<pid>\d+)\]: (?P<queueid>\w+): spam_status=(?P<spamstatus>[^ ]+) \(from=(?P<from>[^ ]*) to=(?P<to>[^ ]*) uwa_client_ip= ?(?P<ip>[\d\.]+) \((?P<class>[^\)]+)\) message_id= ?(?P<message_id>.*)$')
+
+def set_nonblocking(fd):
+ fl = fcntl.fcntl(fd, fcntl.F_GETFL)
+ fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NDELAY)
+
+class Echo(basic.LineReceiver):
+ delimiter = '\n'
+ def __init__(self, log_fd):
+ self.log_fd = log_fd
+ self.resolver = client.createResolver()
+
+ def connectionMade(self):
+ self.log_fd.write('Connection established.\n')
+
+ def dns_response(self, line, is_ok, result):
+ if is_ok:
+ self.log_fd.write("got a response: %s for %s\n" % (result, line))
+
+ def lineReceived(self, line):
+ match = spam_info_re.match(line)
+ if not match:
+ return
+ match = match.groupdict()
+ ip_address = match['ip']
+ ipr = '.'.join(reversed(ip_address.split('.'))) + '.' + 'dnsbl.sorbs.net'
+ self.log_fd.write('starting query up for %s\n' % (ipr))
+ deferred = self.resolver.getHostByName(ipr)
+ response = lambda x: self.dns_response(match, True, x)
+ error = lambda x: self.dns_response(match, False, x)
+ deferred.addCallbacks(response, error)
+
+if __name__ == '__main__':
+ log_fd = open('log.txt', 'w')
+ stdio.StandardIO(Echo(log_fd))
+ from twisted.internet import reactor
+ reactor.run()
============================================================
--- buildmt.sh bfa09601fa7c8686f2b2d5ace821d47f63394df5
+++ buildmt.sh e5809a3784ae71fabefd255c6eed5254c77ba867
@@ -7,6 +7,8 @@ BOOSTDEST="$MONOTONE/$BOOSTVER/"
BOOST="$HOME/mtn/support/$BOOSTVER/"
MONOTONE="$HOME/mtn/monotone/"
BOOSTDEST="$MONOTONE/$BOOSTVER/"
+# should probably use "gdb" on everything except MacOS
+DEBUGSYMS="stabs"
cd "$BOOST" || exit 1
mkdir -p "$BOOSTDEST"/libs
@@ -22,7 +24,7 @@ AUTOMAKE=automake-1.9 ACLOCAL=aclocal-1.
cd "$MONOTONE" &&
AUTOMAKE=automake-1.9 ACLOCAL=aclocal-1.9 autoreconf --install &&
-./configure --prefix=/opt/mtn \
- CC="ccache gcc" CXX="ccache g++" CFLAGS="-Os -ggdb" CXXFLAGS="-I$BOOST -Os -ggdb" LDFLAGS="-L$BOOSTDEST/libs" &&
+./configure --prefix=/opt/mtn --enable-pch \
+ CC="ccache gcc" CXX="ccache g++" CFLAGS="-Os -g$DEBUGSYMS" CXXFLAGS="-I$BOOST -Os -ggdb" LDFLAGS="-L$BOOSTDEST/libs" &&
make