[Pdns-users] PDNS-Admin features
Roger Libiez
rlibiez at arthmoor.com
Sat Feb 9 21:59:07 UTC 2008
I wasn't actually referring to the formats the user types in, those will
obviously need to be checked too. I was referring to verifying that what
they entered is in fact a valid address. Take the example Wikipedia uses:
2001:0db8:0000:0000:0000:0000:1428:57ab can be expressed as any of the
following:
2001:0db8:0000:0000:0000:0000:1428:57ab
2001:0db8:0000:0000:0000::1428:57ab
2001:0db8:0:0:0:0:1428:57ab
2001:0db8:0:0::1428:57ab
2001:0db8::1428:57ab
2001:db8::1428:57ab
So if the user actually puts in 2001:0db8:0000:0000:0000:0000:1428:57ab
and we use this to see if it's a valid address:
function is_valid_ip($ip)
{
return( $ip == inet_pton(inet_ntop($ip))) ? true : false;
}
The result breaks. The code returns 2001:db8::1428:57ab to compare with
the original $ip variable, which no longer matches what the user typed
in. So I'd need some way to take the long format and break it down
according to IPv6 formatting rules so that the comparison is useful to
the code, and we can then make sure someone hasn't tried to make an IPv6
entry equivalent to 299.1.1.1 where the 299 is obviously not valid.
Rudolph Bott wrote:
> Roger Libiez wrote:
>> I would welcome receiving a patch for the AAAA and LOC records.
>>
>> I'm not setup for IPv6 here so I'd be unable to test it even if I were
>> to add the record choice. I also have no idea how to go about
>> validating the input to keep broken data from being inserted.
>
> IMO the easiest way to do input validation is assigning a Regex to each
> available record type in some general config file or wherever. Since the
> syntax is quite the same you can use them either for "on the fly"
> validation via javascript regex'es or inside your PHP scripts. You can
> find some examples in the config file inside the includes/ directory in
> ZoneAdmin (sf.net/projects/ZoneAdmin) - although these regex patterns
> still leave room for "bad" content. If someone here is up to the task
> you're very welcome to help us out with some code :)
--
PDNS-Admin: http://www.iguanadons.net/pdns-admin
Arthmoor Internet Services: http://www.arthmoor.com
More information about the Pdns-users
mailing list