Esempio n. 1
0
 def __init__(self):
     #this may be called more than once,
     #skip doing internal init again:
     if not hasattr(self, "exit_code"):
         self.defaults_init()
     ServerInfoMixin.__init__(self)
     FilePrintMixin.__init__(self)
     self._init_done = False
Esempio n. 2
0
 def cleanup(self):
     reaper_cleanup()
     FilePrintMixin.cleanup(self)
     p = self._protocol
     log("XpraClientBase.cleanup() protocol=%s", p)
     if p:
         log("calling %s", p.close)
         p.close()
         self._protocol = None
     log("cleanup done")
     self.cancel_send_mouse_position_timer()
     dump_all_frames()
Esempio n. 3
0
 def cleanup(self):
     reaper_cleanup()
     try:
         FilePrintMixin.cleanup(self)
     except Exception:
         log.error("%s", FilePrintMixin.cleanup, exc_info=True)
     p = self._protocol
     log("XpraClientBase.cleanup() protocol=%s", p)
     if p:
         log("calling %s", p.close)
         p.close()
         self._protocol = None
     log("cleanup done")
     self.cancel_send_mouse_position_timer()
     dump_all_frames()
Esempio n. 4
0
    def make_hello_base(self):
        capabilities = flatten_dict(get_network_caps())
        #add "kerberos", "gss" and "u2f" digests if enabled:
        for handler in self.challenge_handlers:
            digest = handler.get_digest()
            if digest:
                capabilities["digest"].append(digest)
        capabilities.update(FilePrintMixin.get_caps(self))
        capabilities.update({
            "version": XPRA_VERSION,
            "websocket.multi-packet": True,
            "hostname": socket.gethostname(),
            "uuid": self.uuid,
            "session-id": self.session_id,
            "username": self.username,
            "name": get_name(),
            "client_type": self.client_type(),
            "python.version": sys.version_info[:3],
            "python.bits": BITS,
            "compression_level": self.compression_level,
            "argv": sys.argv,
        })
        capabilities.update(self.get_file_transfer_features())
        if self.display:
            capabilities["display"] = self.display

        def up(prefix, d):
            updict(capabilities, prefix, d)

        up("build", self.get_version_info())
        mid = get_machine_id()
        if mid:
            capabilities["machine_id"] = mid
        encryption = self.get_encryption()
        if encryption:
            crypto_backend_init()
            assert encryption in ENCRYPTION_CIPHERS, "invalid encryption '%s', options: %s" % (
                encryption, csv(ENCRYPTION_CIPHERS))
            iv = get_iv()
            key_salt = get_salt()
            iterations = get_iterations()
            padding = choose_padding(self.server_padding_options)
            up(
                "cipher", {
                    "": encryption,
                    "iv": iv,
                    "key_salt": key_salt,
                    "key_stretch_iterations": iterations,
                    "padding": padding,
                    "padding.options": PADDING_OPTIONS,
                })
            key = self.get_encryption_key()
            self._protocol.set_cipher_in(encryption, iv, key, key_salt,
                                         iterations, padding)
            netlog(
                "encryption capabilities: %s",
                dict((k, v) for k, v in capabilities.items()
                     if k.startswith("cipher")))
        capabilities.update(self.hello_extra)
        return capabilities
Esempio n. 5
0
 def __init__(self):
     #this may be called more than once,
     #skip doing internal init again:
     if not hasattr(self, "exit_code"):
         self.defaults_init()
     FilePrintMixin.__init__(self)
     self._init_done = False
     #insert in order:
     dcm = OrderedDict()
     dcm["uri"] = self.process_challenge_uri
     dcm["file"] = self.process_challenge_file
     dcm["env"] = self.process_challenge_env
     dcm["kerberos"] = self.process_challenge_kerberos
     dcm["gss"] = self.process_challenge_gss
     dcm["u2f"] = self.process_challenge_u2f
     dcm["prompt"] = self.process_challenge_prompt
     self.default_challenge_methods = dcm
