§
    3xÅj2k  ã                   ó  — d Z ddlZddlZddlZddlZddlZddlZddlmZ ddl	m
Z
 ddlmZ d\  ZZ	 ddlZn# e$ rZeZY dZ[ndZ[ww xY wddlmZmZ d	Z G d
„ d¦  «        Zd„ Z G d„ d¦  «        Z G d„ de¦  «        ZdS )z2
Configuration file (aka ``ssh_config``) support.
é    N)Úpartial)Úsha1)ÚStringIO)NNé   )ÚConfigParseErrorÚCouldNotCanonicalizeé   c                   óò   — e Zd ZdZ ej        d¦  «        Zg d¢dgg d¢g d¢g d¢g d¢d	œZd
„ Ze	d„ ¦   «         Z
e	d„ ¦   «         Ze	d„ ¦   «         Zd„ Zd„ Zdd„Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ ZdS )Ú	SSHConfigaƒ  
    Representation of config information as stored in the format used by
    OpenSSH. Queries can be made via `lookup`. The format is described in
    OpenSSH's ``ssh_config`` man page. This class is provided primarily as a
    convenience to posix users (since the OpenSSH format is a de-facto
    standard on posix) but should work fine on Windows too.

    .. versionadded:: 1.6
    z(\w+)(?:\s*=\s*|\s+)(.+))ú%Cú%hú%lú%Lú%nú%pú%rú%ur   )r   ú~ú%dr   r   r   r   )r   r   r   r   )r   r   r   )	r   r   r   r   r   r   r   r   r   )ÚcontrolpathÚhostnameÚidentityfileÚproxycommandÚ	proxyjumpú
match-execc                 ó   — g | _         dS )a†  
        Create a new OpenSSH config object.

        Note: the newer alternate constructors `from_path`, `from_file` and
        `from_text` are simpler to use, as they parse on instantiation. For
        example, instead of::

            config = SSHConfig()
            config.parse(open("some-path.config")

        you could::

            config = SSHConfig.from_file(open("some-path.config"))
            # Or more directly:
            config = SSHConfig.from_path("some-path.config")
            # Or if you have arbitrary ssh_config text from some other source:
            config = SSHConfig.from_text("Host foo\n\tUser bar")
        N)Ú_config)Úselfs    ú@C:\Projects\Historical\venv\Lib\site-packages\paramiko/config.pyÚ__init__zSSHConfig.__init__G   s   € ð& ˆŒˆˆó    c                 óF   — |                       t          |¦  «        ¦  «        S )zg
        Create a new, parsed `SSHConfig` from ``text`` string.

        .. versionadded:: 2.7
        )Ú	from_filer   )ÚclsÚtexts     r   Ú	from_textzSSHConfig.from_text\   s   € ð �}Š}�X d™^œ^Ñ,Ô,Ð,r!   c                 ó~   — t          |¦  «        5 }|                      |¦  «        cddd¦  «         S # 1 swxY w Y   dS )zr
        Create a new, parsed `SSHConfig` from the file found at ``path``.

        .. versionadded:: 2.7
        N)Úopenr#   )r$   ÚpathÚflos      r   Ú	from_pathzSSHConfig.from_pathe   s€   € õ �$‰ZŒZð 	&˜3Ø—=’= Ñ%Ô%ð	&ð 	&ð 	&ð 	&ñ 	&ô 	&ð 	&ð 	&ð 	&ð 	&ð 	&ð 	&øøøð 	&ð 	&ð 	&ð 	&ð 	&ð 	&s   �2²6¹6c                 óD   —  | ¦   «         }|                      |¦  «         |S )zp
        Create a new, parsed `SSHConfig` from file-like object ``flo``.

        .. versionadded:: 2.7
        )Úparse)r$   r*   Úobjs      r   r#   zSSHConfig.from_fileo   s#   € ð ˆc‰eŒeˆØ�	Š	�#‰ŒˆØˆ
r!   c                 ó¼  — dgi dœ}|D �]·}|                      ¦   «         }|r|                     d¦  «        rŒ/t          j        | j        |¦  «        }|s"t          d                     |¦  «        ¦  «        ‚|                     d¦  «                             ¦   «         }|                     d¦  «        }|dv rW| j	         
                    |¦  «         di i}|d	k    r|                      |¦  «        |d	<   Œê|                      |¦  «        |d
