diff --git a/duniterpy/constants.py b/duniterpy/constants.py index 2829118440229813a8872529faedf10fd9ba4424..0612ddad369c8ebe53d25e31134d6eda381ee336 100644 --- a/duniterpy/constants.py +++ b/duniterpy/constants.py @@ -28,10 +28,9 @@ CONDITIONS_REGEX = ( pubkey_regex=PUBKEY_REGEX, hash_regex=HASH_REGEX ) ) -IPV4_REGEX = ( - "(?:(?:[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])" -) +# https://stackoverflow.com/a/17871737 +IPV4SEG = "(?:25[0-5]|(?:2[0-4]|1?\\d)?\\d)" +IPV4_REGEX = f"(?:{IPV4SEG}\\.){{3}}{IPV4SEG}" 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,"