aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2014-05-21 18:07:11 -0700
committerelijah <elijah@riseup.net>2014-05-21 18:07:11 -0700
commit300e794099ca2c402618e7f17b7279ad6b6f34c5 (patch)
tree083e4d96512f1ed7782e5f2a135cfee1413ea370
parent894cc96b149363208bb86ffe035699e6648351e0 (diff)
parent91f32c7261a4c1d5a8a2e00100fbc8ee577aa0ac (diff)
downloadleap_cli-300e794099ca2c402618e7f17b7279ad6b6f34c5.tar.gz
leap_cli-300e794099ca2c402618e7f17b7279ad6b6f34c5.tar.bz2
Merge branch 'feature/obfsproxy_macros' of https://github.com/irregulator/leap_cli
-rw-r--r--leap_cli.gemspec1
-rw-r--r--lib/leap_cli/config/macros.rb12
2 files changed, 13 insertions, 0 deletions
diff --git a/leap_cli.gemspec b/leap_cli.gemspec
index 829309a..d0b9a99 100644
--- a/leap_cli.gemspec
+++ b/leap_cli.gemspec
@@ -70,6 +70,7 @@ spec = Gem::Specification.new do |s|
s.add_runtime_dependency('ya2yaml') # pure ruby yaml, so we can better control output. see https://github.com/afunai/ya2yaml
s.add_runtime_dependency('json_pure') # pure ruby json, so we can better control output.
s.add_runtime_dependency('versionomy') # compare version strings
+ s.add_runtime_dependency('base32') # base32 encoding
##
## DEPENDENCIES for VENDORED GEMS
diff --git a/lib/leap_cli/config/macros.rb b/lib/leap_cli/config/macros.rb
index 63dce97..2eabdd0 100644
--- a/lib/leap_cli/config/macros.rb
+++ b/lib/leap_cli/config/macros.rb
@@ -6,6 +6,8 @@
# This module is included in Config::Object
#
+require 'base32'
+
module LeapCli; module Config
module Macros
##
@@ -130,6 +132,16 @@ module LeapCli; module Config
@manager.secrets.set(name, Util::Secret.generate(length), @node[:environment])
end
+ # inserts a base32 encoded secret
+ def base32_secret(name, length=20)
+ @manager.secrets.set(name, Base32.encode(Util::Secret.generate(length)), @node[:environment])
+ end
+
+ # Picks a random obfsproxy port from given range
+ def rand_range(name, range)
+ @manager.secrets.set(name, rand(range), @node[:environment])
+ end
+
#
# inserts an hexidecimal secret string, generating it if needed.
#