riptables 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -0
- data/bin/riptables +4 -3
- data/lib/riptables/base.rb +29 -0
- data/lib/riptables/dsl/base.rb +20 -0
- data/lib/riptables/table.rb +3 -1
- data/lib/riptables/version.rb +1 -1
- data/lib/riptables.rb +1 -26
- metadata +3 -2
- data/lib/riptables/dsl/root.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 188cb2ed7bb522ea47cd1c2fde51ff290b258f68
|
4
|
+
data.tar.gz: 269aaf5101ca29be6afa53f288527384f4840ae3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95f7cd9e5d4a41434d2976e3ec5332aceb239196a2ceb75c9161d06726a05c0000f04b2e5abb92a3a0821b12fb0bbf1cd09b948e2b9afe970cf1efe5a08e7c3e
|
7
|
+
data.tar.gz: 71146751cebabb763760533c9adf4e810b67f364c54d281a564ff4b999d4f18f4e54c513b2db4d36895cf1f707ac08b3ef602b8a88357049b306d33fec1328f9
|
data/README.md
CHANGED
@@ -116,6 +116,17 @@ both and cannot currently be different depending on IP version.
|
|
116
116
|
The `riptables` command is used to generate your iptables-save files. These can
|
117
117
|
then be used with `iptables-restore`.
|
118
118
|
|
119
|
+
### Installing
|
120
|
+
|
121
|
+
* Ensure you have Ruby 2.0 or higher installed.
|
122
|
+
* Ensure you have RubyGems install.
|
123
|
+
|
124
|
+
```text
|
125
|
+
gem install riptables
|
126
|
+
```
|
127
|
+
|
128
|
+
### Usage
|
129
|
+
|
119
130
|
```text
|
120
131
|
$ riptables
|
121
132
|
```
|
data/bin/riptables
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
$:.unshift(File.expand_path('../../lib', __FILE__))
|
3
|
-
|
3
|
+
|
4
4
|
require 'optparse'
|
5
5
|
|
6
6
|
options = {}
|
@@ -21,8 +21,9 @@ OptionParser.new do |opts|
|
|
21
21
|
end.parse!
|
22
22
|
|
23
23
|
begin
|
24
|
-
|
25
|
-
Riptables.
|
24
|
+
require 'riptables/base'
|
25
|
+
base = Riptables::Base.load_from_file(load_path)
|
26
|
+
base.tables.each do |table|
|
26
27
|
puts table.export(options).to_savefile(ipv)
|
27
28
|
end
|
28
29
|
rescue Riptables::Error => e
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'riptables/error'
|
2
|
+
require 'riptables/dsl/base'
|
3
|
+
|
4
|
+
module Riptables
|
5
|
+
class Base
|
6
|
+
|
7
|
+
attr_reader :tables
|
8
|
+
|
9
|
+
def initialize(&block)
|
10
|
+
@tables = []
|
11
|
+
dsl.instance_eval(&block) if block_given?
|
12
|
+
end
|
13
|
+
|
14
|
+
def dsl
|
15
|
+
@dsl ||= DSL::Base.new(self)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.load_from_file(file)
|
19
|
+
if File.file?(file)
|
20
|
+
base = Base.new
|
21
|
+
base.dsl.instance_eval(File.read(file), file)
|
22
|
+
base
|
23
|
+
else
|
24
|
+
raise Error, "File not found at `#{file}`"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'riptables/dsl/base'
|
2
|
+
require 'riptables/table'
|
3
|
+
|
4
|
+
module Riptables
|
5
|
+
module DSL
|
6
|
+
class Base < Global
|
7
|
+
|
8
|
+
def initialize(base, &block)
|
9
|
+
@base = base
|
10
|
+
end
|
11
|
+
|
12
|
+
def table(name, &block)
|
13
|
+
table = Riptables::Table.new(@base, name)
|
14
|
+
table.dsl.instance_eval(&block)
|
15
|
+
@base.tables << table
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/riptables/table.rb
CHANGED
data/lib/riptables/version.rb
CHANGED
data/lib/riptables.rb
CHANGED
@@ -1,26 +1 @@
|
|
1
|
-
require 'riptables/
|
2
|
-
require 'riptables/error'
|
3
|
-
|
4
|
-
module Riptables
|
5
|
-
|
6
|
-
#
|
7
|
-
# Store all tables configured
|
8
|
-
#
|
9
|
-
def self.tables
|
10
|
-
@tables ||= []
|
11
|
-
end
|
12
|
-
|
13
|
-
#
|
14
|
-
# Parse a given file
|
15
|
-
#
|
16
|
-
def self.load_from_file(file)
|
17
|
-
if File.file?(file)
|
18
|
-
dsl = DSL::Root.new
|
19
|
-
dsl.instance_eval(File.read(file), file)
|
20
|
-
true
|
21
|
-
else
|
22
|
-
raise Error, "File not found at `#{file}`"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
1
|
+
require 'riptables/base'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riptables
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Cooke
|
@@ -22,10 +22,11 @@ files:
|
|
22
22
|
- README.md
|
23
23
|
- bin/riptables
|
24
24
|
- lib/riptables.rb
|
25
|
+
- lib/riptables/base.rb
|
25
26
|
- lib/riptables/chain.rb
|
26
27
|
- lib/riptables/condition.rb
|
28
|
+
- lib/riptables/dsl/base.rb
|
27
29
|
- lib/riptables/dsl/global.rb
|
28
|
-
- lib/riptables/dsl/root.rb
|
29
30
|
- lib/riptables/dsl/rule.rb
|
30
31
|
- lib/riptables/dsl/table.rb
|
31
32
|
- lib/riptables/error.rb
|
data/lib/riptables/dsl/root.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'riptables/dsl/global'
|
2
|
-
require 'riptables/table'
|
3
|
-
|
4
|
-
module Riptables
|
5
|
-
module DSL
|
6
|
-
class Root < Global
|
7
|
-
|
8
|
-
#
|
9
|
-
# Rules within a given table
|
10
|
-
#
|
11
|
-
def table(name, &block)
|
12
|
-
table = Riptables::Table.new(name)
|
13
|
-
table.dsl.instance_eval(&block)
|
14
|
-
Riptables.tables << table
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|