Class: WireGuard::Admin::Client
- Inherits:
-
Object
- Object
- WireGuard::Admin::Client
- Defined in:
- lib/wire_guard/admin/client.rb
Overview
A host that connects to the VPN and registers a VPN subnet address such as 192.0.2.3 for itself.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#private_key ⇒ Object
Returns the value of attribute private_key.
-
#public_key ⇒ Object
readonly
Returns the value of attribute public_key.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(name:, ip:, private_key: nil) ⇒ Client
constructor
A new instance of Client.
- #to_s ⇒ Object
Constructor Details
#initialize(name:, ip:, private_key: nil) ⇒ Client
Returns a new instance of Client.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/wire_guard/admin/client.rb', line 27 def initialize(name:, ip:, private_key: nil) raise ArgumentError, 'name must be present' if name.nil? raise ArgumentError, 'name must not be empty' if name.empty? raise ArgumentError, 'ip must be present' if ip.nil? raise ArgumentError, 'private_key must not be empty' if private_key&.empty? @name = name @ip = ip self.private_key = private_key || generate_private_key end |
Instance Attribute Details
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
25 26 27 |
# File 'lib/wire_guard/admin/client.rb', line 25 def ip @ip end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
25 26 27 |
# File 'lib/wire_guard/admin/client.rb', line 25 def name @name end |
#private_key ⇒ Object
Returns the value of attribute private_key.
25 26 27 |
# File 'lib/wire_guard/admin/client.rb', line 25 def private_key @private_key end |
#public_key ⇒ Object (readonly)
Returns the value of attribute public_key.
25 26 27 |
# File 'lib/wire_guard/admin/client.rb', line 25 def public_key @public_key end |
Instance Method Details
#==(other) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/wire_guard/admin/client.rb', line 55 def ==(other) name == if other.respond_to?(:name) other.name else other end end |
#eql?(other) ⇒ Boolean
51 52 53 |
# File 'lib/wire_guard/admin/client.rb', line 51 def eql?(other) hash == other.hash end |
#hash ⇒ Object
47 48 49 |
# File 'lib/wire_guard/admin/client.rb', line 47 def hash name.hash end |
#to_s ⇒ Object
43 44 45 |
# File 'lib/wire_guard/admin/client.rb', line 43 def to_s "#{self.class.name.split('::').last} #{name}: #{ip}" end |