summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-08-27 19:49:18 +0200
committerChristian Poessinger <christian@poessinger.com>2019-08-27 19:49:18 +0200
commit34adc76f589cb01406155007ce49c5855764c79c (patch)
tree59c92ac8b998f1530e448ef0af3ac4e1f700f409
parent343a48be36b1573286db8f944aa933911b09530b (diff)
downloadvyos-1x-34adc76f589cb01406155007ce49c5855764c79c.tar.gz
vyos-1x-34adc76f589cb01406155007ce49c5855764c79c.zip
Python/VyOS validate: add is_ip() to check for IPv4 or IPv4 address
-rw-r--r--python/vyos/validate.py6
1 files changed, 6 insertions, 0 deletions
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