junos-config 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +28 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +50 -0
- data/VERSION +1 -0
- data/junos-config.gemspec +67 -0
- data/lib/junos-config.rb +2 -0
- data/lib/junos-config/config.rb +20 -0
- data/lib/junos-config/interface.rb +11 -0
- data/spec/junos-config_spec.rb +43 -0
- data/spec/sample_configs/sample_1 +400 -0
- data/spec/spec_helper.rb +12 -0
- metadata +144 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "rspec", "~> 2.3.0"
|
10
|
+
gem "bundler", "~> 1.0.0"
|
11
|
+
gem "jeweler", "~> 1.5.2"
|
12
|
+
gem "rcov", ">= 0"
|
13
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.1.2)
|
5
|
+
git (1.2.5)
|
6
|
+
jeweler (1.5.2)
|
7
|
+
bundler (~> 1.0.0)
|
8
|
+
git (>= 1.2.5)
|
9
|
+
rake
|
10
|
+
rake (0.8.7)
|
11
|
+
rcov (0.9.8)
|
12
|
+
rspec (2.3.0)
|
13
|
+
rspec-core (~> 2.3.0)
|
14
|
+
rspec-expectations (~> 2.3.0)
|
15
|
+
rspec-mocks (~> 2.3.0)
|
16
|
+
rspec-core (2.3.1)
|
17
|
+
rspec-expectations (2.3.0)
|
18
|
+
diff-lcs (~> 1.1.2)
|
19
|
+
rspec-mocks (2.3.0)
|
20
|
+
|
21
|
+
PLATFORMS
|
22
|
+
ruby
|
23
|
+
|
24
|
+
DEPENDENCIES
|
25
|
+
bundler (~> 1.0.0)
|
26
|
+
jeweler (~> 1.5.2)
|
27
|
+
rcov
|
28
|
+
rspec (~> 2.3.0)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 John Wulff
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= junos-config
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to junos-config
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
+
* Fork the project
|
10
|
+
* Start a feature/bugfix branch
|
11
|
+
* Commit and push until you are happy with your contribution
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2011 John Wulff. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'rake'
|
11
|
+
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |gem|
|
14
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
+
gem.name = "junos-config"
|
16
|
+
gem.homepage = "http://github.com/jwulff/junos-config"
|
17
|
+
gem.license = "MIT"
|
18
|
+
gem.summary = %Q{Parser for Junos config files.}
|
19
|
+
gem.description = %Q{Parser for Junos (Juniper network gear OS) config files.}
|
20
|
+
gem.email = "johnw@orcasnet.com"
|
21
|
+
gem.authors = ["John Wulff"]
|
22
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
23
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
24
|
+
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
25
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
require 'rspec/core'
|
30
|
+
require 'rspec/core/rake_task'
|
31
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
32
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
33
|
+
end
|
34
|
+
|
35
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
36
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
37
|
+
spec.rcov = true
|
38
|
+
end
|
39
|
+
|
40
|
+
task :default => :spec
|
41
|
+
|
42
|
+
require 'rake/rdoctask'
|
43
|
+
Rake::RDocTask.new do |rdoc|
|
44
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
45
|
+
|
46
|
+
rdoc.rdoc_dir = 'rdoc'
|
47
|
+
rdoc.title = "junos-config #{version}"
|
48
|
+
rdoc.rdoc_files.include('README*')
|
49
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
50
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{junos-config}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["John Wulff"]
|
12
|
+
s.date = %q{2011-03-29}
|
13
|
+
s.description = %q{Parser for Junos (Juniper network gear OS) config files.}
|
14
|
+
s.email = %q{johnw@orcasnet.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".rspec",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"junos-config.gemspec",
|
29
|
+
"lib/junos-config.rb",
|
30
|
+
"lib/junos-config/config.rb",
|
31
|
+
"lib/junos-config/interface.rb",
|
32
|
+
"spec/junos-config_spec.rb",
|
33
|
+
"spec/sample_configs/sample_1",
|
34
|
+
"spec/spec_helper.rb"
|
35
|
+
]
|
36
|
+
s.homepage = %q{http://github.com/jwulff/junos-config}
|
37
|
+
s.licenses = ["MIT"]
|
38
|
+
s.require_paths = ["lib"]
|
39
|
+
s.rubygems_version = %q{1.6.2}
|
40
|
+
s.summary = %q{Parser for Junos config files.}
|
41
|
+
s.test_files = [
|
42
|
+
"spec/junos-config_spec.rb",
|
43
|
+
"spec/spec_helper.rb"
|
44
|
+
]
|
45
|
+
|
46
|
+
if s.respond_to? :specification_version then
|
47
|
+
s.specification_version = 3
|
48
|
+
|
49
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
50
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
|
51
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
52
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
53
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
54
|
+
else
|
55
|
+
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
56
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
57
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
58
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
59
|
+
end
|
60
|
+
else
|
61
|
+
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
62
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
63
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
64
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
data/lib/junos-config.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module JunosConfig
|
2
|
+
class Config
|
3
|
+
attr_reader :config,
|
4
|
+
:interfaces
|
5
|
+
|
6
|
+
def initialize(config)
|
7
|
+
@config = config
|
8
|
+
config.scan(/^(\w+)\ \{$(.*?)^\}$/m).each do |section|
|
9
|
+
method = "parse_#{section[0]}"
|
10
|
+
send method, section[1] if respond_to?(method)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def parse_interfaces(raw)
|
15
|
+
@interfaces = raw.scan(/^(\ {4}\S+\ \{$.*?^\ {4}\})$/m).collect do |section|
|
16
|
+
Interface.new section[0]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
ROOT = File.expand_path(File.dirname(__FILE__))
|
2
|
+
require File.join(ROOT, 'spec_helper')
|
3
|
+
SAMPLE_1 = File.read(File.join(ROOT, 'sample_configs', 'sample_1')).freeze
|
4
|
+
|
5
|
+
describe JunosConfig do
|
6
|
+
describe Config do
|
7
|
+
describe 'initialized with sample config 1' do
|
8
|
+
before :each do
|
9
|
+
@config = JunosConfig::Config.new SAMPLE_1
|
10
|
+
end
|
11
|
+
it 'should have 9 interfaces' do
|
12
|
+
@config.interfaces.size.should == 9
|
13
|
+
end
|
14
|
+
describe 'interface 0' do
|
15
|
+
it 'should be named ge-0/0/0' do @config.interfaces[0].name.should == 'ge-0/0/0' end
|
16
|
+
end
|
17
|
+
describe 'interface 1' do
|
18
|
+
it 'should be named ge-0/0/1' do @config.interfaces[1].name.should == 'ge-0/0/1' end
|
19
|
+
end
|
20
|
+
describe 'interface 2' do
|
21
|
+
it 'should be named ge-2/0/0' do @config.interfaces[2].name.should == 'ge-2/0/0' end
|
22
|
+
end
|
23
|
+
describe 'interface 3' do
|
24
|
+
it 'should be named ge-2/0/1' do @config.interfaces[3].name.should == 'ge-2/0/1' end
|
25
|
+
end
|
26
|
+
describe 'interface 4' do
|
27
|
+
it 'should be named fab0' do @config.interfaces[4].name.should == 'fab0' end
|
28
|
+
end
|
29
|
+
describe 'interface 5' do
|
30
|
+
it 'should be named fab1' do @config.interfaces[5].name.should == 'fab1' end
|
31
|
+
end
|
32
|
+
describe 'interface 6' do
|
33
|
+
it 'should be named reth0' do @config.interfaces[6].name.should == 'reth0' end
|
34
|
+
end
|
35
|
+
describe 'interface 7' do
|
36
|
+
it 'should be named reth1' do @config.interfaces[7].name.should == 'reth1' end
|
37
|
+
end
|
38
|
+
describe 'interface 8' do
|
39
|
+
it 'should be named st0' do @config.interfaces[8].name.should == 'st0' end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,400 @@
|
|
1
|
+
## Last commit: 2011-03-08 09:56:15 PST by root
|
2
|
+
version 10.3R1.9;
|
3
|
+
groups {
|
4
|
+
node0 {
|
5
|
+
system {
|
6
|
+
host-name test-srx-1;
|
7
|
+
}
|
8
|
+
interfaces {
|
9
|
+
fxp0 {
|
10
|
+
unit 0 {
|
11
|
+
family inet {
|
12
|
+
address 10.0.2.253/24;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}
|
18
|
+
node1 {
|
19
|
+
system {
|
20
|
+
host-name test-srx-2;
|
21
|
+
}
|
22
|
+
interfaces {
|
23
|
+
fxp0 {
|
24
|
+
unit 0 {
|
25
|
+
family inet {
|
26
|
+
address 10.0.2.254/24;
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
apply-groups "${node}";
|
34
|
+
system {
|
35
|
+
host-name test-srx;
|
36
|
+
time-zone America/Los_Angeles;
|
37
|
+
name-server {
|
38
|
+
208.67.222.222;
|
39
|
+
208.67.220.220;
|
40
|
+
}
|
41
|
+
services {
|
42
|
+
ssh;
|
43
|
+
web-management {
|
44
|
+
http {
|
45
|
+
interface reth1.0;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|
49
|
+
syslog {
|
50
|
+
archive size 100k files 3;
|
51
|
+
user * {
|
52
|
+
any emergency;
|
53
|
+
}
|
54
|
+
file messages {
|
55
|
+
any critical;
|
56
|
+
authorization info;
|
57
|
+
}
|
58
|
+
file interactive-commands {
|
59
|
+
interactive-commands error;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
max-configurations-on-flash 5;
|
63
|
+
max-configuration-rollbacks 5;
|
64
|
+
license {
|
65
|
+
autoupdate {
|
66
|
+
url https://ae1.juniper.net/junos/key_retrieval;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
ntp {
|
70
|
+
server 66.36.239.104;
|
71
|
+
}
|
72
|
+
}
|
73
|
+
chassis {
|
74
|
+
cluster {
|
75
|
+
control-link-recovery;
|
76
|
+
reth-count 8;
|
77
|
+
heartbeat-interval 2000;
|
78
|
+
heartbeat-threshold 8;
|
79
|
+
redundancy-group 0 {
|
80
|
+
node 0 priority 100;
|
81
|
+
node 1 priority 90;
|
82
|
+
}
|
83
|
+
redundancy-group 1 {
|
84
|
+
node 0 priority 100;
|
85
|
+
node 1 priority 90;
|
86
|
+
interface-monitor {
|
87
|
+
ge-0/0/0 weight 255;
|
88
|
+
ge-2/0/0 weight 255;
|
89
|
+
ge-2/0/1 weight 255;
|
90
|
+
ge-0/0/1 weight 255;
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
}
|
95
|
+
interfaces {
|
96
|
+
ge-0/0/0 {
|
97
|
+
gigether-options {
|
98
|
+
redundant-parent reth0;
|
99
|
+
}
|
100
|
+
}
|
101
|
+
ge-0/0/1 {
|
102
|
+
gigether-options {
|
103
|
+
redundant-parent reth1;
|
104
|
+
}
|
105
|
+
}
|
106
|
+
ge-2/0/0 {
|
107
|
+
gigether-options {
|
108
|
+
redundant-parent reth0;
|
109
|
+
}
|
110
|
+
}
|
111
|
+
ge-2/0/1 {
|
112
|
+
gigether-options {
|
113
|
+
redundant-parent reth1;
|
114
|
+
}
|
115
|
+
}
|
116
|
+
fab0 {
|
117
|
+
fabric-options {
|
118
|
+
member-interfaces {
|
119
|
+
fe-0/0/5;
|
120
|
+
}
|
121
|
+
}
|
122
|
+
}
|
123
|
+
fab1 {
|
124
|
+
fabric-options {
|
125
|
+
member-interfaces {
|
126
|
+
fe-2/0/5;
|
127
|
+
}
|
128
|
+
}
|
129
|
+
}
|
130
|
+
reth0 {
|
131
|
+
redundant-ether-options {
|
132
|
+
redundancy-group 1;
|
133
|
+
}
|
134
|
+
unit 0 {
|
135
|
+
family inet {
|
136
|
+
address 9.9.5.181/28;
|
137
|
+
}
|
138
|
+
}
|
139
|
+
}
|
140
|
+
reth1 {
|
141
|
+
redundant-ether-options {
|
142
|
+
redundancy-group 1;
|
143
|
+
}
|
144
|
+
unit 0 {
|
145
|
+
family inet {
|
146
|
+
address 10.0.2.1/24;
|
147
|
+
}
|
148
|
+
}
|
149
|
+
}
|
150
|
+
st0 {
|
151
|
+
unit 0 {
|
152
|
+
multipoint;
|
153
|
+
family inet {
|
154
|
+
address 10.254.254.2/24;
|
155
|
+
}
|
156
|
+
}
|
157
|
+
}
|
158
|
+
}
|
159
|
+
routing-options {
|
160
|
+
static {
|
161
|
+
route 0.0.0.0/0 next-hop 9.9.5.177;
|
162
|
+
}
|
163
|
+
}
|
164
|
+
protocols {
|
165
|
+
ospf {
|
166
|
+
area 0.0.0.0 {
|
167
|
+
interface reth1.0;
|
168
|
+
interface st0.0 {
|
169
|
+
interface-type p2mp;
|
170
|
+
dynamic-neighbors;
|
171
|
+
}
|
172
|
+
}
|
173
|
+
}
|
174
|
+
}
|
175
|
+
security {
|
176
|
+
nat {
|
177
|
+
source {
|
178
|
+
rule-set trust-to-untrust {
|
179
|
+
from zone trust;
|
180
|
+
to zone untrust;
|
181
|
+
rule source-nat-rule {
|
182
|
+
match {
|
183
|
+
source-address 0.0.0.0/0;
|
184
|
+
}
|
185
|
+
then {
|
186
|
+
source-nat {
|
187
|
+
interface;
|
188
|
+
}
|
189
|
+
}
|
190
|
+
}
|
191
|
+
}
|
192
|
+
}
|
193
|
+
static {
|
194
|
+
rule-set static_untrust {
|
195
|
+
from zone untrust;
|
196
|
+
rule voip2 {
|
197
|
+
match {
|
198
|
+
destination-address 9.9.5.179/32;
|
199
|
+
}
|
200
|
+
then {
|
201
|
+
static-nat prefix 10.0.2.3/32;
|
202
|
+
}
|
203
|
+
}
|
204
|
+
rule voip1 {
|
205
|
+
match {
|
206
|
+
destination-address 9.9.5.178/32;
|
207
|
+
}
|
208
|
+
then {
|
209
|
+
static-nat prefix 10.0.2.2/32;
|
210
|
+
}
|
211
|
+
}
|
212
|
+
rule test-rails {
|
213
|
+
match {
|
214
|
+
destination-address 9.9.5.183/32;
|
215
|
+
}
|
216
|
+
then {
|
217
|
+
static-nat prefix 10.0.2.4/32;
|
218
|
+
}
|
219
|
+
}
|
220
|
+
}
|
221
|
+
}
|
222
|
+
proxy-arp {
|
223
|
+
interface reth0.0 {
|
224
|
+
address {
|
225
|
+
9.9.5.179/32;
|
226
|
+
9.9.5.178/32;
|
227
|
+
9.9.5.183/32;
|
228
|
+
}
|
229
|
+
}
|
230
|
+
}
|
231
|
+
}
|
232
|
+
screen {
|
233
|
+
ids-option untrust-screen {
|
234
|
+
icmp {
|
235
|
+
ping-death;
|
236
|
+
}
|
237
|
+
ip {
|
238
|
+
source-route-option;
|
239
|
+
tear-drop;
|
240
|
+
}
|
241
|
+
tcp {
|
242
|
+
syn-flood {
|
243
|
+
alarm-threshold 1024;
|
244
|
+
attack-threshold 200;
|
245
|
+
source-threshold 1024;
|
246
|
+
destination-threshold 2048;
|
247
|
+
timeout 20;
|
248
|
+
}
|
249
|
+
land;
|
250
|
+
}
|
251
|
+
}
|
252
|
+
}
|
253
|
+
zones {
|
254
|
+
security-zone trust {
|
255
|
+
address-book {
|
256
|
+
address voip1 10.0.2.2/32;
|
257
|
+
address voip2 10.0.2.3/32;
|
258
|
+
address test-rails 10.0.2.4/32;
|
259
|
+
}
|
260
|
+
host-inbound-traffic {
|
261
|
+
system-services {
|
262
|
+
all;
|
263
|
+
}
|
264
|
+
protocols {
|
265
|
+
all;
|
266
|
+
}
|
267
|
+
}
|
268
|
+
interfaces {
|
269
|
+
reth1.0;
|
270
|
+
}
|
271
|
+
}
|
272
|
+
security-zone untrust {
|
273
|
+
screen untrust-screen;
|
274
|
+
interfaces {
|
275
|
+
reth0.0 {
|
276
|
+
host-inbound-traffic {
|
277
|
+
system-services {
|
278
|
+
ike;
|
279
|
+
ping;
|
280
|
+
ssh;
|
281
|
+
}
|
282
|
+
}
|
283
|
+
}
|
284
|
+
}
|
285
|
+
}
|
286
|
+
security-zone vpn {
|
287
|
+
host-inbound-traffic {
|
288
|
+
system-services {
|
289
|
+
all;
|
290
|
+
}
|
291
|
+
protocols {
|
292
|
+
all;
|
293
|
+
}
|
294
|
+
}
|
295
|
+
interfaces {
|
296
|
+
st0.0;
|
297
|
+
}
|
298
|
+
}
|
299
|
+
}
|
300
|
+
policies {
|
301
|
+
from-zone trust to-zone untrust {
|
302
|
+
policy trust-to-untrust {
|
303
|
+
match {
|
304
|
+
source-address any;
|
305
|
+
destination-address any;
|
306
|
+
application any;
|
307
|
+
}
|
308
|
+
then {
|
309
|
+
permit;
|
310
|
+
}
|
311
|
+
}
|
312
|
+
}
|
313
|
+
from-zone vpn to-zone trust {
|
314
|
+
policy FromVPN {
|
315
|
+
match {
|
316
|
+
source-address any;
|
317
|
+
destination-address any;
|
318
|
+
application any;
|
319
|
+
}
|
320
|
+
then {
|
321
|
+
permit;
|
322
|
+
}
|
323
|
+
}
|
324
|
+
}
|
325
|
+
from-zone trust to-zone vpn {
|
326
|
+
policy ToVpn {
|
327
|
+
match {
|
328
|
+
source-address any;
|
329
|
+
destination-address any;
|
330
|
+
application any;
|
331
|
+
}
|
332
|
+
then {
|
333
|
+
permit;
|
334
|
+
}
|
335
|
+
}
|
336
|
+
}
|
337
|
+
from-zone vpn to-zone vpn {
|
338
|
+
policy vpn-to-vpn {
|
339
|
+
match {
|
340
|
+
source-address any;
|
341
|
+
destination-address any;
|
342
|
+
application any;
|
343
|
+
}
|
344
|
+
then {
|
345
|
+
permit;
|
346
|
+
}
|
347
|
+
}
|
348
|
+
}
|
349
|
+
from-zone untrust to-zone trust {
|
350
|
+
policy voip {
|
351
|
+
match {
|
352
|
+
source-address any;
|
353
|
+
destination-address [ voip1 voip2 ];
|
354
|
+
application [ junos-sip custom-rtp junos-ping junos-ssh ];
|
355
|
+
}
|
356
|
+
then {
|
357
|
+
permit;
|
358
|
+
}
|
359
|
+
}
|
360
|
+
policy test-rails {
|
361
|
+
match {
|
362
|
+
source-address any;
|
363
|
+
destination-address test-rails;
|
364
|
+
application [ junos-http junos-https junos-ping junos-ssh ];
|
365
|
+
}
|
366
|
+
then {
|
367
|
+
permit;
|
368
|
+
}
|
369
|
+
}
|
370
|
+
}
|
371
|
+
}
|
372
|
+
traceoptions {
|
373
|
+
file security size 10k files 2 world-readable;
|
374
|
+
}
|
375
|
+
alg {
|
376
|
+
dns disable;
|
377
|
+
ftp disable;
|
378
|
+
h323 disable;
|
379
|
+
mgcp disable;
|
380
|
+
msrpc disable;
|
381
|
+
sunrpc disable;
|
382
|
+
real disable;
|
383
|
+
rsh disable;
|
384
|
+
rtsp disable;
|
385
|
+
sccp disable;
|
386
|
+
sip disable;
|
387
|
+
sql disable;
|
388
|
+
talk disable;
|
389
|
+
tftp disable;
|
390
|
+
pptp disable;
|
391
|
+
}
|
392
|
+
}
|
393
|
+
applications {
|
394
|
+
application custom-rtp {
|
395
|
+
protocol udp;
|
396
|
+
destination-port 5000-31000;
|
397
|
+
}
|
398
|
+
}
|
399
|
+
|
400
|
+
{primary:node0}
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'junos-config'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: junos-config
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- John Wulff
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-03-29 00:00:00 -07:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
hash: 3
|
28
|
+
segments:
|
29
|
+
- 2
|
30
|
+
- 3
|
31
|
+
- 0
|
32
|
+
version: 2.3.0
|
33
|
+
name: rspec
|
34
|
+
version_requirements: *id001
|
35
|
+
prerelease: false
|
36
|
+
type: :development
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 23
|
44
|
+
segments:
|
45
|
+
- 1
|
46
|
+
- 0
|
47
|
+
- 0
|
48
|
+
version: 1.0.0
|
49
|
+
name: bundler
|
50
|
+
version_requirements: *id002
|
51
|
+
prerelease: false
|
52
|
+
type: :development
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ~>
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 7
|
60
|
+
segments:
|
61
|
+
- 1
|
62
|
+
- 5
|
63
|
+
- 2
|
64
|
+
version: 1.5.2
|
65
|
+
name: jeweler
|
66
|
+
version_requirements: *id003
|
67
|
+
prerelease: false
|
68
|
+
type: :development
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
hash: 3
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
version: "0"
|
79
|
+
name: rcov
|
80
|
+
version_requirements: *id004
|
81
|
+
prerelease: false
|
82
|
+
type: :development
|
83
|
+
description: Parser for Junos (Juniper network gear OS) config files.
|
84
|
+
email: johnw@orcasnet.com
|
85
|
+
executables: []
|
86
|
+
|
87
|
+
extensions: []
|
88
|
+
|
89
|
+
extra_rdoc_files:
|
90
|
+
- LICENSE.txt
|
91
|
+
- README.rdoc
|
92
|
+
files:
|
93
|
+
- .document
|
94
|
+
- .rspec
|
95
|
+
- Gemfile
|
96
|
+
- Gemfile.lock
|
97
|
+
- LICENSE.txt
|
98
|
+
- README.rdoc
|
99
|
+
- Rakefile
|
100
|
+
- VERSION
|
101
|
+
- junos-config.gemspec
|
102
|
+
- lib/junos-config.rb
|
103
|
+
- lib/junos-config/config.rb
|
104
|
+
- lib/junos-config/interface.rb
|
105
|
+
- spec/junos-config_spec.rb
|
106
|
+
- spec/sample_configs/sample_1
|
107
|
+
- spec/spec_helper.rb
|
108
|
+
has_rdoc: true
|
109
|
+
homepage: http://github.com/jwulff/junos-config
|
110
|
+
licenses:
|
111
|
+
- MIT
|
112
|
+
post_install_message:
|
113
|
+
rdoc_options: []
|
114
|
+
|
115
|
+
require_paths:
|
116
|
+
- lib
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
none: false
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
hash: 3
|
123
|
+
segments:
|
124
|
+
- 0
|
125
|
+
version: "0"
|
126
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
hash: 3
|
132
|
+
segments:
|
133
|
+
- 0
|
134
|
+
version: "0"
|
135
|
+
requirements: []
|
136
|
+
|
137
|
+
rubyforge_project:
|
138
|
+
rubygems_version: 1.6.2
|
139
|
+
signing_key:
|
140
|
+
specification_version: 3
|
141
|
+
summary: Parser for Junos config files.
|
142
|
+
test_files:
|
143
|
+
- spec/junos-config_spec.rb
|
144
|
+
- spec/spec_helper.rb
|