Esempio n. 6
0
 def make_hello_base(self):
     capabilities = flatten_dict(get_network_caps())
     #add "kerberos" and "gss" if enabled:
     default_on = "all" in self.challenge_handlers or "auto" in self.challenge_handlers
     for auth in ("kerberos", "gss", "u2f"):
         if default_on or auth in self.challenge_handlers:
             capabilities["digest"].append(auth)
     capabilities.update(FilePrintMixin.get_caps(self))
     capabilities.update({
             "version"               : XPRA_VERSION,
             "encoding.generic"      : True,
             "namespace"             : True,
             "websocket.multi-packet": True,
             "hostname"              : socket.gethostname(),
             "uuid"                  : self.uuid,
             "username"              : self.username,
             "name"                  : get_name(),
             "client_type"           : self.client_type(),
             "python.version"        : sys.version_info[:3],
             "python.bits"           : BITS,
             "compression_level"     : self.compression_level,
             "argv"                  : sys.argv,
             })
     capabilities.update(self.get_file_transfer_features())
     if self.display:
         capabilities["display"] = self.display
     def up(prefix, d):
         updict(capabilities, prefix, d)
     up("build",     self.get_version_info())
     mid = get_machine_id()
     if mid:
         capabilities["machine_id"] = mid
     if self.encryption:
         assert self.encryption in ENCRYPTION_CIPHERS
         iv = get_iv()
         key_salt = get_salt()
         iterations = get_iterations()
         padding = choose_padding(self.server_padding_options)
         up("cipher", {
                 ""                      : self.encryption,
                 "iv"                    : iv,
                 "key_salt"              : key_salt,
                 "key_stretch_iterations": iterations,
                 "padding"               : padding,
                 "padding.options"       : PADDING_OPTIONS,
                 })
         key = self.get_encryption_key()
         if key is None:
             self.warn_and_quit(EXIT_ENCRYPTION, "encryption key is missing")
             return None
         self._protocol.set_cipher_in(self.encryption, iv, key, key_salt, iterations, padding)
         netlog("encryption capabilities: %s", dict((k,v) for k,v in capabilities.items() if k.startswith("cipher")))
     capabilities.update(self.hello_extra)
     return capabilities
Esempio n. 7
0
 def init_authenticated_packet_handlers(self):
     FilePrintMixin.init_authenticated_packet_handlers(self)
Esempio n. 8
0
 def make_hello_base(self):
     capabilities = flatten_dict(get_network_caps())
     #add "kerberos", "gss" and "u2f" digests if enabled:
     for handler in self.challenge_handlers:
         digest = handler.get_digest()
         if digest:
             capabilities["digest"].append(digest)
     capabilities.update(FilePrintMixin.get_caps(self))
     capabilities.update({
             "version"               : XPRA_VERSION,
             "websocket.multi-packet": True,
             "hostname"              : socket.gethostname(),
             "uuid"                  : self.uuid,
             "session-id"            : self.session_id,
             "username"              : self.username,
             "name"                  : get_name(),
             "client_type"           : self.client_type(),
             "python.version"        : sys.version_info[:3],
             "python.bits"           : BITS,
             "compression_level"     : self.compression_level,
             "argv"                  : sys.argv,
             })
     capabilities.update(self.get_file_transfer_features())
     if self.display:
         capabilities["display"] = self.display
     def up(prefix, d):
         updict(capabilities, prefix, d)
     up("build",     self.get_version_info())
     mid = get_machine_id()
     if mid:
         capabilities["machine_id"] = mid
     encryption = self.get_encryption()
     cryptolog("encryption=%s", encryption)
     if encryption:
         crypto_backend_init()
         enc, mode = (encryption+"-").split("-")[:2]
         if not mode:
             mode = DEFAULT_MODE
         assert enc in ENCRYPTION_CIPHERS, "invalid encryption '%s', options: %s" % (enc, csv(ENCRYPTION_CIPHERS))
         assert mode in MODES, "invalid encryption mode '%s', options: %s" % (mode, csv(MODES))
         iv = get_iv()
         key_salt = get_salt()
         iterations = get_iterations()
         padding = choose_padding(self.server_padding_options)
         cipher_caps = {
             ""                      : enc,
             "mode"                  : mode,
             "iv"                    : iv,
             "key_salt"              : key_salt,
             "key_size"              : DEFAULT_KEYSIZE,
             "key_hash"              : DEFAULT_KEY_HASH,
             "key_stretch"           : "PBKDF2",
             "key_stretch_iterations": iterations,
             "padding"               : padding,
             "padding.options"       : PADDING_OPTIONS,
             }
         cryptolog("cipher_caps=%s", cipher_caps)
         up("cipher", cipher_caps)
         key = self.get_encryption_key()
         self._protocol.set_cipher_in(encryption, iv, key,
                                      key_salt, DEFAULT_KEY_HASH, DEFAULT_KEYSIZE, iterations, padding)
     capabilities.update(self.hello_extra)
     return capabilities
