Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

options.py 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. # Copyright (c) Twisted Matrix Laboratories.
  2. # See LICENSE for details.
  3. import sys
  4. from typing import List, Optional, Union
  5. #
  6. from twisted.conch.ssh.transport import SSHCiphers, SSHClientTransport
  7. from twisted.python import usage
  8. class ConchOptions(usage.Options):
  9. optParameters: List[List[Optional[Union[str, int]]]] = [
  10. ["user", "l", None, "Log in using this user name."],
  11. ["identity", "i", None],
  12. ["ciphers", "c", None],
  13. ["macs", "m", None],
  14. ["port", "p", None, "Connect to this port. Server must be on the same port."],
  15. ["option", "o", None, "Ignored OpenSSH options"],
  16. ["host-key-algorithms", "", None],
  17. ["known-hosts", "", None, "File to check for host keys"],
  18. ["user-authentications", "", None, "Types of user authentications to use."],
  19. ["logfile", "", None, "File to log to, or - for stdout"],
  20. ]
  21. optFlags = [
  22. ["version", "V", "Display version number only."],
  23. ["compress", "C", "Enable compression."],
  24. ["log", "v", "Enable logging (defaults to stderr)"],
  25. ["nox11", "x", "Disable X11 connection forwarding (default)"],
  26. ["agent", "A", "Enable authentication agent forwarding"],
  27. ["noagent", "a", "Disable authentication agent forwarding (default)"],
  28. ["reconnect", "r", "Reconnect to the server if the connection is lost."],
  29. ]
  30. compData = usage.Completions(
  31. mutuallyExclusive=[("agent", "noagent")],
  32. optActions={
  33. "user": usage.CompleteUsernames(),
  34. "ciphers": usage.CompleteMultiList(
  35. [v.decode() for v in SSHCiphers.cipherMap.keys()],
  36. descr="ciphers to choose from",
  37. ),
  38. "macs": usage.CompleteMultiList(
  39. [v.decode() for v in SSHCiphers.macMap.keys()],
  40. descr="macs to choose from",
  41. ),
  42. "host-key-algorithms": usage.CompleteMultiList(
  43. [v.decode() for v in SSHClientTransport.supportedPublicKeys],
  44. descr="host key algorithms to choose from",
  45. ),
  46. # "user-authentications": usage.CompleteMultiList(?
  47. # descr='user authentication types' ),
  48. },
  49. extraActions=[
  50. usage.CompleteUserAtHost(),
  51. usage.Completer(descr="command"),
  52. usage.Completer(descr="argument", repeat=True),
  53. ],
  54. )
  55. def __init__(self, *args, **kw):
  56. usage.Options.__init__(self, *args, **kw)
  57. self.identitys = []
  58. self.conns = None
  59. def opt_identity(self, i):
  60. """Identity for public-key authentication"""
  61. self.identitys.append(i)
  62. def opt_ciphers(self, ciphers):
  63. "Select encryption algorithms"
  64. ciphers = ciphers.split(",")
  65. for cipher in ciphers:
  66. if cipher not in SSHCiphers.cipherMap:
  67. sys.exit("Unknown cipher type '%s'" % cipher)
  68. self["ciphers"] = ciphers
  69. def opt_macs(self, macs):
  70. "Specify MAC algorithms"
  71. if isinstance(macs, str):
  72. macs = macs.encode("utf-8")
  73. macs = macs.split(b",")
  74. for mac in macs:
  75. if mac not in SSHCiphers.macMap:
  76. sys.exit("Unknown mac type '%r'" % mac)
  77. self["macs"] = macs
  78. def opt_host_key_algorithms(self, hkas):
  79. "Select host key algorithms"
  80. if isinstance(hkas, str):
  81. hkas = hkas.encode("utf-8")
  82. hkas = hkas.split(b",")
  83. for hka in hkas:
  84. if hka not in SSHClientTransport.supportedPublicKeys:
  85. sys.exit("Unknown host key type '%r'" % hka)
  86. self["host-key-algorithms"] = hkas
  87. def opt_user_authentications(self, uas):
  88. "Choose how to authenticate to the remote server"
  89. if isinstance(uas, str):
  90. uas = uas.encode("utf-8")
  91. self["user-authentications"] = uas.split(b",")
  92. # def opt_compress(self):
  93. # "Enable compression"
  94. # self.enableCompression = 1
  95. # SSHClientTransport.supportedCompressions[0:1] = ['zlib']