Beispiel #1
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":
            remote_xpra = self.config.remote_xpra.split()
            if self.config.socket_dir:
                remote_xpra.append("--socket-dir=%s" % self.config.socket_dir)
            params["remote_xpra"] = 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 = shlex.split(self.config.ssh)
            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 username:
                params["username"] = username
                full_ssh += ["-l", username]
            full_ssh += ["-T", host]
            if str(self.config.ssh_port) != "22":
                if sys.platform.startswith("win"):
                    full_ssh += ["-P", str(self.config.ssh_port)]
                else:
                    full_ssh += ["-p", str(self.config.ssh_port)]
            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:
            #tcp:
            params["host"] = self.config.host
            params["port"] = int(self.config.port)
            params["display_name"] = "tcp:%s:%s" % (self.config.host,
                                                    self.config.port)

        #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:
        self.client.username = username
        self.set_info_text("Connecting...")
        thread.start_new_thread(self.do_connect_builtin, (params, ))
Beispiel #2
0
 def start_UI_thread_polling(self):
     log("start_UI_thread_polling()")
     self.UI_blocked_sent = False
     def UI_thread_wakeup(*args):
         log("UI_thread_wakeup()")
         self.last_UI_thread_time = time.time()
         #UI thread was blocked?
         if self.UI_blocked_sent:
             log.info("UI thread is running again, resuming")
             self.send("resume", True, self._id_to_window.keys())
             self.UI_blocked_sent = False
         return self.exit_code is None
     UI_thread_wakeup()
     gobject.timeout_add(1000, UI_thread_wakeup)
     def poll_UI_loop(*args):
         log("poll_UI_loop() running")
         while self.exit_code is None:
             delta = time.time()-self.last_UI_thread_time
             log("poll_UI_loop() last_UI_thread_time was %.1f seconds ago, UI_blocked_sent=%s", delta, self.UI_blocked_sent)
             if delta>2.0:
                 #UI thread is (still?) blocked:
                 if not self.UI_blocked_sent:
                     log.info("UI thread is blocked, pausing server")
                     self.send("suspend", True, self._id_to_window.keys())
                     self.UI_blocked_sent = True
             time.sleep(1.0)
     thread.start_new_thread(poll_UI_loop, ())
Beispiel #3
0
    def connect_builtin(self):
        #cooked vars used by connect_to
        params = {"type": self.config.mode}
        if self.config.mode == "ssh":
            remote_xpra = self.config.remote_xpra.split()
            if self.config.socket_dir:
                remote_xpra.append("--socket-dir=%s" % self.config.socket_dir)
            params["remote_xpra"] = 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 = shlex.split(self.config.ssh)
            password = self.config.password
            username = self.config.username
            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 username:
                params["username"] = username
                full_ssh += ["-l", username]
            full_ssh += ["-T", host]
            if sys.platform.startswith("win"):
                #putty needs those:
                full_ssh.append("-ssh")
                full_ssh.append("-agent")
            if self.config.ssh_port != "22":
                if sys.platform.startswith("win"):
                    full_ssh += ["-P", self.config.ssh_port]
                else:
                    full_ssh += ["-p", self.config.ssh_port]
            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:
            #tcp:
            params["host"] = self.config.host
            params["port"] = int(self.config.port)
            params["display_name"] = "tcp:%s:%s" % (self.config.host,
                                                    self.config.port)

        #print("connect_to(%s)" % params)
        self.set_info_text("Connecting...")
        thread.start_new_thread(self.do_connect_builtin, (params, ))
Beispiel #4
0
 def check_for_end(*_args):
     qtime = ss.queue.get_property("current-level-time") // MS_TO_NS
     if qtime <= 0:
         log.info("underrun (end of stream)")
         thread.start_new_thread(ss.stop, ())
         glib.timeout_add(500, glib_mainloop.quit)
         return False
     return True
Beispiel #5
0
 def check_for_end(*args):
     qtime = int(ss.queue.get_property("current-level-time")/MS_TO_NS)
     if qtime<=0:
         log.info("underrun (end of stream)")
         thread.start_new_thread(ss.stop, ())
         gobject.timeout_add(500, gobject_mainloop.quit)
         return False
     return True
