コード例 #1
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
コード例 #2
0
ファイル: client_base.py プロジェクト: DiGuoZhiMeng/Xpra
 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
コード例 #3
0
 def filter_caps(self, caps, prefixes):
     #removes caps that the proxy overrides / does not use:
     pcaps = {}
     removed = []
     for k in caps.keys():
         if any(e for e in prefixes if bytestostr(k).startswith(e)):
             removed.append(k)
         else:
             pcaps[k] = caps[k]
     log("filtered out %s matching %s", removed, prefixes)
     #replace the network caps with the proxy's own:
     pcaps.update(flatten_dict(get_network_caps()))
     #then add the proxy info:
     updict(pcaps, "proxy", get_server_info(), flatten_dicts=True)
     pcaps["proxy"] = True
     pcaps["proxy.hostname"] = socket.gethostname()
     return pcaps
コード例 #4
0
ファイル: client_base.py プロジェクト: frostbane/xpra
 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
コード例 #5
0
    def make_hello_base(self):
        capabilities = flatten_dict(get_network_caps())
        import struct
        bits = struct.calcsize("P") * 8
        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
        log("bandwidth-limit=%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
        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
コード例 #6
0
 def send_info():
     info = self.get_info()
     info["network"] = get_network_caps()
     hello_reply(info)
コード例 #7
0
ファイル: network_listener.py プロジェクト: DiGuoZhiMeng/Xpra
 def send_info():
     info = self.get_info()
     info["network"] = get_network_caps()
     proto.send_now(["hello", info])