From 17692e9e69eb578143555403a80aea5b08b21d6d Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Sat, 7 Jan 2006 15:52:40 +0000 Subject: Move link local creation up to host setup split host setup into two parts, as parts depend on other parts git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@47 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede --- Generate | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/Generate b/Generate index bd576a9..07da5a3 100755 --- a/Generate +++ b/Generate @@ -270,7 +270,6 @@ def makelistname(peer, inout) end -hostlist = $config['hosts'].values.sort{ |a,b| a['host_no'] <=> b['host_no'] } iface_dup_check = {} $config['hosts'].each_pair{ |name, host| throw "Host #{name} doesn't have any groups" unless host['groups'] @@ -294,13 +293,27 @@ $config['hosts'].each_pair{ |name, host| if host['ipv6'] host['networks6'][host['vpn_address6']+"/128"] = host['groups'].join(',') end +} - +hostlist = $config['hosts'].values.sort{ |a,b| a['host_no'] <=> b['host_no'] } +hostlist.each{ |host| host['peers'] = hostlist.find_all{ |peer| host['name'] != peer['name'] and want_connection(host, peer) and (can_connect(host,peer) or can_connect(peer,host)) } + + host['link-local'] = {} + host['peers'].each{ |peer| + lower = host['host_no'] < peer['host_no'] ? host['host_no'] : peer['host_no'] + higher = host['host_no'] > peer['host_no'] ? host['host_no'] : peer['host_no'] + ipv6_link_local_me = "fe80:0:#{lower}:#{higher}:0:0:0:#{host['host_no']}" + ipv6_link_local_peer = "fe80:0:#{lower}:#{higher}:0:0:0:#{peer['host_no']}" + host['link-local'][ peer['name'] ] = { + "me" => ipv6_link_local_me, + "peer" => ipv6_link_local_peer + } + } } throw "Duplicate iface names" unless iface_dup_check.size == $config['hosts'].size @@ -427,18 +440,6 @@ hostlist.each{ |host| outmaps << "! from a node with tags that it shouldn't know about: it must be lying." - host['link-local'] = {} - host['peers'].each{ |peer| - lower = host['host_no'] < peer['host_no'] ? host['host_no'] : peer['host_no'] - higher = host['host_no'] > peer['host_no'] ? host['host_no'] : peer['host_no'] - ipv6_link_local_me = "fe80:0:#{lower}:#{higher}:0:0:0:#{host['host_no']}" - ipv6_link_local_peer = "fe80:0:#{lower}:#{higher}:0:0:0:#{peer['host_no']}" - host['link-local'][ peer['name'] ] = { - "me" => ipv6_link_local_me, - "peer" => ipv6_link_local_peer - } - } - host['networks'].each_key{ |net| outmaps << "ip prefix-list pl#{ net.tr(':./', '-_') } seq 10 permit #{net} #{net =~ /\/32/ ? '' : "le 32"}" } -- cgit v1.2.3