ϪfdZddlZddlmZddlmZmZmZmZddl m Z ddl m Z m Z mZmZddlmZddlmZGd d ej(Zy) z A Factory for SSH servers. See also L{twisted.conch.openssh_compat.factory} for OpenSSH compatibility. Maintainer: Paul Swartz N)chain)DictListOptionalTuple)error)_kex connection transportuserauth)protocol)LoggerceZdZUdZeeeeeeeffe d<e Z e jZej ej$dZddZdZdZd Zdeeeeeeefffd Zd edeeeffd Zd Zy) SSHFactoryz$ A Factory for SSH servers. primes) ssh-userauthsssh-connectionreturnNc&t|ds|j|_t|ds|j|_|jr |jst j dt|ds|j|_yy)z4 Check for public and private keys. publicKeys privateKeyszno host keys, failingrN) hasattr getPublicKeysrgetPrivateKeysrr ConchError getPrimesrselfs ;/usr/lib/python3/dist-packages/twisted/conch/ssh/factory.py startFactoryzSSHFactory.startFactory&swt\*"002DOt]+#224D d&6&6""#:; ;tX&..*DK'ctjj||}tt j d|j jD|_|jsd|jjd|jDcgc].}tj|stj|r|0c}|_ |Scc}w)a= Create an instance of the server side of the SSH protocol. @type addr: L{twisted.internet.interfaces.IAddress} provider @param addr: The address at which the server will listen. @rtype: L{twisted.conch.ssh.transport.SSHServerTransport} @return: The built transport. c3<K|]}|jywN)supportedSignatureAlgorithms).0keys r z+SSHFactory.buildProtocol..?s 7:002 szTdisabling non-fixed-group key exchange algorithms because we cannot find moduli file)r Factory buildProtocollistr from_iterablervaluessupportedPublicKeysr_loginfosupportedKeyExchangesr isFixedGroupisEllipticCurve)raddrt kexAlgorithms rr)zSSHFactory.buildProtocol3s    * *4 6 $    >B>N>N>U>U>W  !  {{ IINN5  %&$;$;' $$\2d6J6J<6X'A #  's3Cctd)z Called when the factory is started to get the public portions of the servers host keys. Returns a dictionary mapping SSH key types to public key strings. @rtype: L{dict} zgetPublicKeys unimplementedNotImplementedErrorrs rrzSSHFactory.getPublicKeysOs""?@@r ctd)z Called when the factory is started to get the private portions of the servers host keys. Returns a dictionary mapping SSH key types to L{twisted.conch.ssh.keys.Key} objects. @rtype: L{dict} zgetPrivateKeys unimplementedr7rs rrzSSHFactory.getPrivateKeysYs""@AAr cy)z Called when the factory is started to get Diffie-Hellman generators and primes to use. Returns a dictionary mapping number of bits to lists of tuple of (generator, prime). Nrs rrzSSHFactory.getPrimescsr bitscdtdtffd }|jJdt|jj|}|d}t j |j|S)z Return a tuple of (g, p) for a Diffe-Hellman process, with p being as close to C{bits} bits as possible. irc t|z Sr#)abs)r>r<s rkeyfuncz&SSHFactory.getDHPrime..keyfuncpsq4x= r z(Factory should have been started by now.)r&r)intrsortedkeysrandomchoice)rr<rA primesKeysrealBitss ` r getDHPrimezSSHFactory.getDHPrimejsh  !s !s !{{&R(RR&DKK,,.G< a=}}T[[233r cD|dk(s t|dr|j|Sy)z Return a class to use as a service for the given transport. @type transport: L{transport.SSHServerTransport} @type service: L{bytes} @rtype: subclass of L{service.SSHService} ravatarN)rservices)rr services r getServicezSSHFactory.getServicexs* o %H)E==) )*Fr )rN)__name__ __module__ __qualname____doc__rrrBrr__annotations__rr.r SSHServerTransportr r SSHUserAuthServerr SSHConnectionrLrr)rrrrIrNr;r rrrs T#tE#s(O445 66 8D++H"33%33H +8AB 8Dd5c?.C)C$DE  4s 4uS#X 4 *r r)rRrE itertoolsrtypingrrrr twisted.conchrtwisted.conch.sshr r r r twisted.internetr twisted.loggerrr(rr;r rr]s;..CC%!j*!!j*r