Class: Kscript::KkWgAclUtils

Inherits:
Base
  • Object
show all
Defined in:
lib/kscript/plugins/kk_wg_acl_utils.rb

Constant Summary collapse

WIREGUARD_PORT =
51_821
ALLOWED_IPS =
%w[127.0.0.1].freeze

Instance Attribute Summary

Attributes inherited from Base

#logger

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#human_output?, inherited, #with_error_handling

Constructor Details

#initialize(*args, **opts) ⇒ KkWgAclUtils

Returns a new instance of KkWgAclUtils.



15
16
17
# File 'lib/kscript/plugins/kk_wg_acl_utils.rb', line 15

def initialize(*args, **opts)
  super
end

Class Method Details

.argumentsObject



31
32
33
# File 'lib/kscript/plugins/kk_wg_acl_utils.rb', line 31

def self.arguments
  '[subcommand] [options]'
end

.authorObject



43
44
45
# File 'lib/kscript/plugins/kk_wg_acl_utils.rb', line 43

def self.author
  'kk'
end

.descriptionObject



47
48
49
# File 'lib/kscript/plugins/kk_wg_acl_utils.rb', line 47

def self.description
  'Manage WireGuard firewall ACL rules.'
end

.groupObject



39
40
41
# File 'lib/kscript/plugins/kk_wg_acl_utils.rb', line 39

def self.group
  'network'
end

.usageObject



35
36
37
# File 'lib/kscript/plugins/kk_wg_acl_utils.rb', line 35

def self.usage
  "kscript wg_acl add --ip=10.0.0.2\nkscript wg_acl list"
end

Instance Method Details

#apply_rulesObject



25
26
27
28
29
# File 'lib/kscript/plugins/kk_wg_acl_utils.rb', line 25

def apply_rules
  add_whitelist_rules
  ensure_firewall_enabled
  display_current_rules
end

#runObject



19
20
21
22
23
# File 'lib/kscript/plugins/kk_wg_acl_utils.rb', line 19

def run
  with_error_handling do
    apply_rules
  end
end