From f59706a4b1a309f6c3e614ded7cbd359335e7960 Mon Sep 17 00:00:00 2001 From: irregulator Date: Wed, 21 May 2014 01:36:30 +0300 Subject: Add two macros, base32_secret and obfs_port, used in obfsproxy --- lib/leap_cli/config/macros.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/leap_cli/config/macros.rb b/lib/leap_cli/config/macros.rb index c6938fe..241a2a4 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 obfs_port(name, range) + @manager.secrets.set(name, rand(range), @node[:environment]) + end + # # inserts an hexidecimal secret string, generating it if needed. # -- cgit v1.2.3