Tableutil 0.6 review

Download
by rbytes.net on

Tableutil is a utility for converting, aggregating and performing operations (currently unions, differences, complements and intersec

License: BSD License
File size: 11K
Developer: Henrik Gustafsson
0 stars award from rbytes.net

Tableutil is a utility for converting, aggregating and performing operations (currently unions, differences, complements and intersections) on lists of IP-addresses. Tableutil's primary use is to convert files into a format pfctl(8) can read, but if you find another use for it I'd really like to know about it.

It can read plain-text-files with ranges (12.12.12.12-23.23.23.23), CIDR-style networks (192.168.0.0/24) single addresses (242.242.242.242) or hostnames (one.two.com). It can also read p2b-files, the preferred file-format(s) of PeerGuardian. Tableutil has two modes of operation: Quick mode, which is used for converting files to pfctl-compatible tables and advanced mode, which is used to perform more advanced operations on files, and for greater flexibility of the output format.

For example, if you have three files, 'block1', 'block2' and 'exceptions' that is to be used in a table that blocks the hosts in 'block1' and 'block2', excepting the ranges in 'exceptions', create a file looking something like this:

# cat blockspec
$block1 = load(text, "block1"); # The block1-blocklist
$block2 = load(text, "block2"); # The block2-blocklist
$exceptions = load(text, "exceptions"); # List of exceptions

$block = difference(union($block1, $block2), $exceptions);

save(cidr, "blocklist", $block);
Or, if you just want to load a peerguardian blocklist (the text-kind), do something like this:
# cat update-blocklist.sh
#! /bin/sh

URL="http://peerguardian.sourceforge.net/lists/ads.php"
rm -f /tmp/blocklist

ftp -V -o - ${URL} 2> /dev/null | gunzip -c - | sed "s/.*:([0-9.-])/1/" |
tableutil -q text 2> /dev/null > /tmp/blocklist

if [ -s /tmp/blocklist ] ; then
mv /etc/pfdata/blocklist /etc/pfdata/blocklist.old &&
cp /tmp/blocklist /etc/pfdata/blocklist &&
pfctl -f /etc/pf.conf -T load
fi

What's New in This Release:
A small lexer fix was made to handle different newlines gracefully.

Tableutil 0.6 keywords