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.
-
#network ⇒ Object
readonly
Returns the value of attribute network.
-
#servers ⇒ Object
readonly
Returns the value of attribute servers.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(client:, network:, servers:) ⇒ Client
constructor
A new instance of Client.
- #render ⇒ Object
Constructor Details
#initialize(client:, network:, 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:, network:, servers:) @client = client @network = network @servers = servers super(self.class.template, trim_mode: '<>') 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 |
#network ⇒ Object (readonly)
Returns the value of attribute network.
31 32 33 |
# File 'lib/wire_guard/admin/templates/client.rb', line 31 def network @network 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 " # WireGuard configuration for <%= client.name %>\n # generated by wg-admin\n\n [Interface]\n PrivateKey = <%= client.private_key %>\n Address = <%= client.ip %>/<%= network.prefix %>\n <% servers.each do |server| %>\n\n [Peer]\n PublicKey = <%= server.public_key %>\n EndPoint = <%= server.name %>:<%= server.port %>\n AllowedIPs = <%= server.allowed_ips %>/<%= server.allowed_ips.prefix %>\n PersistentKeepalive = 25\n <% end %>\n CLIENT_TEMPLATE\nend\n" |
Instance Method Details
#render ⇒ Object
40 41 42 |
# File 'lib/wire_guard/admin/templates/client.rb', line 40 def render result(binding) end |