Backport tinc 1.1's str2net() function.