# HG changeset patch # User Edouard Tisserant # Date 1546857214 -3600 # Node ID 733d77bf0aa7a3ff069de18cec9e43cbe8c428c7 # Parent 4866c01e74286e3d7a34db64da2b2a74d5831eba Disable MDNS:// scheme support. Also prevent discovery pannel to produce some. For now it seems that that feature is unused, and could be a security issue. diff -r 4866c01e7428 -r 733d77bf0aa7 connectors/PYRO/__init__.py --- a/connectors/PYRO/__init__.py Fri Dec 21 13:51:33 2018 +0100 +++ b/connectors/PYRO/__init__.py Mon Jan 07 11:33:34 2019 +0100 @@ -39,7 +39,6 @@ import PSKManagement as PSK from runtime import PlcStatus -zeroconf_service_type = '_PYRO._tcp.local.' # this module attribute contains a list of DNS-SD (Zeroconf) service types # supported by this connector confnode. # @@ -71,24 +70,6 @@ else: schemename = "PYROLOC" - if location.find(zeroconf_service_type) != -1: - try: - from zeroconf import Zeroconf - r = Zeroconf() - i = r.get_service_info(zeroconf_service_type, location) - if i is None: - raise Exception("'%s' not found" % location) - ip = str(socket.inet_ntoa(i.address)) - port = str(i.port) - newlocation = ip + ':' + port - confnodesroot.logger.write(_("'{a1}' is located at {a2}\n").format(a1=location, a2=newlocation)) - location = newlocation - r.close() - except Exception: - confnodesroot.logger.write_error(_("MDNS resolution failure for '%s'\n") % location) - confnodesroot.logger.write_error(traceback.format_exc()) - return None - # Try to get the proxy object try: RemotePLCObjectProxy = Pyro.core.getAttrProxyForURI(schemename + "://" + location + "/PLCObject") diff -r 4866c01e7428 -r 733d77bf0aa7 connectors/__init__.py --- a/connectors/__init__.py Fri Dec 21 13:51:33 2018 +0100 +++ b/connectors/__init__.py Mon Jan 07 11:33:34 2019 +0100 @@ -67,6 +67,11 @@ or None if cannot connect to URI """ _scheme = uri.split("://")[0].upper() + + # commented code to enable for MDNS:// support + # _scheme, location = uri.split("://") + # _scheme = _scheme.upper() + if _scheme == "LOCAL": # Local is special case # pyro connection to local runtime @@ -75,6 +80,28 @@ runtime_port = confnodesroot.AppFrame.StartLocalRuntime( taskbaricon=True) uri = "PYROLOC://127.0.0.1:" + str(runtime_port) + + # commented code to enable for MDNS:// support + # elif _scheme == "MDNS": + # try: + # from zeroconf import Zeroconf + # r = Zeroconf() + # i = r.get_service_info(zeroconf_service_type, location) + # if i is None: + # raise Exception("'%s' not found" % location) + # ip = str(socket.inet_ntoa(i.address)) + # port = str(i.port) + # newlocation = ip + ':' + port + # confnodesroot.logger.write(_("'{a1}' is located at {a2}\n").format(a1=location, a2=newlocation)) + # location = newlocation + # # not a bug, but a workaround against obvious downgrade attack + # scheme = "PYROS" + # r.close() + # except Exception: + # confnodesroot.logger.write_error(_("MDNS resolution failure for '%s'\n") % location) + # confnodesroot.logger.write_error(traceback.format_exc()) + # return None + elif _scheme in connectors: scheme = _scheme elif _scheme[-1] == 'S' and _scheme[:-1] in connectors: diff -r 4866c01e7428 -r 733d77bf0aa7 controls/DiscoveryPanel.py --- a/controls/DiscoveryPanel.py Fri Dec 21 13:51:33 2018 +0100 +++ b/controls/DiscoveryPanel.py Mon Jan 07 11:33:34 2019 +0100 @@ -54,7 +54,7 @@ def _init_coll_ButtonGridSizer_Items(self, parent): parent.AddWindow(self.RefreshButton, 0, border=0, flag=0) - parent.AddWindow(self.ByIPCheck, 0, border=0, flag=0) + # parent.AddWindow(self.ByIPCheck, 0, border=0, flag=0) def _init_coll_ButtonGridSizer_Growables(self, parent): parent.AddGrowableCol(0) @@ -100,8 +100,8 @@ pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) self.RefreshButton.Bind(wx.EVT_BUTTON, self.OnRefreshButton) - self.ByIPCheck = wx.CheckBox(self, label=_("Use IP instead of Service Name")) - self.ByIPCheck.SetValue(True) + # self.ByIPCheck = wx.CheckBox(self, label=_("Use IP instead of Service Name")) + # self.ByIPCheck.SetValue(True) self._init_sizers() self.Fit() @@ -190,17 +190,17 @@ def GetURI(self): if self.LatestSelection is not None: - if self.ByIPCheck.IsChecked(): - svcname, scheme, host, port = \ - map(lambda col:self.getColumnText(self.LatestSelection, col), - range(4)) - return ("%s://%s:%s#%s" % (scheme, host, port, svcname)) \ - if scheme[-1] == "S" \ - else ("%s://%s:%s" % (scheme, host, port)) - else: - svcname = self.getColumnText(self.LatestSelection, 0) - connect_type = self.getColumnText(self.LatestSelection, 1) - return str("MDNS://%s" % svcname) + # if self.ByIPCheck.IsChecked(): + svcname, scheme, host, port = \ + map(lambda col:self.getColumnText(self.LatestSelection, col), + range(4)) + return ("%s://%s:%s#%s" % (scheme, host, port, svcname)) \ + if scheme[-1] == "S" \ + else ("%s://%s:%s" % (scheme, host, port)) + # else: + # svcname = self.getColumnText(self.LatestSelection, 0) + # connect_type = self.getColumnText(self.LatestSelection, 1) + # return str("MDNS://%s" % svcname) return None def remove_service(self, zeroconf, _type, name):