Class: BetterCap::Firewalls::Base
- Inherits:
-
Object
- Object
- BetterCap::Firewalls::Base
- Defined in:
- lib/bettercap/firewalls/base.rb
Overview
Base class for BetterCap::Firewalls objects.
Constant Summary collapse
- @@instance =
Instance of the loaded firewall.
nil
Class Method Summary collapse
-
.clear ⇒ Object
Clear the instance of the BetterCap::Firewalls object.
-
.get ⇒ Object
Save and return an instance of the appropriate BetterCap::Firewalls object.
Instance Method Summary collapse
-
#add_port_redirection(r) ⇒ Object
Apply the
r
BetterCap::Firewalls::Redirection port redirection object. -
#del_port_redirection(r) ⇒ Object
Remove the
r
BetterCap::Firewalls::Redirection port redirection object. -
#enable_forwarding(enabled) ⇒ Object
If
enabled
is true will enable packet forwarding, otherwise it will disable it. -
#enable_icmp_bcast(enabled) ⇒ Object
If
enabled
is true will enable icmp_echo_ignore_broadcasts, otherwise it will disable it. -
#enable_send_redirects(enabled) ⇒ Object
If
enabled
is true will enable send_redirects, otherwise it will disable it. -
#forwarding_enabled? ⇒ Boolean
Return true if packet forwarding is currently enabled, otherwise false.
-
#initialize ⇒ Base
constructor
Initialize the firewall object.
-
#restore ⇒ Object
Restore the system’s original packet forwarding state.
Constructor Details
#initialize ⇒ Base
Initialize the firewall object. Raise NotImplementedError
44 45 46 |
# File 'lib/bettercap/firewalls/base.rb', line 44 def initialize @frwd_initial_state = forwarding_enabled? end |
Class Method Details
.clear ⇒ Object
Clear the instance of the BetterCap::Firewalls object.
37 38 39 |
# File 'lib/bettercap/firewalls/base.rb', line 37 def clear @@instance = nil end |
.get ⇒ Object
Save and return an instance of the appropriate BetterCap::Firewalls object.
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/bettercap/firewalls/base.rb', line 22 def get return @@instance unless @@instance.nil? if RUBY_PLATFORM =~ /openbsd/ or RUBY_PLATFORM =~ /darwin/ @@instance = Firewalls::BSD.new elsif RUBY_PLATFORM =~ /linux/ @@instance = Firewalls::Linux.new else raise BetterCap::Error, 'Unsupported operating system' end @@instance end |
Instance Method Details
#add_port_redirection(r) ⇒ Object
Apply the r
BetterCap::Firewalls::Redirection port redirection object. Raise NotImplementedError
77 78 79 |
# File 'lib/bettercap/firewalls/base.rb', line 77 def add_port_redirection( r ) not_implemented_method! end |
#del_port_redirection(r) ⇒ Object
Remove the r
BetterCap::Firewalls::Redirection port redirection object. Raise NotImplementedError
83 84 85 |
# File 'lib/bettercap/firewalls/base.rb', line 83 def del_port_redirection( r ) not_implemented_method! end |
#enable_forwarding(enabled) ⇒ Object
If enabled
is true will enable packet forwarding, otherwise it will disable it. Raise NotImplementedError
51 52 53 |
# File 'lib/bettercap/firewalls/base.rb', line 51 def enable_forwarding(enabled) not_implemented_method! end |
#enable_icmp_bcast(enabled) ⇒ Object
If enabled
is true will enable icmp_echo_ignore_broadcasts, otherwise it will disable it. Raise NotImplementedError
58 59 60 |
# File 'lib/bettercap/firewalls/base.rb', line 58 def enable_icmp_bcast(enabled) not_implemented_method! end |
#enable_send_redirects(enabled) ⇒ Object
If enabled
is true will enable send_redirects, otherwise it will disable it. Raise NotImplementedError
65 66 67 |
# File 'lib/bettercap/firewalls/base.rb', line 65 def enable_send_redirects(enabled) not_implemented_method! end |
#forwarding_enabled? ⇒ Boolean
Return true if packet forwarding is currently enabled, otherwise false. Raise NotImplementedError
71 72 73 |
# File 'lib/bettercap/firewalls/base.rb', line 71 def forwarding_enabled? not_implemented_method! end |
#restore ⇒ Object
Restore the system’s original packet forwarding state. Raise NotImplementedError
89 90 91 92 93 |
# File 'lib/bettercap/firewalls/base.rb', line 89 def restore if forwarding_enabled? != @frwd_initial_state enable_forwarding @frwd_initial_state end end |