diff --git a/tests/unittests/unit/scripts/main_test.py b/tests/unittests/unit/scripts/main_test.py index baa793d5d0..585f4465dc 100755 --- a/tests/unittests/unit/scripts/main_test.py +++ b/tests/unittests/unit/scripts/main_test.py @@ -113,7 +113,7 @@ def fd(d): f(type="invalid", display_name="test") f(type="vsock", display_name="test", vsock=(10, 1000)) fd({"type" : "named-pipe", "display_name" : "test", "named-pipe" : "TEST-INVALID"}) - f(type="unix-domain", display_name=":100000", display="100000") + f(type="socket", display_name=":100000", display="100000") for socktype in ("tcp", "ssl", "ws", "wss", ): f(type=socktype, display_name="test", host="localhost", port=100000) for paramiko in (True, False): diff --git a/tests/unittests/unit/scripts/parse_display_name_test.py b/tests/unittests/unit/scripts/parse_display_name_test.py index daa132b3ea..4183dd056b 100755 --- a/tests/unittests/unit/scripts/parse_display_name_test.py +++ b/tests/unittests/unit/scripts/parse_display_name_test.py @@ -76,7 +76,7 @@ def e(s): raise Exception(f"parse_display_name should fail for {s}") if POSIX: e("ZZZZZZ") - t("10", {"display_name" : ":10", "local" : True, "type" : "unix-domain"}) + t("10", {"display_name" : ":10", "local" : True, "type" : "socket"}) t(socket_dir+"/thesocket", {"display_name" : "socket://"+socket_dir+"/thesocket"}) t("socket:"+socket_dir+"/thesocket", {"display_name" : "socket:"+socket_dir+"/thesocket"}) e("tcp://host:NOTANUMBER/") diff --git a/tests/unittests/unit/server/mixins/fileprint_test.py b/tests/unittests/unit/server/mixins/fileprint_test.py index c91fc3ea52..029ffb548a 100755 --- a/tests/unittests/unit/server/mixins/fileprint_test.py +++ b/tests/unittests/unit/server/mixins/fileprint_test.py @@ -19,7 +19,7 @@ def create_test_sockets(self): return () return [ #socktype, socket, sockpath, cleanup_socket - ("unix-domain", None, "/fake/path", None) + ("socket", None, "/fake/path", None) ] def test_fileprint(self): diff --git a/xpra/client/gtk_base/client_launcher.py b/xpra/client/gtk_base/client_launcher.py index 75d0bb7c80..46778e5f29 100755 --- a/xpra/client/gtk_base/client_launcher.py +++ b/xpra/client/gtk_base/client_launcher.py @@ -717,7 +717,7 @@ def connect_builtin(self): 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"] = f":{self.config.port}" params["display_as_args"] = [params["display"]] else: params["display"] = "auto" @@ -761,7 +761,10 @@ def connect_builtin(self): params["full_ssh"] = full_ssh params["password"] = password params["display_name"] = f"ssh://{self.config.host}:{self.config.port}" - elif self.config.mode=="unix-domain": + elif self.config.mode=="display": + params["display"] = f":{self.config.port}" + params["display_name"] = f":{self.config.port}" + elif self.config.mode in ("socket", "unix-domain"): params["display"] = f":{self.config.port}" params["display_name"] = f"unix-domain:{self.config.port}" else: diff --git a/xpra/net/bytestreams.py b/xpra/net/bytestreams.py index cddcd6aae4..7b3f0bf58f 100644 --- a/xpra/net/bytestreams.py +++ b/xpra/net/bytestreams.py @@ -648,7 +648,7 @@ def log_new_connection(conn, socket_info=""): log.info(" from '%s'", pretty_socket(frominfo)) if socket_info: log.info(" on '%s'", pretty_socket(socket_info)) - elif socktype=="unix-domain": + elif socktype=="socket": frominfo = sockname log.info(" on '%s'", frominfo) else: diff --git a/xpra/net/common.py b/xpra/net/common.py index c1c22619eb..cdd0013555 100644 --- a/xpra/net/common.py +++ b/xpra/net/common.py @@ -16,7 +16,7 @@ class ConnectionClosedException(Exception): MAX_PACKET_SIZE = envint("XPRA_MAX_PACKET_SIZE", 16*1024*1024) FLUSH_HEADER = envbool("XPRA_FLUSH_HEADER", True) -SOCKET_TYPES = ("tcp", "ws", "wss", "ssl", "ssh", "rfb", "vsock", "socket", "unix-domain", "named-pipe") +SOCKET_TYPES = ("tcp", "ws", "wss", "ssl", "ssh", "rfb", "vsock", "socket", "named-pipe") IP_SOCKTYPES = ("tcp", "ssl", "ws", "wss", "ssh") TCP_SOCKTYPES = ("tcp", "ssl", "ws", "wss", "ssh") diff --git a/xpra/net/socket_util.py b/xpra/net/socket_util.py index 1782baa901..63be0a3259 100644 --- a/xpra/net/socket_util.py +++ b/xpra/net/socket_util.py @@ -34,6 +34,7 @@ PEEK_TIMEOUT = envint("XPRA_PEEK_TIMEOUT", 1) PEEK_TIMEOUT_MS = envint("XPRA_PEEK_TIMEOUT_MS", PEEK_TIMEOUT*1000) UNIXDOMAIN_PEEK_TIMEOUT_MS = envint("XPRA_UNIX_DOMAIN_PEEK_TIMEOUT_MS", 100) +SOCKET_PEEK_TIMEOUT_MS = envint("XPRA_SOCKET_PEEK_TIMEOUT_MS", UNIXDOMAIN_PEEK_TIMEOUT_MS) PEEK_SIZE = envint("XPRA_PEEK_SIZE", 8192) SOCKET_DIR_MODE = num = int(os.environ.get("XPRA_SOCKET_DIR_MODE", "775"), 8) @@ -643,7 +644,7 @@ def timeout_probe(sockpath): log.warn("Warning: some of the sockets are in an unknown state:") for sockpath in unknown: log.warn(" %s", sockpath) - t = start_thread(timeout_probe, "probe-%s" % sockpath, daemon=True, args=(sockpath,)) + t = start_thread(timeout_probe, f"probe-{sockpath}", daemon=True, args=(sockpath,)) threads.append(t) log.warn(" please wait as we allow the socket probing to timeout") #wait for all the threads to do their job: @@ -683,7 +684,7 @@ def timeout_probe(sockpath): try: sock, cleanup_socket = create_unix_domain_socket(sockpath, sperms) log.info(f"created unix domain socket {sockpath!r}") - defs[("unix-domain", sock, sockpath, cleanup_socket)] = options + defs[("socket", sock, sockpath, cleanup_socket)] = options except Exception as e: handle_socket_error(sockpath, sperms, e) del e diff --git a/xpra/platform/xposix/sd_listen.pyx b/xpra/platform/xposix/sd_listen.pyx index 3887894297..2e35d1fa8d 100644 --- a/xpra/platform/xposix/sd_listen.pyx +++ b/xpra/platform/xposix/sd_listen.pyx @@ -70,7 +70,7 @@ def get_sd_listen_socket(int fd): if sd_is_socket_unix(fd, socket.SOCK_STREAM, 1, NULL, 0)>0: sock = fromfd(socket.AF_UNIX, socket.SOCK_STREAM) sockpath = sock.getsockname() - return "unix-domain", sock, sockpath + return "socket", sock, sockpath for family in (socket.AF_INET, socket.AF_INET6): if sd_is_socket_inet(fd, family, socket.SOCK_STREAM, 1, 0)>0: sock = fromfd(family, socket.SOCK_STREAM) diff --git a/xpra/scripts/main.py b/xpra/scripts/main.py index ebe69661eb..e43de0c316 100755 --- a/xpra/scripts/main.py +++ b/xpra/scripts/main.py @@ -826,7 +826,7 @@ def do_pick_display(dotxpra, error_cb, opts, extra_args, cmdline=()): dir_servers = dotxpra.socket_details(matching_state=DotXpra.LIVE) try: sockdir, display, sockpath = single_display_match(dir_servers, error_cb) - except: + except Exception: if getuid()==0 and opts.system_proxy_socket: display = ":PROXY" sockdir = os.path.dirname(opts.system_proxy_socket) @@ -845,14 +845,14 @@ def do_pick_display(dotxpra, error_cb, opts, extra_args, cmdline=()): }) else: desc.update({ - "type" : "unix-domain", + "type" : "socket", "socket_dir" : sockdir, "socket_path" : sockpath, }) return desc if len(extra_args) == 1: return parse_display_name(error_cb, opts, extra_args[0], cmdline, find_session_by_name=find_session_by_name) - error_cb("too many arguments (%i): %s" % (len(extra_args), extra_args)) + error_cb(f"too many arguments ({len(extra_args)}): {extra_args}") return None def single_display_match(dir_servers, error_cb, nomatch="cannot find any live servers to connect to"): @@ -996,7 +996,7 @@ def connect_to(display_desc, opts=None, debug_cb=None, ssh_fail_cb=None): conn.socktype_wrapped = "ssh" return conn - if dtype == "unix-domain": + if dtype == "socket": if not hasattr(socket, "AF_UNIX"): # pragma: no cover raise InitExit(EXIT_UNSUPPORTED, "unix domain sockets are not available on this operating system") def sockpathfail_cb(msg): diff --git a/xpra/scripts/parsing.py b/xpra/scripts/parsing.py index c5bc7830f5..7e4e915bff 100755 --- a/xpra/scripts/parsing.py +++ b/xpra/scripts/parsing.py @@ -522,7 +522,7 @@ def add_query(): add_query() display = parsed.path.lstrip(":") desc.update({ - "type" : "unix-domain", + "type" : "socket", "local" : True, "display" : display, "socket_dirs" : opts.socket_dirs, @@ -585,7 +585,7 @@ def add_query(): add_credentials() add_query() desc.update({ - "type" : "unix-domain", + "type" : "socket", "local" : True, "socket_dir" : os.path.basename(parsed.path), "socket_dirs" : opts.socket_dirs, diff --git a/xpra/scripts/server.py b/xpra/scripts/server.py index 178cc43342..8f044c3560 100644 --- a/xpra/scripts/server.py +++ b/xpra/scripts/server.py @@ -1401,7 +1401,7 @@ def init_local_sockets(): sockets.update(local_sockets) if POSIX and (starting or upgrading or starting_desktop): #all unix domain sockets: - ud_paths = [sockpath for stype, _, sockpath, _ in local_sockets if stype=="unix-domain"] + ud_paths = [sockpath for stype, _, sockpath, _ in local_sockets if stype=="socket"] forward_xdg_open = bool(opts.forward_xdg_open) or ( opts.forward_xdg_open is None and mode.find("desktop")<0 and mode.find("monitor")<0) if ud_paths: diff --git a/xpra/server/mixins/fileprint_server.py b/xpra/server/mixins/fileprint_server.py index ba4c0c9623..a037a8d0e3 100644 --- a/xpra/server/mixins/fileprint_server.py +++ b/xpra/server/mixins/fileprint_server.py @@ -49,7 +49,7 @@ def threaded_setup(self): def init_sockets(self, sockets): #verify we have a local socket for printing: - unixsockets = [info for socktype, _, info, _ in sockets if socktype=="unix-domain"] + unixsockets = [info for socktype, _, info, _ in sockets if socktype=="socket"] printlog("local unix domain sockets we can use for printing: %s", unixsockets) if not unixsockets and self.file_transfer.printing: if not WIN32: @@ -116,7 +116,7 @@ def init_printing(self): printlog.error("Error: failed to set lpadmin and lpinfo commands", exc_info=True) printing = False #verify that we can talk to the socket: - auth_class = self.auth_classes.get("unix-domain") + auth_class = self.auth_classes.get("socket") if printing and auth_class: try: #this should be the name of the auth module: @@ -236,7 +236,7 @@ def _process_printers(self, proto, packet): if ss is None: return printers = packet[1] - auth_class = self.auth_classes.get("unix-domain") + auth_class = self.auth_classes.get("socket") ss.set_printers(printers, self.password_file, auth_class, self.encryption, self.encryption_keyfile) diff --git a/xpra/server/proxy/proxy_instance_process.py b/xpra/server/proxy/proxy_instance_process.py index b4f64abca8..af973d07f0 100644 --- a/xpra/server/proxy/proxy_instance_process.py +++ b/xpra/server/proxy/proxy_instance_process.py @@ -262,7 +262,7 @@ def new_control_connection(self, sock, address): target = peername or sockname #sock.settimeout(0) log("new_control_connection() sock=%s, sockname=%s, address=%s, peername=%s", sock, sockname, address, peername) - sc = SocketConnection(sock, sockname, address, target, "unix-domain") + sc = SocketConnection(sock, sockname, address, target, "socket") log.info("New proxy instance control connection received:") log.info(" '%s'", sc) protocol = Protocol(self, sc, self.process_control_packet) diff --git a/xpra/server/proxy/proxy_server.py b/xpra/server/proxy/proxy_server.py index 948de2e8fe..3e80ef1c23 100644 --- a/xpra/server/proxy/proxy_server.py +++ b/xpra/server/proxy/proxy_server.py @@ -40,8 +40,8 @@ PROXY_WS_TIMEOUT = envfloat("XPRA_PROXY_WS_TIMEOUT", "1.0") assert PROXY_SOCKET_TIMEOUT>0, "invalid proxy socket timeout" CAN_STOP_PROXY = envbool("XPRA_CAN_STOP_PROXY", getuid()!=0 or WIN32) -STOP_PROXY_SOCKET_TYPES = os.environ.get("XPRA_STOP_PROXY_SOCKET_TYPES", "unix-domain,named-pipe").split(",") -STOP_PROXY_AUTH_SOCKET_TYPES = os.environ.get("XPRA_STOP_PROXY_AUTH_SOCKET_TYPES", "unix-domain").split(",") +STOP_PROXY_SOCKET_TYPES = os.environ.get("XPRA_STOP_PROXY_SOCKET_TYPES", "socket,named-pipe").split(",") +STOP_PROXY_AUTH_SOCKET_TYPES = os.environ.get("XPRA_STOP_PROXY_AUTH_SOCKET_TYPES", "socket").split(",") #something (a thread lock?) doesn't allow us to use multiprocessing on MS Windows: PROXY_INSTANCE_THREADED = envbool("XPRA_PROXY_INSTANCE_THREADED", WIN32) PROXY_CLEANUP_GRACE_PERIOD = envfloat("XPRA_PROXY_CLEANUP_GRACE_PERIOD", "0.5") diff --git a/xpra/server/server_core.py b/xpra/server/server_core.py index b1f41ae14f..14d26c4301 100644 --- a/xpra/server/server_core.py +++ b/xpra/server/server_core.py @@ -28,7 +28,7 @@ from xpra.net.common import may_log_packet, SOCKET_TYPES, MAX_PACKET_SIZE from xpra.net.socket_util import ( hosts, mdns_publish, peek_connection, - PEEK_TIMEOUT_MS, UNIXDOMAIN_PEEK_TIMEOUT_MS, + PEEK_TIMEOUT_MS, SOCKET_PEEK_TIMEOUT_MS, add_listen_socket, accept_connection, guess_packet_type, ssl_wrap_socket, ) @@ -678,11 +678,10 @@ def init_html_proxy(self, opts): ###################################################################### # authentication: def init_auth(self, opts): - auth = self.get_auth_modules("local-auth", opts.auth or []) for x in SOCKET_TYPES: - if x in ("socket", "unix-domain", "named-pipe"): + if x in ("socket", "named-pipe"): #use local-auth for these: - opts_value = auth + opts_value = opts.auth else: opts_value = getattr(opts, f"{x}_auth") self.auth_classes[x] = self.get_auth_modules(x, opts_value) @@ -815,7 +814,7 @@ def mdns_publish(self): mdnslog("mdns_publish() info=%s, socktypes(%s)=%s", info, socktype, socktypes) for st in socktypes: recs = mdns_recs.setdefault(st, []) - if socktype=="unix-domain": + if socktype=="socket": assert st=="ssh" host = "*" iport = get_ssh_port() @@ -863,7 +862,7 @@ def get_mdns_socktypes(self, socktype): elif socktype=="ws": if ssl: socktypes.append("wss") - elif socktype=="unix-domain": + elif socktype=="socket": if ssh_access: socktypes = ["ssh"] return socktypes @@ -914,7 +913,7 @@ def start_listen_sockets(self): self.socket_info[sock] = info self.socket_options[sock] = options self.idle_add(self.add_listen_socket, socktype, sock, options) - if socktype=="unix-domain" and info: + if socktype=="socket" and info: try: p = os.path.abspath(info) self.unix_socket_paths.append(p) @@ -1017,13 +1016,13 @@ def _new_connection(self, socktype, listener, handle=0): if conn is None: return True #limit number of concurrent network connections: - if socktype not in ("unix-domain", ) and len(self._potential_protocols)>=self._max_connections: + if socktype!="socket" and len(self._potential_protocols)>=self._max_connections: netlog.error("Error: too many connections (%i)", len(self._potential_protocols)) netlog.error(" ignoring new one: %s", conn.endpoint) conn.close() return True #from here on, we run in a thread, so we can poll (peek does) - start_thread(self.handle_new_connection, "new-%s-connection" % socktype, True, + start_thread(self.handle_new_connection, f"new-{socktype}-connection", True, args=(conn, socket_info, socket_options)) return True @@ -1087,8 +1086,8 @@ def handle_new_connection(self, conn, socket_info, socket_options): #rfb does not send any data, waits for a server packet #so don't bother waiting for something that should never come: timeout = 0 - elif socktype=="unix-domain": - timeout = UNIXDOMAIN_PEEK_TIMEOUT_MS + elif socktype=="socket": + timeout = SOCKET_PEEK_TIMEOUT_MS peek_data = b"" if timeout>0: peek_data = peek_connection(conn, timeout) @@ -1189,7 +1188,7 @@ def ssl_wrap(): return peek_data, line1, packet_type = b"", b"", None - if socktype in ("tcp", "unix-domain", "named-pipe") and peek_data: + if socktype in ("tcp", "socket", "named-pipe") and peek_data: #see if the packet data is actually xpra or something else #that we need to handle via an ssl wrapper or the websocket adapter: try: @@ -1210,7 +1209,7 @@ def ssl_wrap(): #get the new socket object as we may have wrapped it with ssl: sock = getattr(conn, "_socket", sock) pre_read = None - if socktype=="unix-domain" and not peek_data: + if socktype=="socket" and not peek_data: #try to read from this socket, #so short lived probes don't go through the whole protocol instantation try: