diff --git a/confluent_server/confluent/discovery/protocols/ssdp.py b/confluent_server/confluent/discovery/protocols/ssdp.py index ac76a399..2a7cc264 100644 --- a/confluent_server/confluent/discovery/protocols/ssdp.py +++ b/confluent_server/confluent/discovery/protocols/ssdp.py @@ -32,6 +32,7 @@ import confluent.config.configmanager as cfm import confluent.neighutil as neighutil import confluent.util as util import confluent.log as log +import confluent.netutil as netutil import eventlet.green.select as select import eventlet.green.socket as socket import time @@ -191,6 +192,14 @@ def snoop(handler, byehandler=None, protocol=None, uuidlookup=None): seconds = int(currtime) msecs = int(currtime * 1000 % 1000) reply = 'HTTP/1.1 200 OK\r\nNODENAME: {0}\r\nCURRTIME: {1}\r\nCURRMSECS: {2}\r\n'.format(node, seconds, msecs) + if '%' in peer[0]: + iface = peer[0].split('%', 1)[1] + reply += 'MGTIFACE: {0}\r\n'.format( + peer[0].split('%', 1)[1]) + ncfg = netutil.get_nic_config( + cfg, node, ifidx=iface) + if ncfg.get('matchesnodename', None): + reply += 'DEFAULTNET: 1\r\n' if not isinstance(reply, bytes): reply = reply.encode('utf8') s.sendto(reply, peer) diff --git a/confluent_server/confluent/netutil.py b/confluent_server/confluent/netutil.py index 4ea3beb2..9af1420c 100644 --- a/confluent_server/confluent/netutil.py +++ b/confluent_server/confluent/netutil.py @@ -104,10 +104,11 @@ def myiptonets(svrip): return inametonets(relevantnic) -def idxtonets(ifidx): - _rebuildidxmap() - iname = _idxtoifnamemap.get(ifidx, None) - return inametonets(iname) +def _iftonets(ifidx): + if isinstance(ifidx, int): + _rebuildidxmap() + ifidx = _idxtoifnamemap.get(ifidx, None) + return inametonets(ifidx) def inametonets(iname): addrs = netifaces.ifaddresses(iname) @@ -176,7 +177,7 @@ def get_nic_config(configmanager, node, ip=None, mac=None, ifidx=None, needsvrip = False if ifidx is not None: dhcprequested = False - nets = list(idxtonets(ifidx)) + nets = list(_iftonets(ifidx)) if not nets: cfgdata['ipv4_broken'] = True if serverip is not None: @@ -222,6 +223,7 @@ def get_nic_config(configmanager, node, ip=None, mac=None, ifidx=None, for net in nets: net, prefix, svrip = net if ip_on_same_subnet(net, ipbynodename, prefix): + cfgdata['isnodename'] = True cfgdata['ipv4_address'] = ipbynodename cfgdata['ipv4_method'] = 'static' cfgdata['prefix'] = prefix