Just test for IPv4-ness beforehand with IPaddr.ipv4?