Skip to content

Commit

Permalink
ensure we always have a uuid in all servers and publish this value vi…
Browse files Browse the repository at this point in the history
…a mdns so it can be reconciled with xpra info (and fix a bug where the info returned by server subclasses could clobber the info from the base class for the "server" dictionary)

git-svn-id: https://xpra.org/svn/Xpra/trunk@14010 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Oct 6, 2016
1 parent 2e25e8e commit e0e9905
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 23 deletions.
3 changes: 1 addition & 2 deletions src/xpra/scripts/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1337,12 +1337,11 @@ def kill_dbus():

#publish mdns records:
if opts.mdns:
from xpra.os_util import get_hex_uuid
from xpra.platform.info import get_username
mdns_info = {
"display" : display_name,
"username" : get_username(),
"uuid" : get_hex_uuid(),
"uuid" : app.uuid,
}
if opts.session_name:
mdns_info["session"] = opts.session_name
Expand Down
32 changes: 13 additions & 19 deletions src/xpra/server/server_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
from xpra.server.control_command import ArgsControlCommand, ControlError
from xpra.simple_stats import to_std_unit
from xpra.child_reaper import getChildReaper
from xpra.os_util import BytesIOClass, thread, get_hex_uuid, livefds, load_binary_file, pollwait
from xpra.os_util import BytesIOClass, thread, livefds, load_binary_file, pollwait
from xpra.util import typedict, flatten_dict, updict, envbool, log_screen_sizes, engs, repr_ellipsized, csv, iround, \
SERVER_EXIT, SERVER_ERROR, SERVER_SHUTDOWN, DETACH_REQUEST, NEW_CLIENT, DONE, IDLE_TIMEOUT
from xpra.net.bytestreams import set_socket_timeout
from xpra.platform import get_username
from xpra.platform.paths import get_icon_filename
from xpra.child_reaper import reaper_cleanup
from xpra.scripts.config import python_platform, parse_bool_or_int, FALSE_OPTIONS, TRUE_OPTIONS
from xpra.scripts.config import parse_bool_or_int, FALSE_OPTIONS, TRUE_OPTIONS
from xpra.scripts.main import sound_option
from xpra.codecs.loader import PREFERED_ENCODING_ORDER, PROBLEMATIC_ENCODINGS, load_codecs, codec_versions, has_codec, get_codec
from xpra.codecs.video_helper import getVideoHelper, ALL_VIDEO_ENCODER_OPTIONS, ALL_CSC_MODULE_OPTIONS
Expand Down Expand Up @@ -455,20 +455,6 @@ def init_virtual_video_devices(self):
webcamlog.info("found %i virtual video device%s for webcam forwarding", len(devices), engs(devices))
return len(devices)

def init_uuid(self):
# Define a server UUID if needed:
self.uuid = self.get_uuid()
if not self.uuid:
self.uuid = unicode(get_hex_uuid())
self.save_uuid()
log("server uuid is %s", self.uuid)

def get_uuid(self):
return None

def save_uuid(self):
pass

def init_notification_forwarder(self):
log("init_notification_forwarder() enabled=%s", self.notifications)
if self.notifications and os.name=="posix" and not sys.platform.startswith("darwin"):
Expand Down Expand Up @@ -1951,7 +1937,16 @@ def get_info(self, proto=None, client_uuids=None, wids=None, *args):
if not wids:
wids = self._id_to_window.keys()
log("info-request: sources=%s, wids=%s", sources, wids)
info.update(self.do_get_info(proto, sources, wids))
dgi = self.do_get_info(proto, sources, wids)
#ugly alert: merge nested dictionaries,
#ie: do_get_info may return a dictionary for "server" and we already have one,
# so we update it with the new values
for k,v in dgi.items():
cval = info.get(k)
if cval is None:
info[k] = v
continue
cval.update(v)
info.setdefault("dpi", {}).update({
"default" : self.default_dpi,
"value" : self.dpi,
Expand Down Expand Up @@ -2052,8 +2047,7 @@ def get_webcam_info(self):

def do_get_info(self, proto, server_sources=None, window_ids=None):
start = time.time()
info = {"server" : {"python" : {"version" : python_platform.python_version()}}}

info = {}
def up(prefix, d):
info[prefix] = d

Expand Down
22 changes: 20 additions & 2 deletions src/xpra/server/server_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
from xpra.server import ClientException
from xpra.scripts.main import _socket_connect
from xpra.scripts.server import deadly_signal
from xpra.scripts.config import InitException, parse_bool
from xpra.scripts.config import InitException, parse_bool, python_platform
from xpra.net.bytestreams import SocketConnection, log_new_connection, inject_ssl_socket_info, pretty_socket, SOCKET_TIMEOUT
from xpra.platform import set_name
from xpra.os_util import load_binary_file, get_machine_id, get_user_uuid, platform_name, bytestostr, SIGNAMES
from xpra.os_util import load_binary_file, get_machine_id, get_user_uuid, platform_name, bytestostr, get_hex_uuid, SIGNAMES
from xpra.version_util import version_compat_check, get_version_info_full, get_platform_info, get_host_info, local_version
from xpra.net.protocol import Protocol, get_network_caps, sanity_checks
from xpra.net.crypto import crypto_backend_init, new_cipher_caps, get_salt, \
Expand Down Expand Up @@ -172,6 +172,7 @@ def __init__(self):
self.server_idle_timeout = 0
self.server_idle_timer = None

self.init_uuid()
self.init_control_commands()
self.init_packet_handlers()
self.init_aliases()
Expand Down Expand Up @@ -210,6 +211,21 @@ def init(self, opts):
self.init_auth(opts)


def init_uuid(self):
# Define a server UUID if needed:
self.uuid = self.get_uuid()
if not self.uuid:
self.uuid = unicode(get_hex_uuid())
self.save_uuid()
log("server uuid is %s", self.uuid)

def get_uuid(self):
return None

def save_uuid(self):
pass


def init_html_proxy(self, opts):
self._tcp_proxy = opts.tcp_proxy
#opts.html can contain a boolean, "auto" or the path to the webroot
Expand Down Expand Up @@ -1162,12 +1178,14 @@ def up(prefix, d):
si.update({
"mode" : self.get_server_mode(),
"type" : "Python",
"python" : {"version" : python_platform.python_version()},
"start_time" : int(self.start_time),
"idle-timeout" : int(self.server_idle_timeout),
"argv" : sys.argv,
"path" : sys.path,
"exec_prefix" : sys.exec_prefix,
"executable" : sys.executable,
"uuid" : self.uuid,
})
if self.original_desktop_display:
si["original-desktop-display"] = self.original_desktop_display
Expand Down

0 comments on commit e0e9905

Please sign in to comment.