Class: WireGuard::Admin::Clients
Overview
Commands for working with clients
Instance Method Summary
collapse
default_network, path, repository
#ip, #network, #repository
Instance Method Details
#add(name) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/wire_guard/admin/cli/clients.rb', line 21
def add(name)
warn "Using database #{repository.path}" if options[:verbose]
client = Client.new(name: name, ip: ip)
client.private_key = options[:private_key] if options[:private_key]
repository.add_peer(network, client)
if options[:verbose]
warn 'New client was successfully added:'
warn ''
warn client
end
rescue StandardError => e
raise Thor::Error, "Error: #{e.message}"
end
|
#list ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/wire_guard/admin/cli/clients.rb', line 49
def list
if options[:verbose]
warn "Using database #{repository.path}"
warn "No clients in network #{network}." if repository.networks.empty?
end
repository.clients(network).each do |client|
puts client
end
rescue StandardError => e
raise Thor::Error, "Error: #{e.message}"
end
|
#remove(name) ⇒ Object
38
39
40
41
42
43
44
|
# File 'lib/wire_guard/admin/cli/clients.rb', line 38
def remove(name)
warn "Using database #{repository.path}" if options[:verbose]
repository.remove_peer(network, name)
warn 'Client was successfully removed.' if options[:verbose]
rescue StandardError => e
raise Thor::Error, "Error: #{e.message}"
end
|