From 34adc76f589cb01406155007ce49c5855764c79c Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Tue, 27 Aug 2019 19:49:18 +0200 Subject: Python/VyOS validate: add is_ip() to check for IPv4 or IPv4 address --- python/vyos/validate.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'python/vyos/validate.py') diff --git a/python/vyos/validate.py b/python/vyos/validate.py index 97a401423..258f7f76a 100644 --- a/python/vyos/validate.py +++ b/python/vyos/validate.py @@ -16,6 +16,12 @@ import netifaces import ipaddress +def is_ip(addr): + """ + Check addr if it is an IPv4 or IPv6 address + """ + return is_ipv4(addr) or is_ipv6(addr) + def is_ipv4(addr): """ Check addr if it is an IPv4 address/network. Returns True/False -- cgit v1.2.3