Skip to content

Commit

Permalink
#4082 show 'endpoint' in client info
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Dec 25, 2023
1 parent a99cd85 commit 61d2004
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 37 deletions.
35 changes: 32 additions & 3 deletions xpra/client/base/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from typing import Any
from collections.abc import Callable

from xpra.log import Logger
from xpra.scripts.config import InitExit
from xpra.common import (
SPLASH_EXIT_DELAY, FULL_INFO, LOG_HELLO,
Expand All @@ -40,9 +39,11 @@
DEFAULT_MODE, DEFAULT_KEYSIZE, DEFAULT_KEY_HASH, DEFAULT_KEY_STRETCH,
)
from xpra.util.version import get_version_info, vparts, XPRA_VERSION
from xpra.platform.info import get_name, get_username
from xpra.net.net_util import get_info as get_net_info
from xpra.log import Logger, get_info as get_log_info
from xpra.platform.info import get_name, get_username, get_sys_info
from xpra.os_util import get_machine_id, get_user_uuid, force_quit, gi_import, BITS
from xpra.util.system import SIGNAMES, register_SIGUSR_signals
from xpra.util.system import SIGNAMES, register_SIGUSR_signals, get_frame_info, get_env_info, get_sysconfig_info
from xpra.util.io import filedata_nocrlf, stderr_print, use_gui_prompt
from xpra.util.pysystem import dump_all_frames, detect_leaks
from xpra.util.types import typedict
Expand Down Expand Up @@ -71,6 +72,7 @@
SPLASH_LOG = envbool("XPRA_SPLASH_LOG", False)
LOG_DISCONNECT = envbool("XPRA_LOG_DISCONNECT", True)
SKIP_UI = envbool("XPRA_SKIP_UI", False)
SYSCONFIG = envbool("XPRA_SYSCONFIG", FULL_INFO>1)

ALL_CHALLENGE_HANDLERS = os.environ.get("XPRA_ALL_CHALLENGE_HANDLERS",
"uri,file,env,kerberos,gss,u2f,prompt,prompt,prompt,prompt").split(",")
Expand Down Expand Up @@ -330,6 +332,22 @@ def client_type(self) -> str:
#overridden in subclasses!
return "Python"

def get_info(self) -> dict[str, Any]:
info : dict[str, Any] = {}
if FULL_INFO > 0:
info |= {
"pid" : os.getpid(),
"sys" : get_sys_info(),
"network" : get_net_info(),
"logging" : get_log_info(),
"threads" : get_frame_info(),
"env" : get_env_info(),
"endpoint" : self.get_connection_endpoint(),
}
if SYSCONFIG:
info["sysconfig"] = get_sysconfig_info()
return info

def get_scheduler(self):
raise NotImplementedError()

Expand Down Expand Up @@ -659,6 +677,17 @@ def start_protocol(self) -> None:
if self._protocol:
self._protocol.start()

def get_connection_endpoint(self) -> str:
p = self._protocol
if not p:
return ""
conn = getattr(p, "_conn", None)
if not conn:
return ""
from xpra.net.bytestreams import pretty_socket
cinfo = conn.get_info()
return pretty_socket(cinfo.get("endpoint", conn.target)).split("?")[0]

def quit(self, exit_code:int|ExitCode=0) -> None:
raise NotImplementedError()

Expand Down
4 changes: 1 addition & 3 deletions xpra/client/gtk3/client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
from xpra.util.types import typedict
from xpra.util.str_fn import csv, ellipsizer, repr_ellipsized, pver, strtobytes, bytestostr, hexstr, memoryview_to_bytes
from xpra.util.env import envint, envbool, osexpand, first_time, IgnoreWarningsContext, ignorewarnings
from xpra.os_util import (
gi_import,
WIN32, OSX, POSIX, )
from xpra.os_util import gi_import, WIN32, OSX, POSIX
from xpra.util.system import is_Wayland, is_gnome
from xpra.util.io import load_binary_file
from xpra.net.common import PacketType
Expand Down
25 changes: 6 additions & 19 deletions xpra/client/gui/ui_client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@
from xpra.util.version import full_version_str
from xpra.net import compression, packet_encoding
from xpra.net.common import PacketType
from xpra.net.net_util import get_info as get_net_info
from xpra.util.child_reaper import reaper_cleanup
from xpra.platform.info import get_sys_info
from xpra.os_util import (
POSIX, WIN32, OSX, )
from xpra.util.system import is_Wayland, get_frame_info, get_info_env, get_sysconfig_info, platform_name
from xpra.os_util import POSIX, WIN32, OSX
from xpra.util.system import is_Wayland, platform_name
from xpra.util.types import typedict, merge_dicts
from xpra.util.screen import log_screen_sizes
from xpra.util.str_fn import std, csv, ellipsizer, repr_ellipsized, bytestostr
Expand All @@ -32,7 +29,7 @@
from xpra.exit_codes import ExitCode, ExitValue
from xpra.util.version import get_platform_info
from xpra.client.gui import features
from xpra.log import Logger, get_info as get_log_info
from xpra.log import Logger