<   �Œ|dk    r%|                     ¦   «         dk    rd|d         |<   �Œ/|                     d¦  «        r|                     d¦  «        r
|dd…         }|dv r;||d         v r#|d         |          
                    |¦  «         �Œ”|g|d         |<   �Œ¢||d         vr||d         |<   �Œ¹| j	         
                    |¦  «         dS )zŽ
        Read an OpenSSH config from the given file object.

        :param file_obj: a file-like object to read the config file from
        Ú*)ÚhostÚconfigú#zUnparsable line {}r   é   )r1   Úmatchr2   r1   Úmatchesr   ÚnoneNú"éÿÿÿÿ)r   ÚlocalforwardÚremoteforward)ÚstripÚ
startswithÚrer5   ÚSETTINGS_REGEXr   ÚformatÚgroupÚlowerr   ÚappendÚ
_get_hostsÚ_get_matchesÚendswith)r   Úfile_objÚcontextÚliner5   ÚkeyÚvalues          r   r-   zSSHConfig.parsez   s  € ð  ˜5¨BÐ/Ð/ˆØð /	3ñ /	3ˆDð —:’:‘<”<ˆDàð ˜4Ÿ?š?¨3Ñ/Ô/ð Øõ ”H˜TÔ0°$Ñ7Ô7ˆEØð JÝ&Ð';×'BÒ'BÀ4Ñ'HÔ'HÑIÔIÐIØ—+’+˜a‘.”.×&Ò&Ñ(Ô(ˆCØ—K’K ‘N”NˆEð Ð'Ð'Ð'Ø”×#Ò# GÑ,Ô,Ð,Ø# R˜.�Ø˜&’=�=ð '+§o¢o°eÑ&<Ô&<�G˜F‘O�Oà)-×):Ò):¸5Ñ)AÔ)A�G˜IÑ&Ñ&à˜Ò&Ð&¨5¯;ª;©=¬=¸FÒ+BÐ+Bð *.�˜Ô! #Ñ&Ñ&ð ×#Ò# CÑ(Ô(ð (¨U¯^ª^¸CÑ-@Ô-@ð (Ø! ! B $œK�Eð
 ÐKÐKÐKØ˜g hÔ/Ð/Ð/Ø Ô)¨#Ô.×5Ò5°eÑ<Ô<Ð<Ñ<à27°˜ Ô)¨#Ñ.Ñ.Ø ¨Ô 1Ð1Ð1Ø-2�G˜HÔ% cÑ*ùàŒ×Ò˜GÑ$Ô$Ð$Ð$Ð$r!   c                 óÂ  — |                       |¬¦  «        }d|vr||d<   |                     dd¦  «        dv }t          |                     dd¦  «        ¦  «        }|ri|                     d¦  «        |k    rP|d	                              ¦   «         }|                      |||¦  «        }||d<   |                       ||d
