summaryrefslogtreecommitdiff
path: root/wireguardmeshgenerator.rb
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-04-18 11:48:33 +0300
committerPaul Buetow <paul@buetow.org>2025-04-18 11:48:33 +0300
commit5e4208c5c3014f96bd2d6804ddad8df6907dc7cf (patch)
tree53ce451af8d1f31aff43951e6a39821d5d9ea263 /wireguardmeshgenerator.rb
parent2e07b3cbce78c75b1c0a586252be69a46d61d2ca (diff)
jo
Diffstat (limited to 'wireguardmeshgenerator.rb')
-rw-r--r--wireguardmeshgenerator.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/wireguardmeshgenerator.rb b/wireguardmeshgenerator.rb
index 656586a..ae7ddd4 100644
--- a/wireguardmeshgenerator.rb
+++ b/wireguardmeshgenerator.rb
@@ -30,18 +30,18 @@ PeerSnippet = Struct.new(:description, :public_key, :preshared_key, :allowed_ips
end
WireguardConfig = Struct.new(:myself, :hosts) do
- def to_s
- peers = hosts.map do |name, data|
- PeerSnippet.new("#{name}.#{data[:wg0][:domain]}",
- :PUB_KEY, :PRESHARED_KEY, "#{data[:wg0][:ip]}/32")
- end
+ @peers = hosts.map do |name, data|
+ PeerSnippet.new("#{name}.#{data[:wg0][:domain]}",
+ :PUB_KEY, :PRESHARED_KEY, "#{data[:wg0][:ip]}/32")
+ end
+ def to_s
<<~CONFIG
[Interface]
Address = #{hosts[myself][:wg0][:ip]}
PrivateKey = #{private_key}
- #{peers.map(&:to_s).join("\n")}
+ #{@peers.map(&:to_s).join("\n")}
CONFIG
end