Example #1
0
 def reset_client(self):
     #lose current client class and make a new one:
     if self.client:
         self.client.cleanup()
         self.client = None
     self.client = make_client(Exception, self.config)
     self.client.init(self.config)
Example #2
0
 def reset_client(self):
     #lose current client class and make a new one:
     if self.client:
         self.client.cleanup()
         self.client = None
     self.client = make_client(Exception, self.config)
     self.client.init(self.config)
Example #3
0
    def __init__(self):
        # Default connection options
        self.config = make_defaults_struct()
        self.config.ssh_port = "22"
        # what we save by default:
        self.config_keys = set(
            [
                "username",
                "password",
                "host",
                "port",
                "mode",
                "ssh_port",
                "encoding",
                "quality",
                "min-quality",
                "speed",
                "min-speed",
            ]
        )
        if is_gtk3():
            self.config.client_toolkit = "gtk3"
        else:
            self.config.client_toolkit = "gtk2"

        def raise_exception(*args):
            raise Exception(*args)

        self.client = make_client(raise_exception, self.config)
        self.client.init(self.config)
        self.exit_code = None
Example #4
0
 def    __init__(self):
     # Default connection options
     self.config = make_defaults_struct()
     #what we save by default:
     self.config_keys = set(["username", "password", "host", "port", "mode",
                             "encoding", "quality", "min-quality", "speed", "min-speed"])
     self.config.client_toolkit = "gtk2"
     self.client = make_client(Exception, self.config)
     self.exit_code = None
Example #5
0
 def __init__(self):
     # Default connection options
     self.config = make_defaults_struct()
     #what we save by default:
     self.config_keys = set([
         "username", "password", "host", "port", "mode", "encoding",
         "quality", "min-quality", "speed", "min-speed"
     ])
     self.config.client_toolkit = "gtk2"
     self.client = make_client(Exception, self.config)
     self.exit_code = None
Example #6
0
 def    __init__(self):
     # Default connection options
     self.config = make_defaults_struct(extras_defaults=LAUNCHER_DEFAULTS, extras_types=LAUNCHER_OPTION_TYPES, extras_validation=self.get_launcher_validation())
     #TODO: the fixup does not belong here?
     from xpra.scripts.main import fixup_options
     fixup_options(self.config)
     #what we save by default:
     self.config_keys = set(SAVED_FIELDS)
     def raise_exception(*args):
         raise Exception(*args)
     self.client = make_client(raise_exception, self.config)
     self.client.init(self.config)
     self.exit_code = None
Example #7
0
 def    __init__(self):
     # Default connection options
     self.config = make_defaults_struct(extras_defaults=LAUNCHER_DEFAULTS, extras_types=LAUNCHER_OPTION_TYPES, extras_validation=LAUNCHER_VALIDATION)
     #TODO: the fixup does not belong here?
     from xpra.scripts.main import fixup_options
     fixup_options(self.config)
     #what we save by default:
     self.config_keys = set(SAVED_FIELDS)
     def raise_exception(*args):
         raise Exception(*args)
     self.client = make_client(raise_exception, self.config)
     self.client.init(self.config)
     self.exit_code = None
Example #8
0
 def reset_client(self):
     #lose current client class and make a new one:
     log("reset_client() client=%s", self.client)
     c = self.client
     if c:
         self.client = None
         def noop(*args):
             pass
         c.disconnect_and_quit = noop
         c.quit = noop
         c.exit = noop
         c.cleanup()
     self.client = make_client(Exception, self.config)
     self.client.init(self.config)
     log("reset_client() new client=%s", self.client)
Example #9
0
 def    __init__(self):
     # Default connection options
     self.config = make_defaults_struct(extras_defaults=LAUNCHER_DEFAULTS, extras_types=LAUNCHER_OPTION_TYPES, extras_validation=LAUNCHER_VALIDATION)
     #TODO: the fixup does not belong here?
     from xpra.scripts.main import fixup_video_all_or_none, fixup_encodings, fixup_compression, fixup_packetencoding
     fixup_video_all_or_none(self.config)
     fixup_encodings(self.config)
     fixup_compression(self.config)
     fixup_packetencoding(self.config)
     #what we save by default:
     self.config_keys = set(SAVED_FIELDS)
     def raise_exception(*args):
         raise Exception(*args)
     self.client = make_client(raise_exception, self.config)
     self.client.init(self.config)
     self.exit_code = None
