summaryrefslogtreecommitdiff
path: root/Generate
diff options
context:
space:
mode:
Diffstat (limited to 'Generate')
-rwxr-xr-xGenerate29
1 files 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"}"
}