CLIENT_BASES : list[type] = [XpraClientBase]
Expand Down Expand Up @@ -82,7 +79,6 @@

NOTIFICATION_EXIT_DELAY = envint("XPRA_NOTIFICATION_EXIT_DELAY", 2)
MOUSE_DELAY_AUTO = envbool("XPRA_MOUSE_DELAY_AUTO", True)
SYSCONFIG = envbool("XPRA_SYSCONFIG", FULL_INFO>1)
DELAY_KEYBOARD_DATA = envbool("XPRA_DELAY_KEYBOARD_DATA", True)


Expand Down Expand Up @@ -285,19 +281,10 @@ def signal_cleanup(self) -> None:
log("UIXpraClient.signal_cleanup() done")


def get_info(self) -> dict[str,Any]:
info : dict[str,Any] = {}
def get_info(self) -> dict[str, Any]:
info : dict[str, Any] = super().get_info()
if FULL_INFO>0:
info |= {
"pid" : os.getpid(),
"sys" : get_sys_info(),
"network" : get_net_info(),
"logging" : get_log_info(),
"threads" : get_frame_info(),
"env" : get_info_env(),
}
if SYSCONFIG:
info["sysconfig"] = get_sysconfig_info()
info["session-name"] = self.session_name
for c in CLIENT_BASES:
with log.trap_error("Error collection information from %s", c):
i = c.get_info(self)
Expand Down
13 changes: 4 additions & 9 deletions xpra/client/mixins/tray.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,11 @@ def get_tray_title(self) -> str:
t : list[str] = []
if self.session_name or self.server_session_name:
t.append(self.session_name or self.server_session_name)
p = self._protocol
if p:
conn = getattr(p, "_conn", None)
if conn:
from xpra.net.bytestreams import pretty_socket
cinfo = conn.get_info()
endpoint = pretty_socket(cinfo.get("endpoint", conn.target)).split("?")[0]
t.append(endpoint)
ce = self.get_connection_endpoint()
if ce:
t.append(ce)
if not t:
t.insert(0, "Xpra")
v = "\n".join(str(x) for x in t)
v = "\n".join(str(x) for x in t if x)
log("get_tray_title()=%r (items=%s)", v, tuple(bytestostr(x) for x in t))
return v
4 changes: 2 additions & 2 deletions xpra/server/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
get_hex_uuid,
getuid, POSIX, OSX, WIN32,
)
from xpra.util.system import get_frame_info, get_info_env, get_sysconfig_info, platform_name, register_SIGUSR_signals
from xpra.util.system import get_frame_info, get_env_info, get_sysconfig_info, platform_name, register_SIGUSR_signals
from xpra.util.parsing import parse_encoded_bin_data
from xpra.util.io import load_binary_file, filedata_nocrlf, which
from xpra.server.background_worker import stop_worker, get_worker, add_work_item
Expand Down Expand Up @@ -2516,7 +2516,7 @@ def up(prefix, d):
up("logging", get_log_info())
from xpra.platform.info import get_sys_info
up("sys", get_sys_info())
up("env", get_info_env())
up("env", get_env_info())
if self.child_reaper:
info.update(self.child_reaper.get_info())
if self.dbus_pid:
Expand Down
2 changes: 1 addition & 1 deletion xpra/util/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def get_frame_info(ignore_threads: tuple[Thread, ...] = ()) -> dict[str | int, A
return info


def get_info_env() -> dict[str,str]:
def get_env_info() -> dict[str, str]:
filtered_env = os.environ.copy()
if filtered_env.get('XPRA_PASSWORD'):
filtered_env['XPRA_PASSWORD'] = "*****"
Expand Down

0 comments on commit 61d2004

Please sign in to comment.