class WireGuard::Admin::Templates::Server
Configuration template for a WireGuard::Admin::Server
Attributes
clients[R]
network[R]
server[R]
Public Class Methods
new(server:, network:, clients:)
click to toggle source
Calls superclass method
# File lib/wire_guard/admin/templates/server.rb, line 35 def initialize(server:, network:, clients:) @server = server @network = network @clients = clients super(self.class.template, trim_mode: '<>') end
template()
click to toggle source
# File lib/wire_guard/admin/templates/server.rb, line 12 def self.template <<~SERVER_TEMPLATE # WireGuard configuration for <%= server.name %> # generated by wg-admin [Interface] Address = <%= server.ip %>/<%= network.prefix %> ListenPort = <%= server.port %> PrivateKey = <%= server.private_key %> # PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o <%= server.device %> -j MASQUERADE # PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o <%= server.device %> -j MASQUERADE <% clients.each do |client| %> [Peer] # Name = <%= client.name %> PublicKey = <%= client.public_key %> AllowedIPs = <%= client.ip %>/<%= client.ip.prefix %> <% end %> SERVER_TEMPLATE end
Public Instance Methods
render()
click to toggle source
# File lib/wire_guard/admin/templates/server.rb, line 42 def render result(binding) end