Sha256: 71e7785e522784ae05f5560c33aeb1cb4a6795d42eafd622e02fbc20a87d6d70
Contents?: true
Size: 1.22 KB
Versions: 1
Compression:
Stored size: 1.22 KB
Contents
module FirewallHelper COMMANDS = { darwin: { setup: [ "sudo ipfw add 02070 deny tcp from any to any 5672" ], teardown: [ "sudo ipfw delete 02070" ] }, linux: { setup: [ "sudo iptables -N block-rabbit", "sudo iptables -A block-rabbit -p tcp --dport 5672 -j DROP", "sudo iptables -A block-rabbit -p tcp --sport 5672 -j DROP", "sudo iptables -I INPUT -j block-rabbit", "sudo iptables -I OUTPUT -j block-rabbit" ], teardown: [ "sudo iptables -D INPUT -j block-rabbit", "sudo iptables -D OUTPUT -j block-rabbit", "sudo iptables -F block-rabbit", "sudo iptables -X block-rabbit" ] } } def block_broker_port run_commands(:setup) @firewall_rule_set = true end def unblock_broker_port run_commands(:teardown) if @firewall_rule_set @firewall_rule_set = false end def run_commands(step) COMMANDS[os][step].each do |cmd| result = system(cmd) raise "command `#{cmd}` failed!" unless result end end def os if darwin? :darwin else :linux end end def darwin? system("uname | grep Darwin") end end World(FirewallHelper)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
message-driver-0.1.0 | features/support/firewall_helper.rb |