diff --git a/duniterpy/constants.py b/duniterpy/constants.py index 0612ddad369c8ebe53d25e31134d6eda381ee336..4723983d8d2bf3dede6f5a9acf5c24ae405dcbc5 100644 --- a/duniterpy/constants.py +++ b/duniterpy/constants.py @@ -31,23 +31,14 @@ CONDITIONS_REGEX = ( # https://stackoverflow.com/a/17871737 IPV4SEG = "(?:25[0-5]|(?:2[0-4]|1?\\d)?\\d)" IPV4_REGEX = f"(?:{IPV4SEG}\\.){{3}}{IPV4SEG}" +IPV6SEG = "[0-9a-fA-F]{1,4}" IPV6_REGEX = ( - "(?:(?:[0-9A-Fa-f]{1,4}:){6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[" - "0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|::(?:[0-9A-Fa-f]{1," - "4}:){5}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){" - "3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1," - "4}:){4}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){" - "3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1," - "4})?::(?:[0-9A-Fa-f]{1,4}:){3}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[" - "0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0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