iptablez 1.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +141 -0
- data/Rakefile +6 -0
- data/Vagrantfile +100 -0
- data/bin/console +14 -0
- data/bin/iptblz.rb +21 -0
- data/bin/setup +8 -0
- data/giant_squid.txt +12 -0
- data/iptablez.gemspec +27 -0
- data/lib/iptablez.rb +33 -0
- data/lib/iptablez/chains/README.md +139 -0
- data/lib/iptablez/chains/chains.rb +227 -0
- data/lib/iptablez/commands/append_chain.rb +62 -0
- data/lib/iptablez/commands/delete_chain.rb +106 -0
- data/lib/iptablez/commands/flush_chain.rb +72 -0
- data/lib/iptablez/commands/helpers/argument_helpers.rb +163 -0
- data/lib/iptablez/commands/helpers/errors.rb +11 -0
- data/lib/iptablez/commands/helpers/move_on.rb +14 -0
- data/lib/iptablez/commands/interface.rb +80 -0
- data/lib/iptablez/commands/list.rb +210 -0
- data/lib/iptablez/commands/new_chain.rb +71 -0
- data/lib/iptablez/commands/policy.rb +65 -0
- data/lib/iptablez/commands/rename_chain.rb +65 -0
- data/lib/iptablez/commands/version.rb +18 -0
- data/lib/iptablez/commands/zero.rb +18 -0
- data/lib/iptablez/helpers/helpers.rb +46 -0
- data/lib/iptablez/helpers/version.rb +3 -0
- metadata +121 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
module Iptablez
|
2
|
+
|
3
|
+
# Shortcut to get the bin path for `iptables`.
|
4
|
+
# @return [String]
|
5
|
+
def self.bin_path
|
6
|
+
o, e, s = Open3.capture3("which", "iptables")
|
7
|
+
return o.strip if s.success?
|
8
|
+
raise e
|
9
|
+
end
|
10
|
+
|
11
|
+
# Shortcut to get the version number for `iptables`.
|
12
|
+
# @return [String]
|
13
|
+
def self.version
|
14
|
+
Commands::Version.number
|
15
|
+
end
|
16
|
+
|
17
|
+
# Shortcut to list the rules found in a chain of a given +name+ or
|
18
|
+
# if no chain is specifcied, list all of the chains.
|
19
|
+
# @example Basic Usage
|
20
|
+
# Iptablez.list
|
21
|
+
# # => []
|
22
|
+
# @example Basic Usage with a Block
|
23
|
+
# Iptablez.list(chain: "INPUT") do |line|
|
24
|
+
# puts line # each line
|
25
|
+
# end
|
26
|
+
def self.list(chain: false)
|
27
|
+
if chain
|
28
|
+
Commands::List.chain(name: chain)
|
29
|
+
else
|
30
|
+
Commands::List.all
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Shortcut to list all of the chains.
|
35
|
+
# @example Basic Usage
|
36
|
+
# Iptablez.chains
|
37
|
+
# # => ["INPUT", "FORWARD", "OUTPUT", "dogs", "cats"]
|
38
|
+
# @example Basic Usage with a Block
|
39
|
+
# Iptablez.chains { |chain| puts chain }
|
40
|
+
# @return [Array]
|
41
|
+
def self.chains
|
42
|
+
Chains.all.each { |chain| yield chain } if block_given?
|
43
|
+
Chains.all
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
metadata
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: iptablez
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.pre
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kent 'picat' Gruber
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-04-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.14'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.14'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- kgruber1@emich.edu
|
58
|
+
executables:
|
59
|
+
- console
|
60
|
+
- iptblz.rb
|
61
|
+
- setup
|
62
|
+
extensions: []
|
63
|
+
extra_rdoc_files: []
|
64
|
+
files:
|
65
|
+
- ".gitignore"
|
66
|
+
- ".rspec"
|
67
|
+
- ".travis.yml"
|
68
|
+
- CODE_OF_CONDUCT.md
|
69
|
+
- Gemfile
|
70
|
+
- LICENSE.txt
|
71
|
+
- README.md
|
72
|
+
- Rakefile
|
73
|
+
- Vagrantfile
|
74
|
+
- bin/console
|
75
|
+
- bin/iptblz.rb
|
76
|
+
- bin/setup
|
77
|
+
- giant_squid.txt
|
78
|
+
- iptablez.gemspec
|
79
|
+
- lib/iptablez.rb
|
80
|
+
- lib/iptablez/chains/README.md
|
81
|
+
- lib/iptablez/chains/chains.rb
|
82
|
+
- lib/iptablez/commands/append_chain.rb
|
83
|
+
- lib/iptablez/commands/delete_chain.rb
|
84
|
+
- lib/iptablez/commands/flush_chain.rb
|
85
|
+
- lib/iptablez/commands/helpers/argument_helpers.rb
|
86
|
+
- lib/iptablez/commands/helpers/errors.rb
|
87
|
+
- lib/iptablez/commands/helpers/move_on.rb
|
88
|
+
- lib/iptablez/commands/interface.rb
|
89
|
+
- lib/iptablez/commands/list.rb
|
90
|
+
- lib/iptablez/commands/new_chain.rb
|
91
|
+
- lib/iptablez/commands/policy.rb
|
92
|
+
- lib/iptablez/commands/rename_chain.rb
|
93
|
+
- lib/iptablez/commands/version.rb
|
94
|
+
- lib/iptablez/commands/zero.rb
|
95
|
+
- lib/iptablez/helpers/helpers.rb
|
96
|
+
- lib/iptablez/helpers/version.rb
|
97
|
+
homepage: https://github.com/picatz/iptablez
|
98
|
+
licenses:
|
99
|
+
- MIT
|
100
|
+
metadata: {}
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options: []
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">"
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: 1.3.1
|
115
|
+
requirements: []
|
116
|
+
rubyforge_project:
|
117
|
+
rubygems_version: 2.6.8
|
118
|
+
signing_key:
|
119
|
+
specification_version: 4
|
120
|
+
summary: A friendly Ruby API to iptables.
|
121
|
+
test_files: []
|