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,))
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, ))
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, ))
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 sys.platform.startswith("win"): 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,))