Class: WireGuard::Admin::Templates::Client
- Inherits:
-
ERB
- Object
- ERB
- WireGuard::Admin::Templates::Client
- Defined in:
- lib/wire_guard/admin/templates/client.rb
Overview
Configuration template for a WireGuard::Admin::Client
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#servers ⇒ Object
readonly
Returns the value of attribute servers.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(client, servers) ⇒ Client
constructor
A new instance of Client.
- #render ⇒ Object
Constructor Details
#initialize(client, servers) ⇒ Client
Returns a new instance of Client.
33 34 35 36 37 38 |
# File 'lib/wire_guard/admin/templates/client.rb', line 33 def initialize(client, servers) @client = client @servers = servers @template = self.class.template super(@template) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
31 32 33 |
# File 'lib/wire_guard/admin/templates/client.rb', line 31 def client @client end |
#servers ⇒ Object (readonly)
Returns the value of attribute servers.
31 32 33 |
# File 'lib/wire_guard/admin/templates/client.rb', line 31 def servers @servers end |
Class Method Details
.template ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/wire_guard/admin/templates/client.rb', line 12 def self.template <<~CLIENT_TEMPLATE # WireGuard configuration for <%= client.name %> # generated by wg-admin [Interface] PrivateKey = <%= client.private_key %> Address = <%= client.ip %>/24 <% servers.each do |server| %> [Peer] PublicKey = <%= server.public_key %> EndPoint = <%= server.name %>:<%= server.port %> AllowedIPs = <%= server.allowed_ips %>/<%= server.allowed_ips.prefix %> PersistentKeepalive = 25 <% end %> CLIENT_TEMPLATE end |
Instance Method Details
#render ⇒ Object
40 41 42 |
# File 'lib/wire_guard/admin/templates/client.rb', line 40 def render result(binding) end |