
    \dv                         d Z ddlmZ ddlmZmZ ddlmZ ddl	m
Z
mZ ddlmZ  G d dej        ej                  Zd	 Zd
S )z4
Support module for making SSH servers with twistd.
    )strports)checkersunix)factory)portalstrcred)usagec                        e Zd ZdZdZg dg dg dg dgZ ej         ej        d           ej        d	           ej	                    d
          Z
 fdZ fdZ xZS )Optionsz([-i <interface>] [-p <port>] [-d <dir>] zMakes a Conch SSH server.  If no authentication methods are specified, the default authentication methods are UNIX passwords and SSH public keys.  If --auth options are passed, only the measures specified will be used.)	interfacei z"local interface to which we listen)portpztcp:22zPort on which to listen)datadz/etcz"directory to look for host keys in)modulir   Nz:directory to look for moduli in (if different from --data)zdata directory)descrzmoduli directory)r   r   r   )
optActionsc                 6   t          j        j        | g|R i | t                                          t          j                               t                                          t          j        t          j                                         d| _	        d S )NT)
r	   r   __init__super
addCheckerconch_checkersUNIXPasswordDatabaseSSHPublicKeyCheckerUNIXAuthorizedKeysFiles_usingDefaultAuth)selfakw	__class__s      1lib/python3.11/site-packages/twisted/conch/tap.pyr   zOptions.__init__+   s    t.a...2... 	>>@@AAA.~/U/W/WXX	
 	
 	
 "&    c                 z    | j         rg | d<   i | d<   d| _         t                                          |           dS )z
        Add the checker specified.  If any checkers are added, the default
        checkers are automatically cleared and the only checkers will be the
        specified one(s).
        credCheckerscredInterfacesFN)r   r   r   )r   checkerr"   s     r#   r   zOptions.addChecker8   sK     ! 	+#%D %'D!"%*D"7#####r$   )__name__
__module____qualname__synopsislongdescoptParametersr	   CompletionsCompleteDirsCompleteNetInterfacescompDatar   r   __classcell__)r"   s   @r#   r   r      s        9H	<  	EDD:::CCC	
 	
 	
	
M !u &E&-=>>>(e(/ABBB4466
 
  H& & & & &
$ 
$ 
$ 
$ 
$ 
$ 
$ 
$ 
$r$   r   c                 T   t          j                    }t          j                    }t	          j        ||                     dg                     |_        | d         |_        | d         p| d         |_        | d         }| d         r|d| d         z   z  }t          j
        ||          S )aH  
    Construct a service for operating a SSH server.

    @param config: An L{Options} instance specifying server options, including
        where server keys are stored and what authentication methods to use.

    @return: A L{twisted.application.service.IService} provider which contains
        the requested SSH server.
    r&   r   r   r   r   z:interface=)r   OpenSSHFactoryr   UnixSSHRealmr   PortalgetdataRoot
moduliRootr   service)configtrr   s       r#   makeServicer?   E   s     	  AA}Q

>2 > >??AHAJ(#5vf~AL&>Dk 4{ 333D!$$$r$   N)__doc__twisted.applicationr   twisted.conchr   r   r   twisted.conch.openssh_compatr   twisted.credr   r   twisted.pythonr	   r   AuthOptionMixinr?    r$   r#   <module>rH      s   
  ) ( ( ( ( ( : : : : : : : : 0 0 0 0 0 0 ( ( ( ( ( ( ( (            2$ 2$ 2$ 2$ 2$emW4 2$ 2$ 2$j% % % % %r$   