d
¬¦  «        }n|                       ||dd
¬¦  «        }|S )a  
        Return a dict (`SSHConfigDict`) of config options for a given hostname.

        The host-matching rules of OpenSSH's ``ssh_config`` man page are used:
        For each parameter, the first obtained value will be used.  The
        configuration files contain sections separated by ``Host`` and/or
        ``Match`` specifications, and that section is only applied for hosts
        which match the given patterns or keywords

        Since the first obtained value for each parameter is used, more host-
        specific declarations should be given near the beginning of the file,
        and general defaults at the end.

        The keys in the returned dict are all normalized to lowercase (look for
        ``"port"``, not ``"Port"``. The values are processed according to the
        rules for substitution variable expansion in ``ssh_config``.

        Finally, please see the docs for `SSHConfigDict` for deeper info on
        features such as optional type conversion methods, e.g.::

            conf = my_config.lookup('myhost')
            assert conf['passwordauthentication'] == 'yes'
            assert conf.as_bool('passwordauthentication') is True

        .. note::
            If there is no explicitly configured ``HostName`` value, it will be
            set to the being-looked-up hostname, which is as close as we can
            get to OpenSSH's behavior around that particular option.

        :param str hostname: the hostname to lookup

        .. versionchanged:: 2.5
            Returns `SSHConfigDict` objects instead of dict literals.
        .. versionchanged:: 2.7
            Added canonicalization support.
        .. versionchanged:: 2.7
            Added ``Match`` support.
        .. versionchanged:: 3.3
            Added ``Match final`` support.
        )r   r   ÚcanonicalizehostnameN)ÚyesÚalwaysÚcanonicalizemaxdotsr   ú.ÚcanonicaldomainsT)Ú	canonicalÚfinalF)Ú_lookupÚgetÚintÚcountÚsplitÚcanonicalize)r   r   ÚoptionsÚcanonÚmaxdotsÚdomainss         r   ÚlookupzSSHConfig.lookup¶   s
  € ðT —,’,¨�,Ñ1Ô1ˆð ˜WÐ$Ð$Ø"*ˆG�JÑà—’Ð2°DÑ9Ô9Ð=NÐNˆÝ�g—k’kÐ"7¸Ñ;Ô;Ñ<Ô<ˆØð 	�X—^’^ CÑ(Ô(¨GÒ3Ð3ð Ð0Ô1×7Ò7Ñ9Ô9ˆGØ×(Ò(¨°7¸GÑDÔDˆHà"*ˆG�JÑØ—l’lØ˜'¨T¸ð #ñ ô ˆGˆGð —l’lØ˜'¨U¸$ð #ñ ô ˆGð ˆr!   NFc                 óæ  ‡‡— ‰€t          ¦   «         Š| j        D ]¾}|                      |                     dg ¦  «        |¦  «        s.|                      |                     dg ¦  «        |||‰¦  «        sŒZ|d                              ¦   «         D ]I\  Š}‰‰vr|�
|d d …         n|‰‰<   Œ‰dk    r(‰‰                              ˆˆfd„|D ¦   «         ¦  «         ŒJŒ¿|r|                      ‰|¦  «        Š‰S )Nr1   r6   r2   r   c              3   ó0   •K  — | ]}|‰‰         v¯|V — Œd S ©N© )Ú.0ÚxrJ   r[   s     €€r   ú	<genexpr>z$SSHConfig._lookup.<locals>.<genexpr>  s:   øè è € ð (ð (Ø¨A°W¸S´\Ð,AÐ,A˜Ð,AÐ,AÐ,AÐ,Að(ð (r!   )ÚSSHConfigDictr   Ú_pattern_matchesrV   Ú_does_matchÚitemsÚextendÚ_expand_variables)r   r   r[   rS   rT   rH   rK   rJ   s     `    @r   rU   zSSHConfig._lookupø   sQ  øø€ àˆ?Ý#‘o”oˆGð ”|ð 	ð 	ˆGà×%Ò% g§k¢k°&¸"Ñ&=Ô&=¸xÑHÔHð
à×#Ò#Ø—K’K 	¨2Ñ.Ô.ØØØØñô ð
ð Ø% hÔ/×5Ò5Ñ7Ô7ð 
ð 
‘
��UØ˜gÐ%Ð%ð
 05Ð/@ 5¨¨¨¤8 8Àe�G˜C‘L�LØ˜NÒ*Ð*Ø˜C”L×'Ò'ð (ð (ð (ð (ð (Ø#(ð(ñ (ô (ñ ô ð øð
ð ð 	@ð ×,Ò,¨W°hÑ?Ô?ˆGØˆr!   c                 ó*  — d}|D ]d}d                      ||¦  «        }t          ||¦  «        }|�	|d         }n+	 t          j        |¦  «        }n# t          j        $ r Y nw xY w|r|c S Œe|                     dd¦  «        dk    r|S t          |¦  «        ‚)ag  
        Return canonicalized version of ``hostname``.

        :param str hostname: Target hostname.
        :param options: An `SSHConfigDict` from a previous lookup pass.
        :param domains: List of domains (e.g. ``["paramiko.org"]``).

        :returns: A canonicalized hostname if one was found, else ``None``.

        .. versionadded:: 2.7
        Fz{}.{}Nr   ÚcanonicalizefallbacklocalrN   )r@   Ú_addressfamily_host_lookupÚsocketÚgethostbynameÚgaierrorrV   r   )r   r   r[   r^   ÚfoundÚdomainÚ	candidateÚfamily_specifics           r   rZ   zSSHConfig.canonicalize  sÓ   € ð ˆØð 	!ð 	!ˆFØŸš x°Ñ8Ô8ˆIÝ8¸ÀGÑLÔLˆOØÐ*ð (¨Ô*��ðÝ"Ô0°Ñ;Ô;�E�EøÝ”ð ð ð Ø�Dðøøøàð !ð !Ð Ð Ð ð!ð �;Š;Ð2°EÑ:Ô:¸eÒCÐCØˆOõ # 8Ñ,Ô,Ð,s   ¹AÁA ÁA c                 ól   — t          ¦   «         }| j        D ]}|                     |d         ¦  «         Œ|S )z‡
        Return the set of literal hostnames defined in the SSH config (both
        explicit hostnames and wildcard entries).
        r1   )Úsetr   Úupdate)r   ÚhostsÚentrys      r   Úget_hostnameszSSHConfig.get_hostnamesD  s<   € õ
 ‘”ˆØ”\ð 	(ð 	(ˆEØ�LŠL˜˜vœÑ'Ô'Ð'Ð'Øˆr!   c                 óö   — t          |d¦  «        r|                     d¦  «        }d}|D ]N}|                     d¦  «        r t          j        ||dd …         ¦  «        r dS t          j        ||¦  «        rd}ŒO|S )NrY   ú,Fú!r   T)ÚhasattrrY   r=   Úfnmatch)r   ÚpatternsÚtargetr5   Úpatterns        r   rh   zSSHConfig._pattern_matchesN  s™   € å�8˜WÑ%Ô%ð 	+Ø—~’~ cÑ*Ô*ˆHØˆØð 		ð 		ˆGà×!Ò! #Ñ&Ô&ð ­7¬?Ø˜   œñ,ô ,ð ð �u�uõ ” ¨Ñ1Ô1ð Ø�øØˆr!   c                 ó:  — g }|d d …         }t          j        ¦   «         }|�rx|                     d¦  «        }	d }
|                     dd ¦  «        }|                     dd ¦  «        }|	d         |	d         }}|dk    r|                      ||	¦  «        rdS |dk    r|}
nÌ|d	k    rd
S |dk    r|p|}|                      ||¦  «        }
n£|dk    r|                      ||¦  «        }
n†|dk    r|p|}|                      ||¦  «        }
ne|dk    r|                      ||¦  «        }
nH|dk    rB|                      ||d|¦  «        }t          €t          ‚t          j	        |dd
¬¦  «        j
        }
|
�|                      |
|	¦  «        rdS |                     |	¦  «         |�°x|S )Nr   r   ÚuserÚtypeÚparamrS   FrT   ÚallTr1   ÚoriginalhostÚ	localuserÚexecr   Ústdout)ÚhideÚwarn)ÚgetpassÚgetuserÚpoprV   Ú_should_failrh   Ú	_tokenizeÚinvokeÚinvoke_import_errorÚrunÚokrC   )r   Ú
match_listÚtarget_hostnamerS   rT   r[   ÚmatchedÚ
candidatesÚlocal_usernameru   ÚpassedÚconfigured_hostÚconfigured_userÚtype_rˆ   Úhostvalr†   Úexec_cmds                     r   ri   zSSHConfig._does_match_  sò  € ð ˆØ   ”]ˆ
Ý œÑ*Ô*ˆØñ .	&Ø"Ÿš qÑ)Ô)ˆIØˆFð &Ÿkšk¨*°dÑ;Ô;ˆOØ%Ÿkšk¨&°$Ñ7Ô7ˆOØ$ VÔ,¨i¸Ô.@�5ˆEð ˜Ò#Ð#Ø×$Ò$ Y°	Ñ:Ô:ð !Ø ˜5Ø˜ÒÐØ��ð ˜%’�Ø�tð ˜&’�Ø)Ð<¨_�Ø×.Ò.¨u°gÑ>Ô>��Ø˜.Ò(Ð(Ø×.Ò.¨u°oÑFÔF��Ø˜&’�Ø&Ð8¨.�Ø×.Ò.¨u°dÑ;Ô;��Ø˜+Ò%Ð%Ø×.Ò.¨u°nÑEÔE��Ø˜&’�ØŸ>š>Ø˜_¨l¸Eñô �õ
 �>Ý-Ð-åœ H°8À$ÐGÑGÔGÔJ�àÐ! d×&7Ò&7¸À	Ñ&JÔ&JÐ!Ø�uà�NŠN˜9Ñ%Ô%Ð%ð] ñ .	&ð` ˆr!   c                 ó   — |d         r|n| S )NÚnegaterc   )r   Ú
would_passru   s      r   r“   zSSHConfig._should_fail—  s   € Ø& xÔ0ÐDˆzˆz¸*°nÐDr!   c                 óÊ  — |                       |¦  «        }|s|S |}|dk    r|                     d|¦  «        }d|v r	|d         }nt          }t          j        ¦   «         }d|v r	|d         }	n|}	t          j        ¦   «                              d¦  «        d         }
t          ||
¦  «        }t          j
                             d¦  «        }|
