vpnmaker 0.0.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +10 -6
- data/VERSION +1 -1
- data/bin/vpnmaker +258 -7
- data/lib/client.haml +49 -9
- data/{foocorp.config.yaml → lib/example_vpnmaker_site.config.yaml} +14 -12
- data/lib/server.haml +32 -6
- data/lib/vpnmaker.rb +9 -7
- data/lib/vpnmaker/config_generator.rb +24 -6
- data/lib/vpnmaker/key_builder.rb +1 -1
- data/lib/vpnmaker/key_db.rb +1 -1
- data/lib/vpnmaker/key_tracker.rb +2 -0
- data/lib/vpnmaker/manager.rb +1 -1
- data/vpnmaker.gemspec +12 -15
- metadata +10 -26
data/Gemfile
CHANGED
@@ -8,7 +8,7 @@ group :development do
|
|
8
8
|
gem 'pry-syntax-hacks' #, :git => 'https://github.com/ConradIrwin/pry-syntax-hacks.git'
|
9
9
|
gem 'pry-stack_explorer' #, :git => 'https://github.com/pry/pry-stack_explorer.git'
|
10
10
|
gem 'pry-exception_explorer' #, :git => 'https://github.com/pry/pry-exception_explorer.git'
|
11
|
-
gem "rdoc"
|
11
|
+
gem "rdoc" #, "~> 3.12"
|
12
12
|
gem "bundler" #, "~> 1.0.0"
|
13
13
|
gem "jeweler" #, "~> 1.8.3"
|
14
14
|
end
|
@@ -17,9 +17,13 @@ gem 'ipaddr_extensions'
|
|
17
17
|
#, :git => 'git://github.com/jamesotron/IPAddrExtensions.git'
|
18
18
|
|
19
19
|
gem 'haml'
|
20
|
-
gem '
|
21
|
-
gem 'gibberish', :git => 'git://github.com/mdp/gibberish.git'
|
22
|
-
gem 'rubyzip', :git => 'git://github.com/aussiegeek/rubyzip.git'
|
23
|
-
# gem 'slim'
|
20
|
+
gem 'main', :git => 'git://github.com/ahoward/main.git'
|
24
21
|
|
25
|
-
#
|
22
|
+
#gem 'hashugar', :git => 'git://github.com/jsuchal/hashugar.git'
|
23
|
+
gem 'highline' #, :git => 'https://github.com/JEG2/highline.git'
|
24
|
+
|
25
|
+
#gem 'rbcurse-core', :git => 'git://github.com/rkumar/rbcurse-core.git'
|
26
|
+
#gem 'rbcurse-extras', :git => 'git://github.com/rkumar/rbcurse-extras.git'
|
27
|
+
|
28
|
+
# gem 'gibberish', :git => 'git://github.com/mdp/gibberish.git'
|
29
|
+
# gem 'rubyzip', :git => 'git://github.com/aussiegeek/rubyzip.git'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
1.0.0
|
data/bin/vpnmaker
CHANGED
@@ -1,11 +1,262 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require_relative '../lib/vpnmaker.rb'
|
3
|
-
require '
|
3
|
+
#require 'micro-optparse'
|
4
|
+
#require 'highline'
|
5
|
+
require 'highline/import'
|
6
|
+
require 'main'
|
4
7
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
#TODO: use ~/.vpnmaker .vpnmaker and /etc/vpnmaker | maybe vpnmakerrc
|
9
|
+
module VPNMaker
|
10
|
+
module CLI
|
11
|
+
module RFC822
|
12
|
+
EmailAddress = begin
|
13
|
+
qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]'
|
14
|
+
dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]'
|
15
|
+
atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-' +
|
16
|
+
'\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+'
|
17
|
+
quoted_pair = '\\x5c[\\x00-\\x7f]'
|
18
|
+
domain_literal = "\\x5b(?:#{dtext}|#{quoted_pair})*\\x5d"
|
19
|
+
quoted_string = "\\x22(?:#{qtext}|#{quoted_pair})*\\x22"
|
20
|
+
domain_ref = atom
|
21
|
+
sub_domain = "(?:#{domain_ref}|#{domain_literal})"
|
22
|
+
word = "(?:#{atom}|#{quoted_string})"
|
23
|
+
domain = "#{sub_domain}(?:\\x2e#{sub_domain})*"
|
24
|
+
local_part = "#{word}(?:\\x2e#{word})*"
|
25
|
+
addr_spec = "#{local_part}\\x40#{domain}"
|
26
|
+
pattern = /\A#{addr_spec.force_encoding('ASCII-8BIT')}\z/
|
27
|
+
end
|
28
|
+
end
|
10
29
|
|
11
|
-
|
30
|
+
class Options
|
31
|
+
# main DSL
|
32
|
+
Main do
|
33
|
+
version '0.0.1'
|
34
|
+
author 'Copyleft(cl) VoipScout - No rights reserved'
|
35
|
+
|
36
|
+
mode('init') {
|
37
|
+
mode('cli') {
|
38
|
+
argument('country') {
|
39
|
+
required
|
40
|
+
cast :string
|
41
|
+
arity 1
|
42
|
+
}
|
43
|
+
argument('province') {
|
44
|
+
required
|
45
|
+
cast :string
|
46
|
+
arity 1
|
47
|
+
}
|
48
|
+
argument('city') {
|
49
|
+
required
|
50
|
+
cast :string
|
51
|
+
arity 1
|
52
|
+
}
|
53
|
+
argument('organization') {
|
54
|
+
required
|
55
|
+
cast :string
|
56
|
+
arity 1
|
57
|
+
}
|
58
|
+
argument('email') {
|
59
|
+
required
|
60
|
+
cast :string
|
61
|
+
arity 1
|
62
|
+
validate {|e| e =~ RFC822::EmailAddress}
|
63
|
+
}
|
64
|
+
|
65
|
+
} #mode 'cli'
|
66
|
+
|
67
|
+
argument('conf_name') {
|
68
|
+
required
|
69
|
+
cast :string
|
70
|
+
arity 1
|
71
|
+
}
|
72
|
+
argument('new_dir_path') {
|
73
|
+
required
|
74
|
+
cast :string
|
75
|
+
arity 1
|
76
|
+
validate {|dir| File.directory?(File.expand_path(dir))}
|
77
|
+
}
|
78
|
+
def run
|
79
|
+
name = params['conf_name'].value
|
80
|
+
dir = params['new_dir_path'].value
|
81
|
+
|
82
|
+
VPNMaker.generate name, dir
|
83
|
+
|
84
|
+
data_dir = (File.expand_path(dir) + "/" + name + ".vpn" + "/" + name + "_data")
|
85
|
+
template_dir = (File.expand_path(dir) + "/" + name + ".vpn" + "/" + name + "_templates")
|
86
|
+
client_config_dir = (File.expand_path(dir) + "/" + name + ".vpn" + "/" + name + "_client_configs")
|
87
|
+
|
88
|
+
[data_dir, template_dir, client_config_dir].each {|dir| FileUtils.mkdir_p(dir)}
|
89
|
+
lib_dir = File.dirname(File.expand_path __FILE__).gsub('/bin', '/lib')
|
90
|
+
FileUtils.cp Dir.glob(lib_dir + "/*.haml"), template_dir
|
91
|
+
|
92
|
+
if params['email'].given?
|
93
|
+
initial_config = {
|
94
|
+
:key_properties => {
|
95
|
+
:country => params['country'].value,
|
96
|
+
:province => params['province'].value,
|
97
|
+
:city => params['city'].value,
|
98
|
+
:organization => params['organization'].value,
|
99
|
+
:email => params['email'].value
|
100
|
+
},
|
101
|
+
:site => {
|
102
|
+
:data_dir => data_dir.split('/').last,
|
103
|
+
:template_dir => template_dir.split('/').last,
|
104
|
+
:client_conf_dir => client_config_dir.split('/').last
|
105
|
+
}
|
106
|
+
}
|
107
|
+
example_config = YAML.load_file(lib_dir + "/example_vpnmaker_site.config.yaml").to_yaml.gsub(/\n|---/, "\n# ")
|
108
|
+
File.open((File.expand_path(dir) + "/" + name + ".vpn" + "/" + name + ".config.yaml"), 'w') {|f| f.write(initial_config.to_yaml + example_config)}
|
109
|
+
mgr = VPNMaker::Manager.new((File.expand_path(dir) + "/" + name + ".vpn"))
|
110
|
+
mgr.build_ca
|
111
|
+
say("Please edit files in #{template_dir} and #{dir}/#{name}.vpn/#{name}.config.yaml before proceeding further")
|
112
|
+
else
|
113
|
+
say('Time to mod yaml files')
|
114
|
+
end
|
115
|
+
end
|
116
|
+
}
|
117
|
+
|
118
|
+
mode('server') {
|
119
|
+
mode('build') {
|
120
|
+
def run
|
121
|
+
db.build_server
|
122
|
+
say('Please edit your config.yaml if you haven\'t done so yet')
|
123
|
+
end
|
124
|
+
}
|
125
|
+
mode('config') {
|
126
|
+
def run
|
127
|
+
puts db.config_generator.server
|
128
|
+
end
|
129
|
+
}
|
130
|
+
keyword('dir') {
|
131
|
+
required
|
132
|
+
arity 1
|
133
|
+
cast :string
|
134
|
+
description "ie. /my/config/vpnmaker.vpn"
|
135
|
+
validate {|dir_name| File.directory?(File.expand_path(dir_name))}
|
136
|
+
}
|
137
|
+
|
138
|
+
argument('server_config_name') {
|
139
|
+
description "filename to save server configuration to"
|
140
|
+
argument :optional
|
141
|
+
cast :string
|
142
|
+
arity -1
|
143
|
+
#TODO: highline, how to not crlf after #agree
|
144
|
+
validate {|fname| File.exist?(fname) ? agree("file exists, overwrite?") : true }
|
145
|
+
}
|
146
|
+
def run
|
147
|
+
|
148
|
+
puts "server run..."
|
149
|
+
puts "need to save fname=#{params['server_config_fname'].value}" if params['server_config_fname'].given?
|
150
|
+
end
|
151
|
+
}
|
152
|
+
|
153
|
+
mode('client') {
|
154
|
+
|
155
|
+
mode('list') {
|
156
|
+
description "ie. vpnmaker clients list"
|
157
|
+
def run
|
158
|
+
pp db.users.select {|u| !db.user(u)[:revoked].include?(db.user(u)[:active_key])}
|
159
|
+
# db.users.each{|u| puts db.user(u)}
|
160
|
+
end
|
161
|
+
}
|
162
|
+
|
163
|
+
mode('config') {
|
164
|
+
def run
|
165
|
+
params['client_name'].values.each do |c|
|
166
|
+
puts db.config_generator.client(db.user(c))
|
167
|
+
end
|
168
|
+
end
|
169
|
+
}
|
170
|
+
|
171
|
+
mode('create') {
|
172
|
+
keyword('passwd') {
|
173
|
+
argument :optional
|
174
|
+
cast :string
|
175
|
+
arity 1
|
176
|
+
default 'passwd'
|
177
|
+
}
|
178
|
+
|
179
|
+
def run
|
180
|
+
params['client_name'].values.each_with_index do |c, i|
|
181
|
+
passwd = params['passwd'].values[i] ? params['passwd'].values[i] : params['passwd'].default
|
182
|
+
db.create_user(c, c, "#{c}@#{db.config[:key_properties][:email].split('@').last}", passwd) if db.users.select {|r| r =~ /#{c}/}.empty?
|
183
|
+
end
|
184
|
+
end
|
185
|
+
}
|
186
|
+
|
187
|
+
mode('destroy') {
|
188
|
+
option('all') {
|
189
|
+
argument :optional
|
190
|
+
cast :bool
|
191
|
+
}
|
192
|
+
def run
|
193
|
+
if params['all'].value
|
194
|
+
db.users.each {|u| db.delete_user(u)} unless db.users.size == 0
|
195
|
+
else
|
196
|
+
params['client_name'].values.each do |c|
|
197
|
+
db.delete_user(c) unless !db.user(c)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
}
|
202
|
+
|
203
|
+
mode('regenerate') {
|
204
|
+
keyword('passwd') {
|
205
|
+
argument :optional
|
206
|
+
cast :string
|
207
|
+
arity 1
|
208
|
+
default 'passwd'
|
209
|
+
}
|
210
|
+
|
211
|
+
def run
|
212
|
+
params['client_name'].values.each_with_index do |c, i|
|
213
|
+
passwd = params['passwd'].values[i] ? params['passwd'].values[i] : params['passwd'].default
|
214
|
+
db.regenerate_user(c, passwd)
|
215
|
+
end
|
216
|
+
end
|
217
|
+
}
|
218
|
+
|
219
|
+
argument('client_name') {
|
220
|
+
argument :optional
|
221
|
+
arity -1
|
222
|
+
cast :string
|
223
|
+
#synopsis 'client_name'
|
224
|
+
description "username"
|
225
|
+
# validate {|name| ? YAML.load_file(path) : {}}
|
226
|
+
}
|
227
|
+
# environment('VPNMAKER_DIR')
|
228
|
+
keyword('dir') {
|
229
|
+
required
|
230
|
+
arity 1
|
231
|
+
cast :string
|
232
|
+
description "ie. /my/config/vpnmaker.vpn"
|
233
|
+
validate {|dir_name| File.directory?(File.expand_path(dir_name))}
|
234
|
+
}
|
235
|
+
|
236
|
+
def run
|
237
|
+
puts "client run"
|
238
|
+
end
|
239
|
+
|
240
|
+
}
|
241
|
+
|
242
|
+
# Global run() is overwritten by specific mode run
|
243
|
+
def run
|
244
|
+
puts "Hitting global run()"
|
245
|
+
params.each {|p| pp "#{p.class} - #{p.name} => #{p.value}"}
|
246
|
+
@opts = params
|
247
|
+
pp @opts
|
248
|
+
end
|
249
|
+
|
250
|
+
def db
|
251
|
+
VPNMaker::Manager.new params['dir'].value
|
252
|
+
end
|
253
|
+
|
254
|
+
|
255
|
+
end #
|
256
|
+
|
257
|
+
end #class Options
|
258
|
+
|
259
|
+
end #module CLI
|
260
|
+
end #module VPNMaker
|
261
|
+
|
262
|
+
VPNMaker::CLI::Options.new
|
data/lib/client.haml
CHANGED
@@ -1,13 +1,53 @@
|
|
1
|
+
client
|
2
|
+
dev tun
|
3
|
+
proto udp
|
1
4
|
remote #{server[:host]} #{server[:port]} udp
|
5
|
+
remote-random
|
6
|
+
resolv-retry infinite
|
7
|
+
nobind
|
2
8
|
persist-key
|
3
|
-
tls-client
|
4
|
-
tls-auth ta.key 1
|
5
|
-
pull
|
6
|
-
ca ca.crt
|
7
|
-
dev tun
|
8
9
|
persist-tun
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
remote
|
10
|
+
\#
|
11
|
+
\#tls-remote must equal CN of ca in the hosts x509
|
12
|
+
\#
|
13
|
+
tls-remote #{server[:host]}
|
14
|
+
|
15
|
+
float
|
16
|
+
cipher AES-256-CBC
|
17
|
+
comp-lzo
|
18
|
+
verb 3
|
19
|
+
ping 30
|
20
|
+
|
21
|
+
- if type == :default
|
22
|
+
<dh>
|
23
|
+
#{dh}
|
24
|
+
</dh>
|
25
|
+
|
26
|
+
<ca>
|
27
|
+
#{ca}
|
28
|
+
</ca>
|
29
|
+
|
30
|
+
<cert>
|
31
|
+
#{cert}
|
32
|
+
</cert>
|
33
|
+
|
34
|
+
<key>
|
35
|
+
#{key}
|
36
|
+
</key>
|
37
|
+
|
38
|
+
<tls-auth>
|
39
|
+
#{ta}
|
40
|
+
</tls-auth>
|
41
|
+
|
42
|
+
- else
|
43
|
+
tls-client
|
44
|
+
tls-auth ta.key 1
|
45
|
+
pull
|
46
|
+
ca ca.crt
|
47
|
+
dev tun
|
48
|
+
persist-tun
|
49
|
+
cert #{user}-#{(revoked.max || - 1) + 1}.crt
|
50
|
+
nobind
|
51
|
+
key #{user}-#{(revoked.max || - 1) + 1}.key
|
52
|
+
remote-cert-tls server
|
13
53
|
:plain
|
@@ -1,24 +1,26 @@
|
|
1
|
+
---
|
2
|
+
:key_properties:
|
3
|
+
:country: US
|
4
|
+
:province: CA
|
5
|
+
:city: San Francisco
|
6
|
+
:organization: myorg
|
7
|
+
:email: security@my.org
|
8
|
+
|
1
9
|
:server:
|
2
|
-
:base_ip: 10.10.10.0
|
10
|
+
:base_ip: 10.10.10.0/24
|
3
11
|
:bridgednets: # real networks to bridge via the VPN server
|
4
|
-
- 172.16.0.0
|
12
|
+
- 172.16.0.0/24
|
5
13
|
:subnets: # subnets that exist only on the VPN
|
6
|
-
- 10.10.11.0
|
14
|
+
- 10.10.11.0/8
|
15
|
+
- 10.11.2.0/24
|
7
16
|
:user: nobody
|
8
17
|
:group: nogroup
|
9
|
-
:root: /
|
18
|
+
:root: /etc/openvpn
|
10
19
|
:log: /var/log/openvpn.log
|
11
|
-
:host:
|
20
|
+
:host: staging.pvstream.in
|
12
21
|
:port: 1194
|
13
22
|
|
14
23
|
:client:
|
15
24
|
:subnet: 172.16.0.0
|
16
25
|
:local_endpoint: 10.10.10.100
|
17
26
|
:remote_endpoint: 10.10.10.1
|
18
|
-
|
19
|
-
:key_properties:
|
20
|
-
:country: US
|
21
|
-
:province: CA
|
22
|
-
:city: San Francisco
|
23
|
-
:organization: FooCorp Inc
|
24
|
-
:email: sec@foocorp.com
|
data/lib/server.haml
CHANGED
@@ -20,11 +20,38 @@ server #{base_ip[:net]} #{base_ip[:mask]}
|
|
20
20
|
\
|
21
21
|
user #{user}
|
22
22
|
group #{group}
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
- if type == :default
|
24
|
+
|
25
|
+
<dh>
|
26
|
+
#{dh}
|
27
|
+
</dh>
|
28
|
+
|
29
|
+
<ca>
|
30
|
+
#{ca}
|
31
|
+
</ca>
|
32
|
+
|
33
|
+
<cert>
|
34
|
+
#{cert}
|
35
|
+
</cert>
|
36
|
+
|
37
|
+
<key>
|
38
|
+
#{key}
|
39
|
+
</key>
|
40
|
+
|
41
|
+
<crl-verify>
|
42
|
+
#{crl}
|
43
|
+
</crl-verify>
|
44
|
+
|
45
|
+
<ta>
|
46
|
+
#{ta}
|
47
|
+
</ta>
|
48
|
+
|
49
|
+
- else
|
50
|
+
dh #{root}/keys/dh.pem
|
51
|
+
ca #{root}/keys/ca.crt
|
52
|
+
cert #{root}/keys/server.crt
|
53
|
+
key #{root}/keys/server.key
|
54
|
+
crl-verify #{root}/keys/crl.pem
|
28
55
|
|
29
56
|
keepalive 10 120
|
30
57
|
|
@@ -34,5 +61,4 @@ persist-tun
|
|
34
61
|
persist-key
|
35
62
|
|
36
63
|
tls-auth #{root}/keys/ta.key 0
|
37
|
-
client-config-dir #{root}/ccd
|
38
64
|
:plain
|
data/lib/vpnmaker.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
|
3
3
|
require 'gibberish'
|
4
|
-
require 'rubyzip'
|
4
|
+
# require 'rubyzip'
|
5
5
|
|
6
6
|
require 'fileutils'
|
7
7
|
require 'yaml'
|
@@ -32,12 +32,14 @@ class HashBinding < Object
|
|
32
32
|
end
|
33
33
|
|
34
34
|
module VPNMaker
|
35
|
-
|
36
|
-
|
37
|
-
autoload :
|
38
|
-
autoload :
|
39
|
-
autoload :
|
40
|
-
autoload :
|
35
|
+
path = (File.dirname File.expand_path(__FILE__)) + "/"
|
36
|
+
|
37
|
+
autoload :ConfigGenerator, "#{path}vpnmaker/config_generator"
|
38
|
+
autoload :KeyDB, "#{path}vpnmaker/key_db"
|
39
|
+
autoload :KeyConfig, "#{path}vpnmaker/key_config"
|
40
|
+
autoload :KeyTracker, "#{path}vpnmaker/key_tracker"
|
41
|
+
autoload :Manager, "#{path}vpnmaker/manager"
|
42
|
+
autoload :KeyBuilder, "#{path}vpnmaker/key_builder"
|
41
43
|
|
42
44
|
def self.generate(*args)
|
43
45
|
KeyTracker.generate(args.first, args.last)
|
@@ -1,21 +1,34 @@
|
|
1
1
|
module VPNMaker
|
2
2
|
class ConfigGenerator
|
3
|
-
def initialize(
|
4
|
-
@mgr =
|
3
|
+
def initialize(*args)
|
4
|
+
@mgr = args.shift.first
|
5
|
+
args.empty? ? (@runtime_cfg = default_template) : (@runtime_cfg = args.shift)
|
5
6
|
end
|
6
7
|
|
8
|
+
def default_template
|
9
|
+
@dirname = (@mgr.tracker.path + "/" + @mgr.config[:site][:data_dir])
|
10
|
+
{
|
11
|
+
:type => :default,
|
12
|
+
:dh => File.read(@dirname + "/dh.pem"),
|
13
|
+
:ca => File.read(@dirname + "/ca.crt"),
|
14
|
+
:ta => File.read(@dirname + "/ta.key")
|
15
|
+
}
|
16
|
+
end
|
7
17
|
def client_conf(client)
|
8
18
|
{
|
9
19
|
:gen_host => Socket.gethostname,
|
10
20
|
:server => @mgr.config[:server],
|
11
21
|
:client => @mgr.config[:client]
|
12
|
-
}.merge(client)
|
22
|
+
}.merge(client).merge(:key => File.read(@dirname + "/#{client[:user]}-#{(client[:revoked].max || - 1) + 1}.key" ),
|
23
|
+
:cert => File.read(@dirname + "/#{client[:user]}-#{(client[:revoked].max || - 1) + 1}.crt")).merge(@runtime_cfg)
|
13
24
|
end
|
14
25
|
|
15
26
|
def server_conf
|
16
27
|
{
|
17
28
|
:gen_host => Socket.gethostname
|
18
|
-
}.merge(@mgr.config[:server])
|
29
|
+
}.merge(@mgr.config[:server]).merge(@runtime_cfg).merge(:key => File.read(@dirname + "/server.key"),
|
30
|
+
:cert => File.read(@dirname + "/server.crt"),
|
31
|
+
:crl => File.read(@dirname + "/crl.pem"))
|
19
32
|
end
|
20
33
|
|
21
34
|
def server
|
@@ -23,13 +36,18 @@ module VPNMaker
|
|
23
36
|
haml_vars[:base_ip] = ((a = IPAddr.new haml_vars[:base_ip]); {:net => a.to_s, :mask => a.subnet_mask.to_s})
|
24
37
|
haml_vars[:bridgednets] = haml_vars[:bridgednets].map {|net| a = (IPAddr.new net); {:net => a.to_s, :mask => a.subnet_mask.to_s}}
|
25
38
|
haml_vars[:subnets] = haml_vars[:subnets].map {|net| a = (IPAddr.new net); {:net => a.to_s, :mask => a.subnet_mask.to_s}}
|
26
|
-
template = File.read(
|
39
|
+
template = File.read(@mgr.tracker.path + \
|
40
|
+
"/" + @mgr.config[:site][:template_dir] + \
|
41
|
+
"/" + 'server.haml')
|
27
42
|
Haml::Engine.new(template).render(Object.new, haml_vars)
|
28
43
|
end
|
29
44
|
|
30
45
|
def client(client)
|
31
46
|
haml_vars = client_conf(client).dup
|
32
|
-
template = File.read(
|
47
|
+
template = File.read(@mgr.tracker.path + \
|
48
|
+
"/" + @mgr.config[:site][:template_dir] + \
|
49
|
+
"/" + 'client.haml')
|
50
|
+
# template = File.read(__FILE__.path('client.haml'))
|
33
51
|
Haml::Engine.new(template).render(Object.new, haml_vars)
|
34
52
|
end
|
35
53
|
end
|
data/lib/vpnmaker/key_builder.rb
CHANGED
@@ -39,7 +39,7 @@ module VPNMaker
|
|
39
39
|
c = cnfpath
|
40
40
|
|
41
41
|
File.open(cnfpath, 'w') do |f|
|
42
|
-
f.write(Haml::Engine.new(File.read
|
42
|
+
f.write(Haml::Engine.new(File.read(@tracker.path + "/" + @config[:site][:template_dir] + "/" + 'openssl.haml')).render(Object.new, opensslvars.merge(hash)))
|
43
43
|
end
|
44
44
|
|
45
45
|
c
|
data/lib/vpnmaker/key_db.rb
CHANGED
data/lib/vpnmaker/key_tracker.rb
CHANGED
@@ -3,6 +3,7 @@ module VPNMaker
|
|
3
3
|
attr_reader :builder
|
4
4
|
attr_reader :db
|
5
5
|
attr_reader :config
|
6
|
+
attr_reader :path
|
6
7
|
|
7
8
|
def self.generate(name, path=nil)
|
8
9
|
path ||= '/tmp'
|
@@ -146,6 +147,7 @@ module VPNMaker
|
|
146
147
|
def users; @db[:users]; end
|
147
148
|
|
148
149
|
def initialize(name, dir)
|
150
|
+
@path = dir
|
149
151
|
@db = KeyDB.new(File.join(dir, name + '.db.yaml'))
|
150
152
|
@config = KeyConfig.new(File.join(dir, name + '.config.yaml'))
|
151
153
|
@builder = KeyBuilder.new(self, @config)
|
data/lib/vpnmaker/manager.rb
CHANGED
data/vpnmaker.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "vpnmaker"
|
8
|
-
s.version = "
|
8
|
+
s.version = "1.0.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Voip Scout"]
|
12
|
-
s.date = "2012-05-
|
12
|
+
s.date = "2012-05-09"
|
13
13
|
s.description = "haml templates and key tracking"
|
14
14
|
s.email = "voipscout@gmail.com"
|
15
15
|
s.executables = ["vpnmaker"]
|
@@ -23,8 +23,8 @@ Gem::Specification.new do |s|
|
|
23
23
|
"Rakefile",
|
24
24
|
"VERSION",
|
25
25
|
"bin/vpnmaker",
|
26
|
-
"foocorp.config.yaml",
|
27
26
|
"lib/client.haml",
|
27
|
+
"lib/example_vpnmaker_site.config.yaml",
|
28
28
|
"lib/openssl.haml",
|
29
29
|
"lib/server.haml",
|
30
30
|
"lib/vpnmaker.rb",
|
@@ -48,9 +48,8 @@ Gem::Specification.new do |s|
|
|
48
48
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
49
49
|
s.add_runtime_dependency(%q<ipaddr_extensions>, [">= 0"])
|
50
50
|
s.add_runtime_dependency(%q<haml>, [">= 0"])
|
51
|
-
s.add_runtime_dependency(%q<
|
52
|
-
s.add_runtime_dependency(%q<
|
53
|
-
s.add_runtime_dependency(%q<rubyzip>, [">= 0"])
|
51
|
+
s.add_runtime_dependency(%q<main>, [">= 0"])
|
52
|
+
s.add_runtime_dependency(%q<highline>, [">= 0"])
|
54
53
|
s.add_development_dependency(%q<pry>, [">= 0"])
|
55
54
|
s.add_development_dependency(%q<pry-doc>, [">= 0"])
|
56
55
|
s.add_development_dependency(%q<pry-rails>, [">= 0"])
|
@@ -58,15 +57,14 @@ Gem::Specification.new do |s|
|
|
58
57
|
s.add_development_dependency(%q<pry-syntax-hacks>, [">= 0"])
|
59
58
|
s.add_development_dependency(%q<pry-stack_explorer>, [">= 0"])
|
60
59
|
s.add_development_dependency(%q<pry-exception_explorer>, [">= 0"])
|
61
|
-
s.add_development_dependency(%q<rdoc>, ["
|
60
|
+
s.add_development_dependency(%q<rdoc>, [">= 0"])
|
62
61
|
s.add_development_dependency(%q<bundler>, [">= 0"])
|
63
62
|
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
64
63
|
else
|
65
64
|
s.add_dependency(%q<ipaddr_extensions>, [">= 0"])
|
66
65
|
s.add_dependency(%q<haml>, [">= 0"])
|
67
|
-
s.add_dependency(%q<
|
68
|
-
s.add_dependency(%q<
|
69
|
-
s.add_dependency(%q<rubyzip>, [">= 0"])
|
66
|
+
s.add_dependency(%q<main>, [">= 0"])
|
67
|
+
s.add_dependency(%q<highline>, [">= 0"])
|
70
68
|
s.add_dependency(%q<pry>, [">= 0"])
|
71
69
|
s.add_dependency(%q<pry-doc>, [">= 0"])
|
72
70
|
s.add_dependency(%q<pry-rails>, [">= 0"])
|
@@ -74,16 +72,15 @@ Gem::Specification.new do |s|
|
|
74
72
|
s.add_dependency(%q<pry-syntax-hacks>, [">= 0"])
|
75
73
|
s.add_dependency(%q<pry-stack_explorer>, [">= 0"])
|
76
74
|
s.add_dependency(%q<pry-exception_explorer>, [">= 0"])
|
77
|
-
s.add_dependency(%q<rdoc>, ["
|
75
|
+
s.add_dependency(%q<rdoc>, [">= 0"])
|
78
76
|
s.add_dependency(%q<bundler>, [">= 0"])
|
79
77
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
80
78
|
end
|
81
79
|
else
|
82
80
|
s.add_dependency(%q<ipaddr_extensions>, [">= 0"])
|
83
81
|
s.add_dependency(%q<haml>, [">= 0"])
|
84
|
-
s.add_dependency(%q<
|
85
|
-
s.add_dependency(%q<
|
86
|
-
s.add_dependency(%q<rubyzip>, [">= 0"])
|
82
|
+
s.add_dependency(%q<main>, [">= 0"])
|
83
|
+
s.add_dependency(%q<highline>, [">= 0"])
|
87
84
|
s.add_dependency(%q<pry>, [">= 0"])
|
88
85
|
s.add_dependency(%q<pry-doc>, [">= 0"])
|
89
86
|
s.add_dependency(%q<pry-rails>, [">= 0"])
|
@@ -91,7 +88,7 @@ Gem::Specification.new do |s|
|
|
91
88
|
s.add_dependency(%q<pry-syntax-hacks>, [">= 0"])
|
92
89
|
s.add_dependency(%q<pry-stack_explorer>, [">= 0"])
|
93
90
|
s.add_dependency(%q<pry-exception_explorer>, [">= 0"])
|
94
|
-
s.add_dependency(%q<rdoc>, ["
|
91
|
+
s.add_dependency(%q<rdoc>, [">= 0"])
|
95
92
|
s.add_dependency(%q<bundler>, [">= 0"])
|
96
93
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
97
94
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vpnmaker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ipaddr_extensions
|
@@ -44,7 +44,7 @@ dependencies:
|
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
|
-
name:
|
47
|
+
name: main
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
49
49
|
none: false
|
50
50
|
requirements:
|
@@ -60,23 +60,7 @@ dependencies:
|
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ! '>='
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
70
|
-
type: :runtime
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ! '>='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '0'
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: rubyzip
|
63
|
+
name: highline
|
80
64
|
requirement: !ruby/object:Gem::Requirement
|
81
65
|
none: false
|
82
66
|
requirements:
|
@@ -208,17 +192,17 @@ dependencies:
|
|
208
192
|
requirement: !ruby/object:Gem::Requirement
|
209
193
|
none: false
|
210
194
|
requirements:
|
211
|
-
- -
|
195
|
+
- - ! '>='
|
212
196
|
- !ruby/object:Gem::Version
|
213
|
-
version: '
|
197
|
+
version: '0'
|
214
198
|
type: :development
|
215
199
|
prerelease: false
|
216
200
|
version_requirements: !ruby/object:Gem::Requirement
|
217
201
|
none: false
|
218
202
|
requirements:
|
219
|
-
- -
|
203
|
+
- - ! '>='
|
220
204
|
- !ruby/object:Gem::Version
|
221
|
-
version: '
|
205
|
+
version: '0'
|
222
206
|
- !ruby/object:Gem::Dependency
|
223
207
|
name: bundler
|
224
208
|
requirement: !ruby/object:Gem::Requirement
|
@@ -265,8 +249,8 @@ files:
|
|
265
249
|
- Rakefile
|
266
250
|
- VERSION
|
267
251
|
- bin/vpnmaker
|
268
|
-
- foocorp.config.yaml
|
269
252
|
- lib/client.haml
|
253
|
+
- lib/example_vpnmaker_site.config.yaml
|
270
254
|
- lib/openssl.haml
|
271
255
|
- lib/server.haml
|
272
256
|
- lib/vpnmaker.rb
|
@@ -292,7 +276,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
292
276
|
version: '0'
|
293
277
|
segments:
|
294
278
|
- 0
|
295
|
-
hash: -
|
279
|
+
hash: -4049670178564647437
|
296
280
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
297
281
|
none: false
|
298
282
|
requirements:
|