diff options
-rwxr-xr-x | Generate | 18 |
1 files changed, 11 insertions, 7 deletions
@@ -270,6 +270,7 @@ 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'] @@ -293,11 +294,16 @@ $config['hosts'].each_pair{ |name, host| if host['ipv6'] host['networks6'][host['vpn_address6']+"/128"] = host['groups'].join(',') end + + + 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)) + } } throw "Duplicate iface names" unless iface_dup_check.size == $config['hosts'].size -hostlist = $config['hosts'].values.sort{ |a,b| a['host_no'] <=> b['host_no'] } - ##################################################################### # Create the zonefile zonefile = File.new("#{$NAMESPACE}.zone", "w") @@ -313,8 +319,6 @@ zonefile.close ##################################################################### hostlist.each{ |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))} - check_keys host cn = host['name'] +'.'+ $config['cadndomain'] dir = "#{$NAMESPACE}-#{host['name']}" @@ -424,7 +428,7 @@ hostlist.each{ |host| host['link-local'] = {} - peers.each{ |peer| + 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']}" @@ -450,7 +454,7 @@ hostlist.each{ |host| } mapdups = {} host['peer_map_name'] = {} - peers.each{ |peer| + host['peers'].each{ |peer| sharedGroups = peer['groups'].find_all{ |g| host['groups'].include?(g) } #puts "#{host['name']} shares with #{peer['name']}: "+sharedGroups.join(' '); @@ -559,7 +563,7 @@ hostlist.each{ |host| bgpd.puts " exit-address-family" end - peers.each{ |peer| + host['peers'].each{ |peer| if can_connect(peer, host) and can_connect(host, peer) host_is_server = host['host_no'] < peer['host_no'] |