|
| 1 | +# This file is part of ssh-python. |
| 2 | +# Copyright (C) 2018 Panos Kittenis |
| 3 | +# |
| 4 | +# This library is free software; you can redistribute it and/or |
| 5 | +# modify it under the terms of the GNU Lesser General Public |
| 6 | +# License as published by the Free Software Foundation, version 2.1. |
| 7 | +# |
| 8 | +# This library is distributed in the hope that it will be useful, |
| 9 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 | +# Lesser General Public License for more details. |
| 12 | +# |
| 13 | +# You should have received a copy of the GNU Lesser General Public |
| 14 | +# License along with this library; if not, write to the Free Software |
| 15 | +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130 |
| 16 | + |
| 17 | +from c_ssh cimport ssh_options_e |
| 18 | + |
| 19 | + |
| 20 | +cdef class Option: |
| 21 | + """Class for representing an SSH option.""" |
| 22 | + |
| 23 | + @staticmethod |
| 24 | + cdef object from_option(ssh_options_e option): |
| 25 | + cdef Option _option = Option.__new__(Option) |
| 26 | + _option._option = option |
| 27 | + return _option |
| 28 | + |
| 29 | + @property |
| 30 | + def value(self): |
| 31 | + return self._option |
| 32 | + |
| 33 | + def __str__(self): |
| 34 | + return str(self._option) |
| 35 | + |
| 36 | + def __repr__(self): |
| 37 | + return self.__str__() |
| 38 | + |
| 39 | + |
| 40 | +HOST = Option.from_option(ssh_options_e.SSH_OPTIONS_HOST) |
| 41 | +USER = Option.from_option(ssh_options_e.SSH_OPTIONS_USER) |
| 42 | +PORT = Option.from_option(ssh_options_e.SSH_OPTIONS_PORT) |
| 43 | +PORT_STR = Option.from_option(ssh_options_e.SSH_OPTIONS_PORT_STR) |
| 44 | +FD = Option.from_option(ssh_options_e.SSH_OPTIONS_FD) |
| 45 | +USER = Option.from_option(ssh_options_e.SSH_OPTIONS_USER) |
| 46 | +SSH_DIR = Option.from_option(ssh_options_e.SSH_OPTIONS_SSH_DIR) |
| 47 | +IDENTITY = Option.from_option(ssh_options_e.SSH_OPTIONS_IDENTITY) |
| 48 | +ADD_IDENTITY = Option.from_option(ssh_options_e.SSH_OPTIONS_ADD_IDENTITY) |
| 49 | +KNOWNHOSTS = Option.from_option(ssh_options_e.SSH_OPTIONS_KNOWNHOSTS) |
| 50 | +TIMEOUT = Option.from_option(ssh_options_e.SSH_OPTIONS_TIMEOUT) |
| 51 | +TIMEOUT_USEC = Option.from_option(ssh_options_e.SSH_OPTIONS_TIMEOUT_USEC) |
| 52 | +SSH1 = Option.from_option(ssh_options_e.SSH_OPTIONS_SSH1) |
| 53 | +SSH2 = Option.from_option(ssh_options_e.SSH_OPTIONS_SSH2) |
| 54 | +LOG_VERBOSITY = Option.from_option(ssh_options_e.SSH_OPTIONS_LOG_VERBOSITY) |
| 55 | +LOG_VERBOSITY_STR = Option.from_option(ssh_options_e.SSH_OPTIONS_LOG_VERBOSITY_STR) |
| 56 | +CIPHERS_C_S = Option.from_option(ssh_options_e.SSH_OPTIONS_CIPHERS_C_S) |
| 57 | +CIPHERS_S_C = Option.from_option(ssh_options_e.SSH_OPTIONS_CIPHERS_S_C) |
| 58 | +COMPRESSION_C_S = Option.from_option(ssh_options_e.SSH_OPTIONS_COMPRESSION_C_S) |
| 59 | +COMPRESSION_S_C = Option.from_option(ssh_options_e.SSH_OPTIONS_COMPRESSION_S_C) |
| 60 | +PROXYCOMMAND = Option.from_option(ssh_options_e.SSH_OPTIONS_PROXYCOMMAND) |
| 61 | +BINDADDR = Option.from_option(ssh_options_e.SSH_OPTIONS_BINDADDR) |
| 62 | +STRICTHOSTKEYCHECK = Option.from_option(ssh_options_e.SSH_OPTIONS_STRICTHOSTKEYCHECK) |
| 63 | +COMPRESSION = Option.from_option(ssh_options_e.SSH_OPTIONS_COMPRESSION) |
| 64 | +COMPRESSION_LEVEL = Option.from_option(ssh_options_e.SSH_OPTIONS_COMPRESSION_LEVEL) |
| 65 | +KEY_EXCHANGE = Option.from_option(ssh_options_e.SSH_OPTIONS_KEY_EXCHANGE) |
| 66 | +HOSTKEYS = Option.from_option(ssh_options_e.SSH_OPTIONS_HOSTKEYS) |
| 67 | +GSSAPI_SERVER_IDENTITY = Option.from_option(ssh_options_e.SSH_OPTIONS_GSSAPI_SERVER_IDENTITY) |
| 68 | +GSSAPI_CLIENT_IDENTITY = Option.from_option(ssh_options_e.SSH_OPTIONS_GSSAPI_CLIENT_IDENTITY) |
| 69 | +GSSAPI_DELEGATE_CREDENTIALS = Option.from_option(ssh_options_e.SSH_OPTIONS_GSSAPI_DELEGATE_CREDENTIALS) |
| 70 | +HMAC_C_S = Option.from_option(ssh_options_e.SSH_OPTIONS_HMAC_C_S) |
| 71 | +HMAC_S_C = Option.from_option(ssh_options_e.SSH_OPTIONS_HMAC_S_C) |
| 72 | +PASSWORD_AUTH = Option.from_option(ssh_options_e.SSH_OPTIONS_PASSWORD_AUTH) |
| 73 | +PUBKEY_AUTH = Option.from_option(ssh_options_e.SSH_OPTIONS_PUBKEY_AUTH) |
| 74 | +KBDINT_AUTH = Option.from_option(ssh_options_e.SSH_OPTIONS_KBDINT_AUTH) |
| 75 | +GSSAPI_AUTH = Option.from_option(ssh_options_e.SSH_OPTIONS_GSSAPI_AUTH) |
| 76 | +GLOBAL_KNOWNHOSTS = Option.from_option(ssh_options_e.SSH_OPTIONS_GLOBAL_KNOWNHOSTS) |
| 77 | +NODELAY = Option.from_option(ssh_options_e.SSH_OPTIONS_NODELAY) |
0 commit comments