|z   t          |¦  «        z   |	z   }t          |                     ¦   «         ¦  «                             ¦   «         |||
||||	||dœ
}|}|                     ¦   «         D ]-\  }}||vrŒ
|                     |t%          |¦  «        ¦  «        }Œ.|S )a„  
        Tokenize a string based on current config/hostname data.

        :param config: Current config data.
        :param target_hostname: Original target connection hostname.
        :param key: Config key being tokenized (used to filter token list).
        :param value: Config value being tokenized.

        :returns: The tokenized version of the input ``value`` string.
        r   Úportr†   rQ   r   r   )
r   r   r   r   r   r   r   r   r   r   )Ú_allowed_tokensrV   ÚSSH_PORTr�   r‘   rp   ÚgethostnamerY   ÚLazyFqdnÚosr)   Ú
expanduserÚreprr   ÚencodeÚ	hexdigestrj   ÚreplaceÚstr)r   r2   rš   rJ   rK   Úallowed_tokensÚconfigured_hostnamer¨   r†   Ú
remoteuserÚlocal_hostnameÚ
local_fqdnÚhomedirÚtohashÚreplacementsÚ	tokenizedÚfindr²   s                     r   r”   zSSHConfig._tokenizeš  s�  € ð ×-Ò-¨cÑ2Ô2ˆàð 	ØˆLð .ÐØ�*ÒÐØ"(§*¢*¨ZÐ9LÑ"MÔ"MÐà�VÐÐØ˜&”>ˆDˆDåˆDÝŒÑ Ô ˆØ�VÐÐØ œˆJˆJàˆJÝÔ+Ñ-Ô-×3Ò3°CÑ8Ô8¸Ô;ˆÝ˜f nÑ5Ô5ˆ
Ý”'×$Ò$ SÑ)Ô)ˆØ /Ñ1µD¸±J´JÑ>ÀÑKˆõ
 �v—}’}‘”Ñ'Ô'×1Ò1Ñ3Ô3ØØ%à Øð "ØØàØð!
ð 
ˆð& ˆ	Ø)×/Ò/Ñ1Ô1ð 	>ð 	>‰MˆD�'Ø˜>Ð)Ð)ØØ!×)Ò)¨$µ°G±´Ñ=Ô=ˆIˆIàÐr!   c                 ó8   — | j                              |g ¦  «        S )aJ  
        Given config ``key``, return list of token strings to tokenize.

        .. note::
            This feels like it wants to eventually go away, but is used to
            preserve as-strict-as-possible compatibility with OpenSSH, which
            for whatever reason only applies some tokens to some config keys.
        )ÚTOKENS_BY_CONFIG_KEYrV   ©r   rJ   s     r   r©   zSSHConfig._allowed_tokensÙ  s   € ð Ô(×,Ò,¨S°"Ñ5Ô5Ð5r!   c                 ó  — |D ]�}||         €Œt          | j        |||¦  «        }t          ||         t          ¦  «        r0t	          ||         ¦  «        D ]\  }} ||¦  «        ||         |<   ŒŒm |||         ¦  «        ||<   Œ‚|S )aA  
        Return a dict of config options with expanded substitutions
        for a given original & current target hostname.

        Please refer to :doc:`/api/config` for details.

        :param dict config: the currently parsed config
        :param str hostname: the hostname whose config is being looked up
        )r   r”   Ú
isinstanceÚlistÚ	enumerate)r   r2   rš   ÚkÚ	tokenizerÚirK   s          r   rl   zSSHConfig._expand_variablesä  s¨   € ð ð 	1ð 	1ˆAØ�aŒyÐ ØÝ ¤°¸ÈÑKÔKˆIÝ˜& œ)¥TÑ*Ô*ð 1Ý )¨&°¬)Ñ 4Ô 4ð 4ð 4‘H�A�uØ#, 9¨UÑ#3Ô#3�F˜1”I˜a‘L�Lð4ð &˜I f¨Q¤iÑ0Ô0��q‘	�	Øˆr!   c                 óŒ   — 	 t          j        |¦  «        S # t          $ r# t          d                     |¦  «        ¦  «        ‚w xY w)z>
        Return a list of host_names from host value.
        zUnparsable host {})ÚshlexrY   Ú
ValueErrorr   r@   )r   r1   s     r   rD   zSSHConfig._get_hostsù  sT   € ð	FÝ”;˜tÑ$Ô$Ð$øÝð 	Fð 	Fð 	FÝ"Ð#7×#>Ò#>¸tÑ#DÔ#DÑEÔEÐEð	Føøøs	   ‚ –-Ac                 óì  ‡	— g }t          j        |¦  «        }|r±ddddœ}|                     d¦  «        }|                     d¦  «        rd|d<   |dd…         }||d	<   |d
v r|                     |¦  «         Œ`|s"t          d                     |¦  «        ¦  «        ‚|                     d¦  «        |d<   |                     |¦  «         |°±d„ |D ¦   «         }d|v r™dŠ	t          t          ˆ	fd„|¦  «        ¦  «        t          t          ˆ	fd„|¦  «        ¦  «        }}d}t          |¦  «        rd}n2d|v r.| 
                    d¦  «        | 
                    d¦  «        k    rd}|�t          |¦  «        ‚|S )z�
        Parse a specific Match config line into a list-of-dicts for its values.

        Performs some parse-time validation as well.
        NF)r‡   rˆ   r¥   r   r   Tr¥   r   r‡   )r‰   rS   rT   z'Missing parameter to Match '{}' keywordrˆ   c                 ó   — g | ]
}|d          ‘ŒS )r‡   rc   )rd   re   s     r   ú
<listcomp>z*SSHConfig._get_matches.<locals>.<listcomp>  s   € Ð/Ð/Ð/ !�A�f”IÐ/Ð/Ð/r!   r‰   )r‰   rS   c                 ó   •— | ‰v S rb   rc   ©re   Ú	allowables    €r   ú<lambda>z(SSHConfig._get_matches.<locals>.<lambda>"  s   ø€  a¨9 n€ r!   c                 ó   •— | ‰vS rb   rc   rÏ   s    €r   rÑ   z(SSHConfig._get_matches.<locals>.<lambda>#  s   ø€  a¨yÐ&8€ r!   z>Match does not allow 'all' mixed with anything but 'canonical'rS   z-Match does not allow 'all' before 'canonical')rÉ   rY   r’   r=   rC   r   r@   rÃ   ÚfilterÚanyÚindex)
r   r5   r6   Útokensr¡   Úkeywordsr˜   ÚbadÚerrrÐ   s
            @r   rE   zSSHConfig._get_matches  sÀ  ø€ ð ˆÝ”˜UÑ#Ô#ˆØð 	"Ø!¨D¸EÐBÐBˆEØ—J’J˜q‘M”MˆEà×Ò Ñ$Ô$ð "Ø"&��h‘Ø˜a˜b˜bœ	�Ø!ˆE�&‰MàÐ5Ð5Ð5Ø—’˜uÑ%Ô%Ð%ØØð Ý&Ø=×DÒDÀUÑKÔKñô ð ð $ŸZšZ¨™]œ]ˆE�'‰NØ�NŠN˜5Ñ!Ô!Ð!ð# ð 	"ð( 0Ð/ wÐ/Ñ/Ô/ˆØ�HÐÐØ,ˆIå•VÐ4Ð4Ð4Ð4°hÑ?Ô?Ñ@Ô@Ý•VÐ8Ð8Ð8Ð8¸(ÑCÔCÑDÔDð ˆBð ˆCÝ�3‰xŒxð FØV��Ø Ð"Ð" r§x¢x°Ñ'<Ô'<¸r¿xºxÈ¹¼Ò'NÐ'NØE�ØˆÝ& sÑ+Ô+Ð+Øˆr!   )NFF)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r>   Úcompiler?   r¿   r    Úclassmethodr&   r+   r#   r-   r_   rU   rZ   r|   rh   ri   r“   r”   r©   rl   rD   rE   rc   r!   r   r   r   -   s®  € € € € € ðð ð  �R”ZÐ ;Ñ<Ô<€Nð
 HÐGÐGØ�FØAÐAÐAØ/Ð/Ð/Ø'Ð'Ð'ð MÐLÐLð	ð 	Ððð ð ð* ð-ð -ñ „[ð-ð ð&ð &ñ „[ð&ð ðð ñ „[ðð:%ð :%ð :%ðx@ð @ð @ðD!ð !ð !ð !ðF'-ð '-ð '-ðRð ð ðð ð ð"6ð 6ð 6ðpEð Eð Eð=ð =ð =ð~	6ð 	6ð 	6ðð ð ð*Fð Fð Fð*ð *ð *ð *ð *r!   r   c                 ó:  — |                      dd¦  «                             ¦   «         }|dk    rdS 	 t          j        }|dk    rt          j        }t          j        | d|t          j        t          j        t          j        ¦  «        S # t          j	        $ r Y dS w xY w)a  
    Try looking up ``hostname`` in an IPv4 or IPv6 specific manner.

    This is an odd duck due to needing use in two divergent use cases. It looks
    up ``AddressFamily`` in ``options`` and if it is ``inet`` or ``inet6``,
    this function uses `socket.getaddrinfo` to perform a family-specific
    lookup, returning the result if successful.

    In any other situation -- lookup failure, or ``AddressFamily`` being
    unspecified or ``any`` -- ``None`` is returned instead and the caller is
    expected to do something situation-appropriate like calling
    `socket.gethostbyname`.

    :param str hostname: Hostname to look up.
    :param options: `SSHConfigDict` instance w/ parsed options.
    :returns: ``getaddrinfo``-style tuples, or ``None``, depending.
    ÚaddressfamilyrÔ   NÚinet)
rV   rB   rp   ÚAF_INET6ÚAF_INETÚgetaddrinfoÚ
SOCK_DGRAMÚ
IPPROTO_IPÚAI_CANONNAMErr   )r   r[   Úaddress_familyÚfamilys       r   ro   ro   /  s§   € ð$ —[’[ °%Ñ8Ô8×>Ò>Ñ@Ô@€NØ˜ÒÐØˆðÝ”ˆØ˜VÒ#Ð#Ý”^ˆFÝÔ!ØØØÝÔÝÔÝÔñ
ô 
ð 	
øõ Œ?ð ð ð Øˆˆðøøøs   ²AB ÂBÂBc                   ó    — e Zd ZdZdd„Zd„ ZdS )r¬   z7
    Returns the host's fqdn on request as string.
    Nc                 ó0   — d | _         || _        || _        d S rb   )Úfqdnr2   r1   )r   r2   r1   s      r   r    zLazyFqdn.__init__Y  s   € ØˆŒ	ØˆŒØˆŒ	ˆ	ˆ	r!   c                 óÀ   — | j         €Qd }t          | j        | j        ¦  «        }|�|D ]}|\  }}}}}|rd|v r|} nŒ|€t	          j        ¦   «         }|| _         | j         S )NrQ   )rí   ro   r1   r2   rp   Úgetfqdn)	r   rí   ÚresultsÚresÚafÚsocktypeÚprotoÚ	canonnameÚsas	            r   Ú__str__zLazyFqdn.__str__^  s‡   € ØŒ9Ðð ˆDÝ0°´¸D¼KÑHÔHˆGØÐ"Ø"ð ð �CØ9<Ñ6�B˜ %¨°BØ ð  S¨IÐ%5Ð%5Ø(˜Ø˜øàˆ|Ý”~Ñ'Ô'�àˆDŒIØŒyÐr!   rb   )rÚ   rÛ   rÜ   rÝ   r    r÷   rc   r!   r   r¬   r¬   T  sA   € € € € € ðð ðð ð ð ð
ð ð ð ð r!   r¬   c                   ó   — e Zd ZdZd„ Zd„ ZdS )rg   aÃ  
    A dictionary wrapper/subclass for per-host configuration structures.

    This class introduces some usage niceties for consumers of `SSHConfig`,
    specifically around the issue of variable type conversions: normal value
    access yields strings, but there are now methods such as `as_bool` and
    `as_int` that yield casted values instead.

    For example, given the following ``ssh_config`` file snippet::

        Host foo.example.com
            PasswordAuthentication no
            Compression yes
            ServerAliveInterval 60

    the following code highlights how you can access the raw strings as well as
    usefully Python type-casted versions (recalling that keys are all
    normalized to lowercase first)::

        my_config = SSHConfig()
        my_config.parse(open('~/.ssh/config'))
        conf = my_config.lookup('foo.example.com')

        assert conf['passwordauthentication'] == 'no'
        assert conf.as_bool('passwordauthentication') is False
        assert conf['compression'] == 'yes'
        assert conf.as_bool('compression') is True
        assert conf['serveraliveinterval'] == '60'
        assert conf.as_int('serveraliveinterval') == 60

    .. versionadded:: 2.5
    c                 óp   — | |         }t          |t          ¦  «        r|S |                     ¦   «         dk    S )aº  
        Express given key's value as a boolean type.

        Typically, this is used for ``ssh_config``'s pseudo-boolean values
        which are either ``"yes"`` or ``"no"``. In such cases, ``"yes"`` yields
        ``True`` and any other value becomes ``False``.

        .. note::
            If (for whatever reason) the stored value is already boolean in
            nature, it's simply returned.

        .. versionadded:: 2.5
        rN   )rÂ   ÚboolrB   )r   rJ   Úvals      r   Úas_boolzSSHConfigDict.as_boolœ  s7   € ð �3ŒiˆÝ�c�4Ñ Ô ð 	ØˆJØ�yŠy‰{Œ{˜eÒ#Ð#r!   c                 ó,   — t          | |         ¦  «        S )zí
        Express given key's value as an integer, if possible.

        This method will raise ``ValueError`` or similar if the value is not
        int-appropriate, same as the builtin `int` type.

        .. versionadded:: 2.5
        )rW   rÀ   s     r   Úas_intzSSHConfigDict.as_int¯  s   € õ �4˜”9‰~Œ~Ðr!   N)rÚ   rÛ   rÜ   rÝ   rü   rþ   rc   r!   r   rg   rg   z  s=   € € € € € ðð ðB$ð $ð $ð&	ð 	ð 	ð 	ð 	r!   rg   )rÝ   r�   r�   r­   r>   rÉ   rp   Ú	functoolsr   Úhashlibr   Úior   r•   r–   ÚImportErrorÚeÚssh_exceptionr   r   rª   r   ro   r¬   Údictrg   rc   r!   r   ú<module>r     sŠ  ðð(ð ð €€€Ø €€€Ø 	€	€	€	Ø 	€	€	€	Ø €€€Ø €€€Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à(Ñ €ÐðØ€M€M€M€MøØð ð ð ØÐÐÐÐÐÐøøøøðøøøð BÐ AÐ AÐ AÐ AÐ AÐ AÐ Aà€ðð ð ð ð ñ ô ð ðD"ð "ð "ðJ#ð #ð #ð #ð #ñ #ô #ð #ðL>ð >ð >ð >ð >�Dñ >ô >ð >ð >ð >s   ³8 ¸A	½AÁA	