Commit 39d8d005 authored by Antoine Catton's avatar Antoine Catton

Final improvement of stunnel recipe

parent db1dc523
...@@ -24,44 +24,25 @@ ...@@ -24,44 +24,25 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# #
############################################################################## ##############################################################################
import itertools
import zc.buildout
from slapos.recipe.librecipe import GenericBaseRecipe from slapos.recipe.librecipe import GenericBaseRecipe
class Recipe(GenericBaseRecipe): class Recipe(GenericBaseRecipe):
def _options(self, options): def _options(self, options):
self.types = ['local', 'remote']
self.datas = ['address', 'port']
for type_ in self.types:
for data in self.datas:
opt = '%s-%s' % (type_, data)
if opt not in options:
raise zc.buildout.UserError("No %s for %s connections." % (data, type_))
self.isClient = self.optionIsTrue('client', default=False) self.isClient = self.optionIsTrue('client', default=False)
if self.isClient: if self.isClient:
self.logger.info("Client mode") self.logger.info("Client mode")
else: else:
self.logger.info("Server mode") self.logger.info("Server mode")
if 'name' not in options:
options['name'] = self.name
def install(self): def install(self):
path_list = [] path_list = []
conf = {} conf = {}
gathered_options = ['%s-%s' % option for type_ in ['remote', 'local']:
for option in itertools.product(self.types, for data in ['host', 'port']:
self.datas)] confkey, opt = ['%s%s%s' % (type_, i, data) for i in ['_', '-']]
for option in gathered_options: conf[confkey] = self.options[opt]
# XXX: Because the options are using dash and the template uses
# underscore
conf[option.replace('-', '_')] = self.options[option]
pid_file = self.options['pid-file'] pid_file = self.options['pid-file']
conf.update(pid_file=pid_file) conf.update(pid_file=pid_file)
......
...@@ -6,5 +6,5 @@ key = %(key)s ...@@ -6,5 +6,5 @@ key = %(key)s
cert = %(cert)s cert = %(cert)s
[service] [service]
accept = %(remote_address)s:%(remote_port)s accept = %(remote_host)s:%(remote_port)s
connect = %(local_address)s:%(local_port)s connect = %(local_host)s:%(local_port)s
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment