summaryrefslogtreecommitdiff
path: root/lib/leap_cli/leapfile.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/leap_cli/leapfile.rb')
-rw-r--r--lib/leap_cli/leapfile.rb26
1 files changed, 24 insertions, 2 deletions
diff --git a/lib/leap_cli/leapfile.rb b/lib/leap_cli/leapfile.rb
index 439b60c..c24f939 100644
--- a/lib/leap_cli/leapfile.rb
+++ b/lib/leap_cli/leapfile.rb
@@ -15,6 +15,11 @@ module LeapCli
attr_accessor :custom_vagrant_vm_line
attr_accessor :leap_version
attr_accessor :log
+ attr_accessor :vagrant_network
+
+ def initialize
+ @vagrant_network = '10.5.5.0/24'
+ end
def load
directory = File.expand_path(find_in_directory_tree('Leapfile'))
@@ -22,8 +27,8 @@ module LeapCli
return nil
else
self.provider_directory_path = directory
- leapfile = directory + '/Leapfile'
- instance_eval(File.read(leapfile), leapfile)
+ read_settings(directory + '/Leapfile')
+ read_settings(ENV['HOME'] + '/.leaprc')
self.platform_directory_path = File.expand_path(self.platform_directory_path || '../leap_platform', self.provider_directory_path)
return true
end
@@ -31,6 +36,14 @@ module LeapCli
private
+ def read_settings(file)
+ if File.exists? file
+ Util::log 2, :read, file
+ instance_eval(File.read(file), file)
+ validate(file)
+ end
+ end
+
def find_in_directory_tree(filename)
search_dir = Dir.pwd
while search_dir != "/"
@@ -41,6 +54,15 @@ module LeapCli
end
return search_dir
end
+
+ PRIVATE_IP_RANGES = /(^127\.0\.0\.1)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^192\.168\.)/
+
+ def validate(file)
+ Util::assert! vagrant_network =~ PRIVATE_IP_RANGES do
+ Util::log 0, :error, "in #{file}: vagrant_network is not a local private network"
+ end
+ end
+
end
end