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
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4e27d616c61e90e4fa969613ccd236445775873a
|
4
|
+
data.tar.gz: 6d89e672eaa3c0c801dd8d0946fa83cec269bc63
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2445e2428e180aa13a2bda763e187948390e8bfeb673bde2e88d24b74817e7077084621450d882e167745f3d1de7bc77418db1809ac4e59aedfeb2e0c8165efe
|
7
|
+
data.tar.gz: 6f30d3bcc5ad65e24999b6d7704e2a5654040298201f0fbe7edf71dcf81dbe918696060bcbeb2e4a0e5b5f65002df2805b96e17008d44bd3d2dc3c0a1856da98
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at kgruber1@emich.edu. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Kent Gruber
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
# 🦑 Iptablez
|
2
|
+
|
3
|
+
A friendly Ruby API to `iptables`. With a squid for a mascot.
|
4
|
+
|
5
|
+
### 🚧 Development Notice
|
6
|
+
|
7
|
+
Iptablez is still under development.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
$ gem install iptablez
|
12
|
+
|
13
|
+
## ⛓ Usage
|
14
|
+
|
15
|
+
Easily list all of the `iptables` chains.
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
Iptablez.chains
|
19
|
+
# => ["INPUT", "FORWARD", "OUTPUT", "cats", "dogs"]
|
20
|
+
|
21
|
+
Iptablez::Chains.all
|
22
|
+
# => ["INPUT", "FORWARD", "OUTPUT", "cats", "dogs"]
|
23
|
+
```
|
24
|
+
|
25
|
+
Maybe you just want the default chains?
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
Iptablez::Chains.defaults
|
29
|
+
# => ["INPUT", "FORWARD", "OUTPUT"]
|
30
|
+
|
31
|
+
Iptablez::Chains::DEFAULT
|
32
|
+
# => ["INPUT", "FORWARD", "OUTPUT"]
|
33
|
+
```
|
34
|
+
|
35
|
+
Create a new user defined chain(s)?
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
Iptablez::Chains.create(name: "dogs")
|
39
|
+
# => true
|
40
|
+
|
41
|
+
Iptablez::Chains.create(names: ["dogs", "cats"])
|
42
|
+
# => {"dogs"=>false, "cats"=>true}
|
43
|
+
```
|
44
|
+
|
45
|
+
Delete a user defined chain(s) ( that's empty )?
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
Iptablez::Chains.delete(name: "dogs")
|
49
|
+
# => true
|
50
|
+
|
51
|
+
Iptablez::Chains.delete(names: ["dogs", "cats"])
|
52
|
+
# => {"dogs"=>false, "cats"=>true}
|
53
|
+
```
|
54
|
+
|
55
|
+
Maybe rename a user defined chain?
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
Iptablez::Chains.rename(from: "dogs", to: "puppies")
|
59
|
+
# => true
|
60
|
+
|
61
|
+
Iptablez::Chains.rename(pairs: { "dogs" => "puppies", "cats" => "kittens"} )
|
62
|
+
# => {"dogs"=>{"puppies"=>false}, "cats"=>{"kittens"=>true}}
|
63
|
+
```
|
64
|
+
|
65
|
+
Why not check the default chain policies?
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
Iptablez::Chains.policies
|
69
|
+
# => {"INPUT"=>"ACCEPT", "FORWARD"=>"ACCEPT", "OUTPUT"=>"ACCEPT"}
|
70
|
+
```
|
71
|
+
|
72
|
+
Want to be a little bit more specific when checking policies? I got'chu.
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
Iptablez::Chains.policy?(name: "INPUT", policy: "ACCEPT")
|
76
|
+
# => true
|
77
|
+
|
78
|
+
Iptablez::Chains.policy?(name: "FORWARD", policy: "ACCEPT")
|
79
|
+
# => false
|
80
|
+
|
81
|
+
Iptablez::Chains.policies(names: ["FORWARD", "OUTPUT"])
|
82
|
+
# => {"FORWARD"=>"ACCEPT", "OUTPUT"=>"ACCEPT"}
|
83
|
+
```
|
84
|
+
|
85
|
+
Feel like flushing some chains? Maybe you're about to delete them and need them to not be empty. I feel you.
|
86
|
+
|
87
|
+
```ruby
|
88
|
+
Iptablez::Chains.flush(name: "wizards")
|
89
|
+
# => true
|
90
|
+
|
91
|
+
Iptablez::Chains.flush(names: ["wizards", "hobbits"])
|
92
|
+
# => {"wizards"=>false, "hobbits"=>true}
|
93
|
+
```
|
94
|
+
|
95
|
+
Curious if there are any user defined chains?
|
96
|
+
|
97
|
+
```ruby
|
98
|
+
Iptablez::Chains.user_defined?
|
99
|
+
# => true
|
100
|
+
```
|
101
|
+
|
102
|
+
Curious if a specific chain(s) has been user defined?
|
103
|
+
|
104
|
+
```ruby
|
105
|
+
Iptablez::Chains.user_defined?(name: "frogs")
|
106
|
+
# => false
|
107
|
+
|
108
|
+
Iptablez::Chains.user_defined?(names: ["wizards", "hobbits"])
|
109
|
+
# => {"wizards"=>true, "hobbits"=>true}
|
110
|
+
```
|
111
|
+
|
112
|
+
TODO add more stuff.
|
113
|
+
|
114
|
+
## 🐚 iptablez-shell
|
115
|
+
|
116
|
+
This is a TODO. Iptablez provides an interactive shell via the `iptablez-shell` command.
|
117
|
+
|
118
|
+
```ruby
|
119
|
+
$ iptablez-shell
|
120
|
+
🦑 ~ (main)> Iptablez.version
|
121
|
+
```
|
122
|
+
|
123
|
+
## 🦑 iptablez-cli
|
124
|
+
|
125
|
+
This is a TODO. Iptablez provides a simple command-line application via the `iptablez-cli` command.
|
126
|
+
|
127
|
+
```shell
|
128
|
+
$ iptablez-cli -h
|
129
|
+
```
|
130
|
+
## iptablez-web
|
131
|
+
|
132
|
+
This is a TODO. Iptablez provides a web application that can be started via the `iptablez-web` command.
|
133
|
+
|
134
|
+
## iptablez-api
|
135
|
+
|
136
|
+
This is a TODO. A simple REST API that can be started via the `iptablez-api` command.
|
137
|
+
|
138
|
+
## License
|
139
|
+
|
140
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
141
|
+
|
data/Rakefile
ADDED
data/Vagrantfile
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
# All Vagrant configuration is done below. The "2" in Vagrant.configure
|
5
|
+
# configures the configuration version (we support older styles for
|
6
|
+
# backwards compatibility). Please don't change it unless you know what
|
7
|
+
# you're doing.
|
8
|
+
Vagrant.configure("2") do |config|
|
9
|
+
# The most common configuration options are documented and commented below.
|
10
|
+
# For a complete reference, please see the online documentation at
|
11
|
+
# https://docs.vagrantup.com.
|
12
|
+
|
13
|
+
# Every Vagrant development environment requires a box. You can search for
|
14
|
+
# boxes at https://atlas.hashicorp.com/search.
|
15
|
+
config.vm.box = "ubuntu/xenial64"
|
16
|
+
|
17
|
+
# Disable automatic box update checking. If you disable this, then
|
18
|
+
# boxes will only be checked for updates when the user runs
|
19
|
+
# `vagrant box outdated`. This is not recommended.
|
20
|
+
# config.vm.box_check_update = false
|
21
|
+
|
22
|
+
# Create a forwarded port mapping which allows access to a specific port
|
23
|
+
# within the machine from a port on the host machine. In the example below,
|
24
|
+
# accessing "localhost:8080" will access port 80 on the guest machine.
|
25
|
+
# config.vm.network "forwarded_port", guest: 80, host: 8080
|
26
|
+
|
27
|
+
# Create a private network, which allows host-only access to the machine
|
28
|
+
# using a specific IP.
|
29
|
+
# config.vm.network "private_network", ip: "192.168.33.10"
|
30
|
+
|
31
|
+
# Create a public network, which generally matched to bridged network.
|
32
|
+
# Bridged networks make the machine appear as another physical device on
|
33
|
+
# your network.
|
34
|
+
# config.vm.network "public_network"
|
35
|
+
|
36
|
+
# Share an additional folder to the guest VM. The first argument is
|
37
|
+
# the path on the host to the actual folder. The second argument is
|
38
|
+
# the path on the guest to mount the folder. And the optional third
|
39
|
+
# argument is a set of non-required options.
|
40
|
+
config.vm.synced_folder ".", "/opt/iptablez"
|
41
|
+
|
42
|
+
# Provider-specific configuration so you can fine-tune various
|
43
|
+
# backing providers for Vagrant. These expose provider-specific options.
|
44
|
+
# Example for VirtualBox:
|
45
|
+
#
|
46
|
+
# config.vm.provider "virtualbox" do |vb|
|
47
|
+
# # Display the VirtualBox GUI when booting the machine
|
48
|
+
# vb.gui = true
|
49
|
+
#
|
50
|
+
# # Customize the amount of memory on the VM:
|
51
|
+
# vb.memory = "1024"
|
52
|
+
# end
|
53
|
+
#
|
54
|
+
# View the documentation for the provider you are using for more
|
55
|
+
# information on available options.
|
56
|
+
|
57
|
+
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
|
58
|
+
# such as FTP and Heroku are also available. See the documentation at
|
59
|
+
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
|
60
|
+
# config.push.define "atlas" do |push|
|
61
|
+
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
|
62
|
+
# end
|
63
|
+
|
64
|
+
# Enable provisioning with a shell script. Additional provisioners such as
|
65
|
+
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
|
66
|
+
# documentation for more information about their specific syntax and use.
|
67
|
+
config.vm.provision "shell", inline: <<-SHELL
|
68
|
+
sudo su root
|
69
|
+
apt-get update
|
70
|
+
apt-get install tmux gnupg2 -y
|
71
|
+
gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
|
72
|
+
curl -L https://get.rvm.io | bash -s stable --ruby
|
73
|
+
echo "source /usr/local/rvm/scripts/rvm" >> ~/.bashrc
|
74
|
+
# vim bruh
|
75
|
+
# coment this stuff out if you don't want to be cool
|
76
|
+
# :)
|
77
|
+
echo "syntax on" >> ~/.vimrc
|
78
|
+
echo "set nu" >> ~/.vimrc
|
79
|
+
echo "set showcmd" >> ~/.vimrc
|
80
|
+
echo "set cursorline" >> ~/.vimrc
|
81
|
+
echo "set wildmenu" >> ~/.vimrc
|
82
|
+
echo "set hlsearch" >> ~/.vimrc
|
83
|
+
echo "set title" >> ~/.vimrc
|
84
|
+
echo "set esckeys" >> ~/.vimrc
|
85
|
+
echo "set showmode" >> ~/.vimrc
|
86
|
+
echo "set nocompatible" >> ~/.vimrc
|
87
|
+
echo "set smartindent" >> ~/.vimrc
|
88
|
+
echo "set ruler" >> ~/.vimrc
|
89
|
+
echo "set noswapfile" >> ~/.vimrc
|
90
|
+
echo "set tabstop=2" >> ~/.vimrc
|
91
|
+
echo "set softtabstop=2" >> ~/.vimrc
|
92
|
+
echo "set shiftround" >> ~/.vimrc
|
93
|
+
echo "set shiftwidth=2" >> ~/.vimrc
|
94
|
+
echo "set expandtab" >> ~/.vimrc
|
95
|
+
echo "highlight LineNr ctermbg=blue" >> ~/.vimrc
|
96
|
+
echo "highlight LineNr ctermfg=cyan" >> ~/.vimrc
|
97
|
+
echo "set spell spelllang=en_us" >> ~/.vimrc
|
98
|
+
echo "set ttyfast" >> ~/.vimrc
|
99
|
+
SHELL
|
100
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "iptablez"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/iptblz.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
#!/usr/bin/env ruby
|
3
|
+
|
4
|
+
require 'iptablez'
|
5
|
+
require 'colorize'
|
6
|
+
require 'pry'
|
7
|
+
|
8
|
+
include Iptablez
|
9
|
+
|
10
|
+
prompt_name = "🦑 #{"~".blue} "
|
11
|
+
|
12
|
+
Pry.config.prompt = [
|
13
|
+
proc { |target_self, nest_level, pry|
|
14
|
+
"#{prompt_name}(#{Pry.view_clip(target_self)})#{":#{nest_level}" unless nest_level.zero?}> "
|
15
|
+
},
|
16
|
+
proc { |target_self, nest_level, pry|
|
17
|
+
"#{prompt_name}(#{Pry.view_clip(target_self)})#{":#{nest_level}" unless nest_level.zero?}* "
|
18
|
+
}
|
19
|
+
]
|
20
|
+
Pry.config.prompt_name = prompt_name
|
21
|
+
Pry.start
|
data/bin/setup
ADDED