
    Vh              	         d dl mZ d dlZd dlmZmZ dZdZdZdj                  e      Z
d	j                  e      Zd
j                  e      Z ej                  dej                         ej                  dej                         ej                  dj                  e      ej                  ej                  z         ej                  dj                  e
      ej                  ej                  z         ej                  dj                  e      ej                  ej                  z  ej                   z        dZddZy)    )annotationsN)AnsibleParserErrorAnsibleErrorz
    \[
        (?:[0-9]+:[0-9]+)               # numeric begin:end
        (?::[0-9]+)?                    # numeric :step (optional)
    \]
z
    \[
        (?:[0-9a-f]+:[0-9a-f]+)         # hexadecimal begin:end
        (?::[0-9]+)?                    # numeric :step (optional)
    \]
z
    \[
        (?:
            [a-z]:[a-z]|                # one-char alphabetic range
            [0-9]+:[0-9]+               # ...or a numeric one
        )
        (?::[0-9]+)?                    # numeric :step (optional)
    \]
z~
    (?:
        [0-9a-f]{{1,4}}|                # 0..ffff
        {range}                         # or a numeric range
    )
)rangez
    (?:
        [01]?[0-9]{{1,2}}|              # 0..199
        2[0-4][0-9]|                    # 200..249
        25[0-5]|                        # 250..255
        {range}                         # or a numeric range
    )
z
    (?:[\w]|{range})                    # Starts with an alphanumeric or a range
    (?:[\w_-]|{range})*                 # Then zero or more of the same or [_-]
    (?<![_-])                           # ...as long as it didn't end with [_-]
z^
            \[(.+)\]                    # [host identifier]
            :([0-9]+)                   # :port number
            $
        a  ^
            ((?:                        # We want to match:
                [^:\[\]]                # (a non-range character
                |                       # ...or...
                \[[^\]]*\]              # a complete bracketed expression)
            )*)                         # repeated as many times as possible
            :([0-9]+)                   # followed by a port number
            $
        zh^
            (?:{i4}\.){{3}}{i4}         # Three parts followed by dots plus one
            $
        )i4a  ^
            (?:{0}:){{7}}{0}|           # uncompressed: 1:2:3:4:5:6:7:8
            (?:{0}:){{1,6}}:|           # compressed variants, which are all
            (?:{0}:)(?::{0}){{1,6}}|    # a::b for various lengths of a,b
            (?:{0}:){{2}}(?::{0}){{1,5}}|
            (?:{0}:){{3}}(?::{0}){{1,4}}|
            (?:{0}:){{4}}(?::{0}){{1,3}}|
            (?:{0}:){{5}}(?::{0}){{1,2}}|
            (?:{0}:){{6}}(?::{0})|      # ...all with 2 <= a+b <= 7
            :(?::{0}){{1,6}}|           # ::ffff(:ffff...)
            {0}?::|                     # ffff::, ::
                                        # ipv4-in-ipv6 variants
            (?:0:){{6}}(?:{0}\.){{3}}{0}|
            ::(?:ffff:)?(?:{0}\.){{3}}{0}|
            (?:0:){{5}}ffff:(?:{0}\.){{3}}{0}
            $
        z^
            {label}                     # We must have at least one label
            (?:\.{label})*              # Followed by zero or more .labels
            $
        )label)bracketed_hostporthostportipv4ipv6hostnamec                   d}dD ];  }t         |   j                  |       }|s|j                         \  } }t        |      }= d}dD ]  }t         |   j                  |       }|s| }! |st	        d| z        |sd|v rt        d      ||fS )a  
    Takes a string and returns a (host, port) tuple. If the host is None, then
    the string could not be parsed as a host identifier with an optional port
    specification. If the port is None, then no port was specified.

    The host identifier may be a hostname (qualified or not), an IPv4 address,
    or an IPv6 address. If allow_ranges is True, then any of those may contain
    [x:y] range specifications, e.g. foo[1:3] or foo[0:5]-bar[x-z].

    The port number is an optional :NN suffix on an IPv4 address or host name,
    or a mandatory :NN suffix on any square-bracketed expression: IPv6 address,
    IPv4 address, or host name. (This means the only way to specify a port for
    an IPv6 address is to enclose it in square brackets.)
    N)r	   r
   )r   r   r   z Not a valid network hostname: %s[z5Detected range in host but was asked to ignore ranges)patternsmatchgroupsintr   r   )addressallow_rangesportmatchingmhosts         O/home/dcms/DCMS/lib/python3.12/site-packages/ansible/parsing/utils/addresses.pyparse_addressr      s    $ D6 X$$W-hhjOWdt9D D0 X$$W-D	 =GHH
 C4K !XYY$<    )F)
__future__r   reansible.errorsr   r   numeric_rangehexadecimal_rangealphanumeric_rangeformatipv6_componentipv4_componentr   compileXIUNICODEr   r    r   r   <module>r+      sV  $ # 	 ;
  
 F"F#  FF 	 F#F$	  %"**	 TT 

	 TT
 BJJ	 FnF%rttbdd{	" BJJ	  F>"BDD244K#< 

	 FFrzz!9YTn.r   