[Interface]
-<%- @ips.each do |ip| %>
+<%- @ips.each do |ip| -%>
Address = <%= ip %>
-<% end -%>
+<%- end -%>
PrivateKey = <%= @private_key %>
+ListenPort = 51820
<%- @facts["ldapvar"]["other"].each do |host| -%>
<%- if (host["vars"]["wireguard_public"] || []).count > 0 %>
[Peer]
-PublicKey = host["vars"]["wireguard_public"][0]
+# <%= host["vars"]["real_hostname"][0] %>
+PublicKey = <%= host["vars"]["wireguard_public"][0] %>
+<%- if (host["vars"]["wireguard_ip"] || []).count > 0 -%>
+AllowedIps = <%= host["vars"]["wireguard_ip"].join(", ").gsub /\/\d+/, "/32" %>
+<%- end -%>
+Endpoint = <%= host["vars"]["real_hostname"][0] %>:51820
<% end -%>
<%- end -%>