Class: IRC::Server::Modules::Firewall
- Inherits:
-
IRC::Server::Module
- Object
- IRC::Server::Module
- IRC::Server::Modules::Firewall
- Defined in:
- lib/failirc/server/modules/Firewall.rb
Constant Summary collapse
- @@version =
'0.0.1'
Instance Attribute Summary
Attributes inherited from IRC::Server::Module
Class Method Summary collapse
Instance Method Summary collapse
- #description ⇒ Object
- #dispatch(event, thing, string) ⇒ Object
- #finalize ⇒ Object
-
#initialize(server) ⇒ Firewall
constructor
A new instance of Firewall.
- #log(string) ⇒ Object
- #logKill(thing, message) ⇒ Object
- #rehash ⇒ Object
- #target(thing) ⇒ Object
Constructor Details
#initialize(server) ⇒ Firewall
Returns a new instance of Firewall.
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/failirc/server/modules/Firewall.rb', line 39 def initialize (server) @events = { :pre => Event::Callback.new(self.method(:dispatch), -9001), :post => Event::Callback.new(self.method(:dispatch), -9001), :custom => { :log => self.method(:log), :kill => Event::Callback.new(self.method(:logKill), -9001), }, } super(server) end |
Class Method Details
.version ⇒ Object
31 32 33 |
# File 'lib/failirc/server/modules/Firewall.rb', line 31 def self.version return @@version end |
Instance Method Details
#description ⇒ Object
35 36 37 |
# File 'lib/failirc/server/modules/Firewall.rb', line 35 def description "Firewall-#{Firewall.version}" end |
#dispatch(event, thing, string) ⇒ Object
73 74 75 76 77 78 |
# File 'lib/failirc/server/modules/Firewall.rb', line 73 def dispatch (event, thing, string) if (event.chain == :input && event.special == :pre) || (event.chain == :output && event.special == :post) @log.puts "[#{Time.now}] #{target(thing)} #{(event.chain == :input) ? '>' : '<'} #{string.inspect}" @log.flush end end |
#finalize ⇒ Object
67 68 69 70 71 |
# File 'lib/failirc/server/modules/Firewall.rb', line 67 def finalize if @log != $stdout @log.close end end |
#log(string) ⇒ Object
80 81 82 83 |
# File 'lib/failirc/server/modules/Firewall.rb', line 80 def log (string) @log.puts "[#{Time.now}] #{string}" @log.flush end |
#logKill(thing, message) ⇒ Object
85 86 87 |
# File 'lib/failirc/server/modules/Firewall.rb', line 85 def logKill (thing, ) log "#{target(thing)} KILL :#{}" end |
#rehash ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/failirc/server/modules/Firewall.rb', line 53 def rehash if @log && @log != $stdout @log.close end file = @server.config.elements['config/modules/module[@name="Firewall"]/file'] if file @log = File.open(file.text) else @log = $stdout end end |