My SPF library kinda works
RaSPF, my attempted port of PySPF to C is now at a very special point in its life:
The provided CLI application can check SPF records and tell you what you should do with them!
Here's an example:
[ralsina@monty build]$ ./raspfquery --ip=192.0.2.1 --sender=03.spf1-test.mailzone.com --helo=03.spf1-test.mailzone.com Checking SPF with: sender: 03.spf1-test.mailzone.com helo: 03.spf1-test.mailzone.com ip: 192.0.2.1 response: softfail code: 250 explanation: domain owner discourages use of this host
Is that correct? Apparently yes!
[ralsina@monty pyspf-2.0.2]$ python spf.py 192.0.2.1 03.spf1-test.mailzone.com 03.spf1-test.mailzone.com ('softfail', 250, 'domain owner discourages use of this host')
Is it useful? Surely you jest!
There are still the following problems:
The memory management is unexistant
I need to hack a way to run the official SPF test suite so I can see how well it works and that it works exactly as PySPF
It probably will segfault on many places
I am changing the error handling to be exception-based, thanks to EXCC
The IPv6 support is between iffy and not there
There is no support for SPF (type 99) DNS records, only TXT records (need to hack the udns library)
But really, this should be about 60% of the work, and it does work for some cases, which is more than I really expected at the beginning.
Here's the whole source code of the sample application (except for CLI option processing):
spf_init(); spf_response r=spf_check(ip,sender,helo,0,0); printf ("\nresponse:\t%s\ncode:\t\t%d\nexplanation:\t\t%s\n", r.response,r.code,r.explanation);