Esempio n. 9
0
    def make_hello_base(self):
        capabilities = flatten_dict(get_network_caps())
        #add "kerberos" and "gss" if enabled:
        default_on = "all" in self.challenge_handlers or "auto" in self.challenge_handlers
        for auth in ("kerberos", "gss", "u2f"):
            if default_on or auth in self.challenge_handlers:
                capabilities["digest"].append(auth)
        capabilities.update(FilePrintMixin.get_caps(self))
        capabilities.update({
            "version": XPRA_VERSION,
            "encoding.generic": True,
            "namespace": True,
            "hostname": socket.gethostname(),
            "uuid": self.uuid,
            "username": self.username,
            "name": get_name(),
            "client_type": self.client_type(),
            "python.version": sys.version_info[:3],
            "python.bits": BITS,
            "compression_level": self.compression_level,
            "argv": sys.argv,
        })
        capabilities.update(self.get_file_transfer_features())
        if self.display:
            capabilities["display"] = self.display

        def up(prefix, d):
            updict(capabilities, prefix, d)

        up("build", self.get_version_info())
        mid = get_machine_id()
        if mid:
            capabilities["machine_id"] = mid
        #get socket speed if we have it:
        pinfo = self._protocol.get_info()
        netlog("protocol info=%s", pinfo)
        socket_speed = pinfo.get("socket", {}).get("speed")
        if socket_speed:
            capabilities["connection-data"] = {"speed": socket_speed}
        bandwidth_limit = self.bandwidth_limit
        bandwidthlog("bandwidth-limit setting=%s, socket-speed=%s",
                     self.bandwidth_limit, socket_speed)
        if bandwidth_limit is None:
            if socket_speed:
                #auto: use 80% of socket speed if we have it:
                bandwidth_limit = socket_speed * AUTO_BANDWIDTH_PCT // 100 or 0
            else:
                bandwidth_limit = 0
        bandwidthlog("bandwidth-limit capability=%s", bandwidth_limit)
        if bandwidth_limit > 0:
            capabilities["bandwidth-limit"] = bandwidth_limit

        if self.encryption:
            assert self.encryption in ENCRYPTION_CIPHERS
            iv = get_iv()
            key_salt = get_salt()
            iterations = get_iterations()
            padding = choose_padding(self.server_padding_options)
            up(
                "cipher", {
                    "": self.encryption,
                    "iv": iv,
                    "key_salt": key_salt,
                    "key_stretch_iterations": iterations,
                    "padding": padding,
                    "padding.options": PADDING_OPTIONS,
                })
            key = self.get_encryption_key()
            if key is None:
                self.warn_and_quit(EXIT_ENCRYPTION,
                                   "encryption key is missing")
                return
            self._protocol.set_cipher_in(self.encryption, iv, key, key_salt,
                                         iterations, padding)
            netlog(
                "encryption capabilities: %s",
                dict((k, v) for k, v in capabilities.items()
                     if k.startswith("cipher")))
        capabilities.update(self.hello_extra)
        return capabilities