Am 8. August 2011 22:46 schrieb Andrea Spadaccini <[email protected]>:
>> > It does not seem restrictive to me.. Do you think there are addresses
>> > that
>> > might not be validated?
>>
>> Thinking about it again, why don't you pass “-4” or “-6” to “ip” (e.g.
>> “ip -4 addr show”) to only get the wanted addresses?
>
> That's what I do, see patch 4/4. :)

Sorry, didn't remember that.

> The regex is there only to extract the IP from the output of ip.
> I first simply did it with a couple of split(), but Guido and Iustin
> suggested to use regexps to extract the addresses.

I suggest simplying the regular expression to
r"inet6?\s+([.:a-z0-9]+)/" (the same for both IPv4 and IPv6) and using
the “search” function. You pass the only matched group to inet_pton
for checking and don't have to do any address validation in the form
of a regular expression yourself. What do you think?

Michael

Reply via email to