Browse Source

nodeinfo: allow to specify mac

determine node_id by specified mac if node_id is not set.
Karsten Böddeker 7 years ago
parent
commit
b476188fd7
2 changed files with 10 additions and 1 deletions
  1. 3 0
      config.json.example
  2. 7 1
      ext-respondd.py

+ 3 - 0
config.json.example

@@ -9,6 +9,9 @@
       "latitude": 51.7236,
       "longitude": 8.7484
     },
+    "network": {
+      "mac": "ca:ff:ee:ba:be:00"
+    },
     "node_id": "caffeebabe00",
     "owner": {
         "contact": "contact@example.tld"

+ 7 - 1
ext-respondd.py

@@ -207,6 +207,8 @@ def getMeshVPNPeers():
 def getNode_ID():
     if 'node_id' in config['nodeinfo']:
         return config['nodeinfo']['node_id']
+    elif 'network' in config['nodeinfo'] and 'mac' in config['nodeinfo']['network']:
+        return config['nodeinfo']['network']['mac'].replace(':','')
     else:
         return getDevice_MAC(config["batman"]).replace(':','')
 
@@ -303,7 +305,6 @@ def createNodeinfo():
                     "interfaces": getBat0_Interfaces(),
                 },
             },
-            "mac": getDevice_MAC(config["batman"]),
             "mesh_interfaces": list(getMesh_Interfaces().values()),
         },
         "software": {
@@ -340,6 +341,11 @@ def createNodeinfo():
         },
         j['vpn'] = True
 
+    if 'network' in config['nodeinfo'] and 'mac' in config['nodeinfo']['network']:
+        j['network']['mac'] = config['nodeinfo']['network']['mac']
+    else:
+        j['network']['mac'] = getDevice_MAC(config['batman'])
+
     if 'location' in config['nodeinfo']:
         j['location'] = {
             "latitude": config['nodeinfo']['location']['latitude'],