fix(graph): NS, MX and web names share one column so edges do not cross nodes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+5
-3
@@ -52,6 +52,8 @@ def build(domain):
|
||||
nodes[zone_node]['nxdomain'] = True
|
||||
return {'domain': domain, 'nodes': list(nodes.values()), 'edges': edges,
|
||||
'delegation': steps}
|
||||
# Columns after the zone: names it publishes (NS, MX, www), CNAME targets,
|
||||
# addresses, networks. Empty columns are collapsed by the GUI.
|
||||
L_REC, L_HOST, L_IP, L_NET = depth + 1, depth + 2, depth + 3, depth + 4
|
||||
|
||||
ns = [n.rstrip('.') for n in dnsutil.resolve(domain, 'NS')]
|
||||
@@ -68,13 +70,13 @@ def build(domain):
|
||||
host_ips[h] = ips
|
||||
|
||||
for n in ns[:8]:
|
||||
hid = node('host:' + n, n, 'ns', L_HOST)
|
||||
hid = node('host:' + n, n, 'ns', L_REC)
|
||||
edge(zone_node, hid, 'NS')
|
||||
for pref, h in mx[:6]:
|
||||
h = h.rstrip('.')
|
||||
if h in ('', '.'):
|
||||
continue
|
||||
hid = node('host:' + h, h, 'mx', L_HOST, pref=int(pref))
|
||||
hid = node('host:' + h, h, 'mx', L_REC, pref=int(pref))
|
||||
edge(zone_node, hid, f'MX {pref}')
|
||||
|
||||
chains = dict(_pool.map(lambda w: (w, dnsutil.cname_chain(w)), web))
|
||||
@@ -87,7 +89,7 @@ def build(domain):
|
||||
edge(zone_node, wid, None)
|
||||
cur = wid
|
||||
for i, target in enumerate(chains[w]):
|
||||
tid = node('host:' + target, target, 'cname', L_HOST if i == len(chains[w]) - 1 else L_REC)
|
||||
tid = node('host:' + target, target, 'cname', L_HOST)
|
||||
edge(cur, tid, 'CNAME')
|
||||
cur = tid
|
||||
if chains[w]:
|
||||
|
||||
Reference in New Issue
Block a user