Example #10
0
    def start_client(self, display_desc):
        def raise_exception(*args):
            raise Exception(*args)

        self.client = make_client(raise_exception, self.config)
        self.client.show_progress(30, "client configuration")
        self.client.init(self.config)
        self.client.show_progress(40, "loading user interface")
        self.client.init_ui(self.config)
        self.client.username = display_desc.get("username")

        def handshake_complete(*_args):
            self.client.show_progress(100, "connection established")

        self.client.after_handshake(handshake_complete)
        self.set_info_text("Connecting...")
        start_thread(self.do_connect_builtin,
                     "connect",
                     daemon=True,
                     args=(display_desc, ))
Example #11
0
 def    __init__(self):
     # Default connection options
     self.config = make_defaults_struct(extras_defaults=LAUNCHER_DEFAULTS, extras_types=LAUNCHER_OPTION_TYPES, extras_validation=LAUNCHER_VALIDATION)
     #TODO: the fixup does not belong here?
     from xpra.scripts.main import fixup_video_all_or_none, fixup_encodings, fixup_compression, fixup_packetencoding
     fixup_video_all_or_none(self.config)
     fixup_encodings(self.config)
     fixup_compression(self.config)
     fixup_packetencoding(self.config)
     #what we save by default:
     self.config_keys = set(SAVED_FIELDS)
     if is_gtk3():
         self.config.client_toolkit = "gtk3"
     else:
         self.config.client_toolkit = "gtk2"
     def raise_exception(*args):
         raise Exception(*args)
     self.client = make_client(raise_exception, self.config)
     self.client.init(self.config)
     self.exit_code = None
Example #12
0
    def __init__(self):
        # Default connection options
        self.config = make_defaults_struct()
        self.config.ssh_port = "22"
        #what we save by default:
        self.config_keys = set([
            "username", "password", "host", "port", "mode", "ssh_port",
            "encoding", "quality", "min-quality", "speed", "min-speed"
        ])
        if is_gtk3():
            self.config.client_toolkit = "gtk3"
        else:
            self.config.client_toolkit = "gtk2"

        def raise_exception(*args):
            raise Exception(*args)

        self.client = make_client(raise_exception, self.config)
        self.client.init(self.config)
        self.exit_code = None
Example #13
0
    def connect_builtin(self):
        #cooked vars used by connect_to
        params = {"type": self.config.mode}
        username = self.config.username
        if self.config.mode == "ssh":
            if self.config.socket_dir:
                params["socket_dir"] = self.config.socket_dir
            params["remote_xpra"] = self.config.remote_xpra
            params["proxy_command"] = ["_proxy"]
            if self.config.port and self.config.port > 0:
                params["display"] = ":%s" % self.config.port
                params["display_as_args"] = [params["display"]]
            else:
                params["display"] = "auto"
                params["display_as_args"] = []
            full_ssh = parse_ssh_string(self.config.ssh)
            ssh_cmd = full_ssh[0].lower()
            is_putty = ssh_cmd.endswith("plink") or ssh_cmd.endswith(
                "plink.exe")
            is_paramiko = ssh_cmd == "paramiko"
            params["is_putty"] = is_putty
            params["is_paramiko"] = is_paramiko
            password = self.config.password
            host = self.config.host
            upos = host.find("@")
            if upos >= 0:
                #found at sign: username@host
                username = host[:upos]
                host = host[upos + 1:]
                ppos = username.find(":")
                if ppos >= 0:
                    #found separator: username:password@host
                    password = username[ppos + 1:]
                    username = username[:ppos]
            if self.config.ssh_port and self.config.ssh_port != 22:
                params["ssh-port"] = self.config.ssh_port
            full_ssh += add_ssh_args(username, password, host,
                                     self.config.ssh_port, is_putty,
                                     is_paramiko)
            if username:
                params["username"] = username
            if self.nostrict_host_check.get_active():
                full_ssh += ["-o", "StrictHostKeyChecking=no"]
            params["host"] = host
            params["local"] = is_local(self.config.host)
            params["full_ssh"] = full_ssh
            params["password"] = password
            params["display_name"] = "ssh:%s:%s" % (self.config.host,
                                                    self.config.port)
        elif self.config.mode == "unix-domain":
            params["display"] = ":%s" % self.config.port
            params["display_name"] = "unix-domain:%s" % self.config.port
        else:
            assert self.config.mode in (
                "tcp", "ssl", "ws",
                "wss"), "invalid / unsupported mode %s" % self.config.mode
            params["host"] = self.config.host
            params["local"] = is_local(self.config.host)
            params["port"] = int(self.config.port)
            params["display_name"] = "%s:%s:%s" % (
                self.config.mode, self.config.host, self.config.port)
            if self.config.mode == "ssl" and self.nostrict_host_check.get_active(
            ):
                params["strict-host-check"] = False

        #print("connect_to(%s)" % params)
        #UGLY warning: the username may have been updated during display parsing,
        #or the config file may contain a username which is different from the default one
        #which is used for initializing the client during init,
        #so update the client now:
        def raise_exception(*args):
            raise Exception(*args)

        self.client = make_client(raise_exception, self.config)
        self.client.init(self.config)
        self.client.username = username
        self.set_info_text("Connecting...")
        thread.start_new_thread(self.do_connect_builtin, (params, ))
