Skip to content

Commit

Permalink
#3623 show adapter type
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Jan 29, 2024
1 parent 72fedb8 commit 99d2c8d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
9 changes: 6 additions & 3 deletions xpra/net/device_info.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file is part of Xpra.
# Copyright (C) 2010-2023 Antoine Martin <antoine@xpra.org>
# Copyright (C) 2010-2024 Antoine Martin <antoine@xpra.org>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.
# pylint: disable-msg=E1101
Expand All @@ -23,7 +23,7 @@
ADSL_LIMIT: int = envint("XPRA_WIFI_LIMIT", 1000 * 1000)


def get_NM_adapter_type(device_name) -> str:
def get_NM_adapter_type(device_name, ignore_inactive=True) -> str:
if not any(sys.modules.get(f"gi.repository.{mod}") for mod in ("GLib", "Gtk")):
log("get_NM_adapter_type() no main loop")
return ""
Expand Down Expand Up @@ -53,10 +53,13 @@ def get_NM_adapter_type(device_name) -> str:
log(f"NM device {device_name!r}: {nmdevice.get_vendor()} {nmdevice.get_product()}")
nmstate = nmdevice.get_state()
log(f"NM state({device_name})={nmstate}")
if nmdevice.get_state() != NM.DeviceState.ACTIVATED:
inactive = nmdevice.get_state() != NM.DeviceState.ACTIVATED
if ignore_inactive and inactive:
log.info(f"ignoring {device_name}: {nmstate.value_name}")
return ""
adapter_type = nmdevice.get_device_type().value_name
if adapter_type.startswith("NM_DEVICE_TYPE_"):
adapter_type = adapter_type[len("NM_DEVICE_TYPE_"):]
log(f"NM device-type({device_name})={adapter_type}")
return adapter_type

Expand Down
12 changes: 8 additions & 4 deletions xpra/net/net_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ def main(): # pragma: no cover
from xpra.os_util import POSIX
from xpra.util.str_fn import print_nested_dict
from xpra.util.str_fn import csv
from xpra.net.device_info import get_NM_adapter_type
from xpra.platform import program_context
from xpra.platform.netdev_query import get_interface_info
from xpra.log import enable_color, add_debug_category, enable_debug_for
Expand Down Expand Up @@ -456,10 +457,12 @@ def main(): # pragma: no cover
print(" %s" % info)
finally:
sock.close()
if not POSIX:
info = get_interface_info(0, iface)
if info:
print(f" {info}")
info = get_interface_info(0, iface)
dtype = get_NM_adapter_type(iface, ignore_inactive=False)
if dtype:
info["type"] = dtype
if info:
print(f" {info}")

from xpra.util.str_fn import bytestostr

Expand All @@ -483,6 +486,7 @@ def pver(v):
return v[1:]
return str(v)

print("")
print("Gateways found:")
for gt, idefs in get_gateways().items():
print(f"* {gt}") # ie: "INET"
Expand Down

0 comments on commit 99d2c8d

Please sign in to comment.