diff --git a/types/ip.pp b/types/ip.pp new file mode 100644 index 0000000..e965934 --- /dev/null +++ b/types/ip.pp @@ -0,0 +1,2 @@ +# https://stackoverflow.com/a/190405/1000630, with minor modifications to syntax +type Tea::IP = Variant[Tea::IPv4, Tea::IPv6] diff --git a/types/ipcidr.pp b/types/ipcidr.pp new file mode 100644 index 0000000..44ec287 --- /dev/null +++ b/types/ipcidr.pp @@ -0,0 +1,2 @@ +# https://stackoverflow.com/a/190405/1000630, with minor modifications to syntax +type Tea::IPCIDR = Variant[Tea::IPv4CIDR, Tea::IPv6CIDR] diff --git a/types/ipv4.pp b/types/ipv4.pp new file mode 100644 index 0000000..cebcbf5 --- /dev/null +++ b/types/ipv4.pp @@ -0,0 +1,2 @@ +# https://stackoverflow.com/a/190405/1000630, with minor modifications to syntax +type Tea::IPv4 = Pattern[/((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4}/] diff --git a/types/ipv4cidr.pp b/types/ipv4cidr.pp new file mode 100644 index 0000000..e5b7087 --- /dev/null +++ b/types/ipv4cidr.pp @@ -0,0 +1,2 @@ +#http://www.regexpal.com/93987 +type Tea::IPv4CIDR = Pattern[/^([0-9]{1,3}\.){3}[0-9]{1,3}(\/([0-9]|[1-2][0-9]|3[0-2]))?/] diff --git a/types/ipv6.pp b/types/ipv6.pp new file mode 100644 index 0000000..6d69d9b --- /dev/null +++ b/types/ipv6.pp @@ -0,0 +1,2 @@ +# Unsure where this came from, thank you Internet! +type Tea::IPv6 = Pattern[/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/] # lint:ignore:140chars diff --git a/types/ipv6cidr.pp b/types/ipv6cidr.pp new file mode 100644 index 0000000..b3b2d01 --- /dev/null +++ b/types/ipv6cidr.pp @@ -0,0 +1,2 @@ +#source: http://www.regexpal.com/93988 +type Tea::IPv6CIDR = Pattern[/s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5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