Example #14
0
    def connect_builtin(self):
        #cooked vars used by connect_to
        params = {"type": self.config.mode}
        self.config.sharing = self.sharing.get_active()
        username = self.config.username
        if self.config.mode == "ssh" or self.config.mode == "ssh -> ssh":
            if self.config.socket_dir:
                params["socket_dir"] = self.config.socket_dir
            params["remote_xpra"] = self.config.remote_xpra
            params["proxy_command"] = ["_proxy"]
            if self.config.port and self.config.port > 0:
                params["display"] = ":%s" % self.config.port
                params["display_as_args"] = [params["display"]]
            else:
                params["display"] = "auto"
                params["display_as_args"] = []
            params["ssh"] = self.config.ssh
            params["is_putty"] = self.is_putty
            params["is_paramiko"] = self.is_paramiko
            password = self.config.password
            host = self.config.host
            upos = host.find("@")
            if upos >= 0:
                #found at sign: username@host
                username = host[:upos]
                host = host[upos + 1:]
                ppos = username.find(":")
                if ppos >= 0:
                    #found separator: username:password@host
                    password = username[ppos + 1:]
                    username = username[:ppos]
            if self.config.ssh_port and self.config.ssh_port != 22:
                params["ssh-port"] = self.config.ssh_port
            ssh_cmd = parse_ssh_string(self.config.ssh)
            ssh_cmd_0 = ssh_cmd[0].strip().lower()
            self.is_putty = ssh_cmd_0.endswith("plink") or ssh_cmd_0.endswith(
                "plink.exe")
            self.is_paramiko = ssh_cmd_0 == "paramiko"
            full_ssh = ssh_cmd[:]
            full_ssh += add_ssh_args(username, password, host,
                                     self.config.ssh_port, None, self.is_putty,
                                     self.is_paramiko)
            if username:
                params["username"] = username
            if self.nostrict_host_check.get_active():
                full_ssh += ["-o", "StrictHostKeyChecking=no"]
            if params["type"] == "ssh -> ssh":
                params["type"] = "ssh"
                params["proxy_host"] = self.config.proxy_host
                params["proxy_port"] = self.config.proxy_port
                params["proxy_username"] = self.config.proxy_username
                params["proxy_password"] = self.config.proxy_password
                full_ssh += add_ssh_proxy_args(self.config.proxy_username,
                                               self.config.proxy_password,
                                               self.config.proxy_host,
                                               self.config.proxy_port,
                                               self.config.proxy_key, ssh_cmd,
                                               self.is_putty, self.is_paramiko)
            params["host"] = host
            params["local"] = is_local(self.config.host)
            params["full_ssh"] = full_ssh
            params["password"] = password
            params["display_name"] = "ssh:%s:%s" % (self.config.host,
                                                    self.config.port)
        elif self.config.mode == "unix-domain":
            params["display"] = ":%s" % self.config.port
            params["display_name"] = "unix-domain:%s" % self.config.port
        else:
            assert self.config.mode in (
                "tcp", "ssl", "ws",
                "wss"), "invalid / unsupported mode %s" % self.config.mode
            params["host"] = self.config.host
            params["local"] = is_local(self.config.host)
            params["port"] = int(self.config.port)
            params["display_name"] = "%s:%s:%s" % (
                self.config.mode, self.config.host, self.config.port)
            if self.config.mode in (
                    "ssl", "wss") and self.nostrict_host_check.get_active():
                params["strict-host-check"] = False

        #print("connect_to(%s)" % params)
        #UGLY warning: the username may have been updated during display parsing,
        #or the config file may contain a username which is different from the default one
        #which is used for initializing the client during init,
        #so update the client now:
        def raise_exception(*args):
            raise Exception(*args)

        configure_env(self.config.env)
        configure_logging(self.config, "attach")
        configure_network(self.config)
        self.client = make_client(raise_exception, self.config)
        self.client.show_progress(30, "client configuration")
        self.client.init(self.config)
        self.client.show_progress(40, "loading user interface")
        self.client.init_ui(self.config)
        self.client.username = username

        def handshake_complete(*_args):
            self.client.show_progress(100, "connection established")

        self.client.after_handshake(handshake_complete)
        self.set_info_text("Connecting...")
        start_thread(self.do_connect_builtin,
                     "connect",
                     daemon=True,
                     args=(params, ))