diff options
author | Peter Palfrader <peter@palfrader.org> | 2006-01-07 15:52:40 +0000 |
---|---|---|
committer | weasel <weasel@bc3d92e2-beff-0310-a7cd-cc87d7ac0ede> | 2006-01-07 15:52:40 +0000 |
commit | 17692e9e69eb578143555403a80aea5b08b21d6d (patch) | |
tree | 27e737f083bdc8b49132b73382bc220d18acb5fd | |
parent | 50fe5008367e0dfbd9303ab21f83fe1177df4cd3 (diff) |
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
-rwxr-xr-x | Generate | 29 |
1 files changed, 15 insertions, 14 deletions
@@ -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"}" } |