Spam: DNS blocklists are a well-established, low-latency way to query a database of IP addresses for info. If you need to query a database over the internet quickly and in a connectionless manner, they’re ideal.
Declude have a page called how ip4r (DNSBL-style) DNS lookups work, which describes the general method:
- input: the DNS zone for the DNSBL (e.g. ‘sbl.spamhaus.org’)
- input: IP address to query about (e.g. ‘1.2.3.4’)
- perform A, or TXT query to retrieve data: ‘dig
4.3.2.1.sbl.spamhaus.org. TXT’ - output: data (waves hands… not important right now)
All well and good, if all you have is a single IP address as input. But what if you want to attach more query parameters — such as your user ID, or some numeric value to set a ‘sensitivity’ level, like the SpamAssassin threshold system?
Easy-peasy: encode it in the looked-up hostname. Assuming you want to pass
a user ID number of ‘9583495’ and a threshold value of ‘7’ along with
the query above, here’s one way to do it:
- ‘dig threshold.7.uid.9583495.4.3.2.1.sbl.spamhaus.org. TXT’
Note that to avoid charset issues, marshalling into an ‘-a-z0-9.’ namespace is probably safest. Of course, a dynamic DNS server is required to process these. But the protocol itself, at least, will support it.
(Just brain-dumping here so I have an URL to point to in future, and to get it into archive.org etc…)