Beispiel #6
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":
            remote_xpra = self.config.remote_xpra.split()
            if self.config.socket_dir:
                remote_xpra.append("--socket-dir=%s" % self.config.socket_dir)
            params["remote_xpra"] = 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 = shlex.split(self.config.ssh)
            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 username:
                params["username"] = username
                full_ssh += ["-l", username]
            full_ssh += ["-T", host]
            if str(self.config.ssh_port)!="22":
                if sys.platform.startswith("win"):
                    full_ssh += ["-P", str(self.config.ssh_port)]
                else:
                    full_ssh += ["-p", str(self.config.ssh_port)]
            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:
            #tcp:
            params["host"] = self.config.host
            params["port"] = int(self.config.port)
            params["display_name"] = "tcp:%s:%s" % (self.config.host, self.config.port)

        #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:
        self.client.username = username
        self.set_info_text("Connecting...")
        thread.start_new_thread(self.do_connect_builtin, (params,))
Beispiel #7
0
    def connect_builtin(self):
        #cooked vars used by connect_to
        params = {"type"    : self.config.mode}
        if self.config.mode=="ssh":
            remote_xpra = self.config.remote_xpra.split()
            if self.config.socket_dir:
                remote_xpra.append("--socket-dir=%s" % self.config.socket_dir)
            params["remote_xpra"] = 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 = shlex.split(self.config.ssh)
            password = self.config.password
            username = self.config.username
            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 username:
                params["username"] = username
                full_ssh += ["-l", username]
            full_ssh += ["-T", host]
            if sys.platform.startswith("win"):
                #putty needs those:
                full_ssh.append("-ssh")
                full_ssh.append("-agent")
            if self.config.ssh_port!="22":
                if sys.platform.startswith("win"):
                    full_ssh += ["-P", self.config.ssh_port]
                else:
                    full_ssh += ["-p", self.config.ssh_port]
            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:
            #tcp:
            params["host"] = self.config.host
            params["port"] = int(self.config.port)
            params["display_name"] = "tcp:%s:%s" % (self.config.host, self.config.port)

        #print("connect_to(%s)" % params)
        self.set_info_text("Connecting...")
        thread.start_new_thread(self.do_connect_builtin, (params,))
Beispiel #8
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 = shlex.split(self.config.ssh)
            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 username:
                params["username"] = username
                full_ssh += ["-l", username]
            full_ssh += ["-T", host]
            if self.nostrict_host_check.get_active():
                full_ssh += ["-o", "StrictHostKeyChecking=no"]
            if str(self.config.ssh_port)!="22":
                if WIN32:
                    full_ssh += ["-P", str(self.config.ssh_port)]
                else:
                    full_ssh += ["-p", str(self.config.ssh_port)]
            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"), "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:
        self.client.username = username
        self.set_info_text("Connecting...")
        thread.start_new_thread(self.do_connect_builtin, (params,))
Beispiel #9
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, ))
Beispiel #10
0
 def setup(self):
     log("starting component init")
     for c in SERVER_BASES:
         c.setup(self)
     thread.start_new_thread(self.threaded_init, ())
 def cleanup(self):
     nf = self.notifications_forwarder
     if nf:
         self.notifications_forwarder = None
         thread.start_new_thread(nf.release, ())  #@UndefinedVariable
Beispiel #12
0
 def setup(self):
     log("starting component init")
     for c in ServerBase.__bases__:
         c.setup(self)
     thread.start_new_thread(self.threaded_init, ())
Beispiel #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 = shlex.split(self.config.ssh)
            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 username:
                params["username"] = username
                full_ssh += ["-l", username]
            full_ssh += ["-T", host]
            if self.nostrict_host_check.get_active():
                full_ssh += ["-o", "StrictHostKeyChecking=no"]
            if str(self.config.ssh_port) != "22":
                if WIN32:
                    full_ssh += ["-P", str(self.config.ssh_port)]
                else:
                    full_ssh += ["-p", str(self.config.ssh_port)]
            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"), "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:
        self.client.username = username
        self.set_info_text("Connecting...")
        thread.start_new_thread(self.do_connect_builtin, (params,))