Class: WireGuard::Admin::Server
- Defined in:
- lib/wire_guard/admin/server.rb
Overview
A publicly reachable peer/node that serves as a fallback to relay traffic for other VPN peers behind NATs.
@see https://github.com/pirate/wireguard-docs#bounce-server]
Instance Attribute Summary collapse
-
#allowed_ips ⇒ Object
Returns the value of attribute allowed_ips.
-
#device ⇒ Object
Returns the value of attribute device.
-
#port ⇒ Object
Returns the value of attribute port.
Attributes inherited from Client
#ip, #name, #private_key, #public_key
Instance Method Summary collapse
-
#initialize(name:, ip:, allowed_ips:, private_key: nil, port: 51_820, device: 'eth0') ⇒ Server
constructor
rubocop:disable Metrics/ParameterLists.
- #to_s ⇒ Object
Methods inherited from Client
Constructor Details
#initialize(name:, ip:, allowed_ips:, private_key: nil, port: 51_820, device: 'eth0') ⇒ Server
rubocop:disable Metrics/ParameterLists
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/wire_guard/admin/server.rb', line 18 def initialize( name:, ip:, allowed_ips:, private_key: nil, port: 51_820, device: 'eth0' ) super(name: name, ip: ip, private_key: private_key) raise ArgumentError, 'port must be present' if port.nil? raise ArgumentError, 'port number is invalid' unless (1..65_535).cover?(port.to_i) @port = port.to_i raise ArgumentError, 'allowed_ips must be present' if allowed_ips.nil? self.allowed_ips = allowed_ips raise ArgumentError, 'device must be present' if device.nil? raise ArgumentError, 'device must not be empty' if device.empty? @device = device end |
Instance Attribute Details
#allowed_ips ⇒ Object
Returns the value of attribute allowed_ips.
14 15 16 |
# File 'lib/wire_guard/admin/server.rb', line 14 def allowed_ips @allowed_ips end |
#device ⇒ Object
Returns the value of attribute device.
15 16 17 |
# File 'lib/wire_guard/admin/server.rb', line 15 def device @device end |
#port ⇒ Object
Returns the value of attribute port.
15 16 17 |
# File 'lib/wire_guard/admin/server.rb', line 15 def port @port end |
Instance Method Details
#to_s ⇒ Object
50 51 52 |
# File 'lib/wire_guard/admin/server.rb', line 50 def to_s "#{self.class.name.split('::').last} #{name}: #{ip}:#{port} [Allowed IPs: #{allowed_ips}/#{allowed_ips.prefix} via #{device}]" end |