Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

DnsIpToBytes

function DnsIpToBytes(const aLiteral: string; out aOctets: tBytes): Boolean;
An IPv4 or IPv6 literal to its network-order octets: 4 for v4, 16 for v6. False - with aOctets empty - on anything that is not exactly one address.

THIS IS DELIBERATELY STRICTER THAN inet_pton. A part with a redundant leading zero ('010.0.0.1') is REFUSED, because C's inet_aton reads that as octal while everything written since reads it as decimal: the same text then means two different hosts, which is a classic way to slip past an address-based policy. Nothing here accepts the short forms ('10.1' for 10.0.0.1) for the same reason. A v4-mapped v6 literal ('::ffff:192.0.2.1') yields SIXTEEN octets and therefore does NOT match a v4 network - matching it would let a v6 peer claim a v4 authorisation.