In <792DE28E91F6EA42B4663AE761C41C2A0250FE33(_at_)cliff(_dot_)bai(_dot_)org>
"Ryan Malayter" <rmalayter(_at_)bai(_dot_)org> writes:
That's just my point. A whole parser written just for SPFv1 is not a
*simpler* solution.
Oh, I guess it might be good to point out that during the, uh, less
interesting portions of the recent IETF meeting on SPF/Caller-ID/etc.,
I wrote up an SPF to XML converter. If you *really* don't want to
write an SPF parser, but would like to only see XML instead, you can
call a couple of simple C functions to do the conversion for you.
(This converter will be available in the next release of libspf-alt.)
Please note that I've never written a line of XML in my life, so this
code is likely to be wrong in many ways. However, I understand the
SPF stuff very well, and this is a fathful conversion from the SPF
semantics to something close to XML.
The "SPF header:" line contains a "len=" part. This is the size of
the byte-compiled SPF record that libspf-alt uses.
Here are some examples:
(wayne(_at_)footbone) $ ./spftest_static spf2xml "v=spf1 a mx -all"
SPF header: version: 1 mech 3/6 mod 0/0 len=10
SPF record: v=spf1 a mx -all
SPF record converted to XML: (16 vs 115 bytes)
<ep xmlns='http://spf.pobox.com/1' version="1">
<out>
<a/>
<mx/>
<all result="fail"/>
</out>
</ep>
SPF record converted to XML: (16 vs 92 bytes)
<ep xmlns='http://spf.pobox.com/1' version="1"><out><a/><mx/><all
result="fail"/></out></ep>
(wayne(_at_)footbone) $ ./spftest_static spf2xml "v=spf1 ip4:66.240.66.130/32
ip4:66.240.66.131/32 ip4:66.240.66.132/32 ip4:66.240.66.133/32
ip4:66.240.66.134/32 a ptr mx ?all"
SPF record in: v=spf1 ip4:66.240.66.130/32 ip4:66.240.66.131/32
ip4:66.240.66.132/32 ip4:66.240.66.133/32 ip4:66.240.66.134/32 a ptr mx ?all
no errors
SPF header: version: 1 mech 9/38 mod 0/0 len=42
SPF record: v=spf1 ip4:66.240.66.130 ip4:66.240.66.131 ip4:66.240.66.132
ip4:66.240.66.133 ip4:66.240.66.134 a ptr mx ?all
SPF record converted to XML: (125 vs 274 bytes)
<ep xmlns='http://spf.pobox.com/1' version="1">
<out>
<ip4>66.240.66.130</ip4>
<ip4>66.240.66.131</ip4>
<ip4>66.240.66.132</ip4>
<ip4>66.240.66.133</ip4>
<ip4>66.240.66.134</ip4>
<a/>
<ptr/>
<mx/>
<all result="neutral"/>
</out>
</ep>
SPF record converted to XML: (125 vs 221 bytes)
<ep xmlns='http://spf.pobox.com/1'
version="1"><out><ip4>66.240.66.130</ip4><ip4>66.240.66.131</ip4><ip4>66.240.66.132</ip4><ip4>66.240.66.133</ip4><ip4>66.240.66.134</ip4><a/><ptr/><mx/><all
result="neutral"/></out></ep>
(wayne(_at_)footbone) $ ./spftest_static spf2xml "v=spf1 ~ip4:1.2.3.4/8
a:smtp-out.%{d3} exists:%{ir}.hello.com exists:%{L-=+}.hello.com mx/24//48 -all"
SPF header: version: 1 mech 6/59 mod 0/0 len=63
SPF record: v=spf1 ~ip4:1.2.3.4/8 a:smtp-out.%{d3} exists:%{ir}.hello.com
exists:%{L-+=}.hello.com mx/24//48 -all
SPF record converted to XML: (101 vs 356 bytes)
<ep xmlns='http://spf.pobox.com/1' version="1">
<out>
<ip4 cidr4="8" result="softfail">1.2.3.4</ip4>
<a><str>smtp-out.</str><d num_rhs="3"/>
</a>
<exists><i rev="y"/>
<str>.hello.com</str></exists>
<exists><l url="y" delim="-+="/>
<str>.hello.com</str></exists>
<mx cidr4="24" cidr6="24"></mx>
<all result="fail"/>
</out>
</ep>
SPF record converted to XML: (101 vs 315 bytes)
<ep xmlns='http://spf.pobox.com/1' version="1"><out><ip4 cidr4="8"
result="softfail">1.2.3.4</ip4><a><str>smtp-out.</str><d
num_rhs="3"/></a><exists><i rev="y"/><str>.hello.com</str></exists><exists><l
url="y" delim="-+="/><str>.hello.com</str></exists><mx cidr4="24"
cidr6="24"></mx><all result="fail"/></out></ep>
This is aol.com's SPF record:
(wayne(_at_)footbone) $ ./spftest_static spf2xml "v=spf1 ip4:152.163.225.0/24
ip4:205.188.139.0/24 ip4:205.188.144.0/24 ip4:205.188.156.0/23
ip4:205.188.159.0/24 ip4:64.12.136.0/23 ip4:64.12.138.0/24 ptr:mx.aol.com ?all"
SPF header: version: 1 mech 9/58 mod 0/0 len=62
SPF record: v=spf1 ip4:152.163.225.0/24 ip4:205.188.139.0/24
ip4:205.188.144.0/24 ip4:205.188.156.0/23 ip4:205.188.159.0/24
ip4:64.12.136.0/23 ip4:64.12.138.0/24 ptr:mx.aol.com ?all
SPF record converted to XML: (169 vs 412 bytes)
<ep xmlns='http://spf.pobox.com/1' version="1">
<out>
<ip4 cidr4="24">152.163.225.0</ip4>
<ip4 cidr4="24">205.188.139.0</ip4>
<ip4 cidr4="24">205.188.144.0</ip4>
<ip4 cidr4="23">205.188.156.0</ip4>
<ip4 cidr4="24">205.188.159.0</ip4>
<ip4 cidr4="23">64.12.136.0</ip4>
<ip4 cidr4="24">64.12.138.0</ip4>
<ptr><str>mx.aol.com</str></ptr>
<all result="neutral"/>
</out>
</ep>
SPF record converted to XML: (169 vs 359 bytes)
<ep xmlns='http://spf.pobox.com/1' version="1"><out><ip4
cidr4="24">152.163.225.0</ip4><ip4 cidr4="24">205.188.139.0</ip4><ip4
cidr4="24">205.188.144.0</ip4><ip4 cidr4="23">205.188.156.0</ip4><ip4
cidr4="24">205.188.159.0</ip4><ip4 cidr4="23">64.12.136.0</ip4><ip4
cidr4="24">64.12.138.0</ip4><ptr><str>mx.aol.com</str></ptr><all
result="neutral"/></out></ep>
-wayne
-wayne