This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2gobroker. commit f3bb32d68de84542083ceec093ee0f1ce8cc1333 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Thu Sep 11 20:59:46 2014 +0200 Move split_host_address() code into x2gobroker.utils. --- bin/x2gobroker | 19 ++----------------- debian/changelog | 1 + x2gobroker/utils.py | 29 +++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/bin/x2gobroker b/bin/x2gobroker index 12ea764..f9c878f 100755 --- a/bin/x2gobroker +++ b/bin/x2gobroker @@ -95,7 +95,7 @@ except ImportError: from x2gobroker import __VERSION__ from x2gobroker import __AUTHOR__ from x2gobroker.loggers import logger_broker, logger_access, logger_error, tornado_log_request -from x2gobroker.utils import drop_privileges +from x2gobroker.utils import drop_privileges, split_host_address interactive_mode_warning = False # check effective UID the broker runs as and complain appropriately... @@ -240,22 +240,7 @@ if __name__ == "__main__": if not daemon_logdir.endswith('/'): daemon_logdir += '/' - # some people just give the port but prepend a colon, webpy does not like this, so we strip if off - cmdline_args.bind = cmdline_args.bind.lstrip('*') - cmdline_args.bind = cmdline_args.bind.lstrip(':') - - if ':' in cmdline_args.bind: - bind_address, bind_port = cmdline_args.bind.rsplit(':', 1) - try: - bind_port = int(bind_port) - except TypeError: - # obviously we split an IPv6 address - bind_address = cmdline_args.bind - bind_port = 22 - else: - bind_address = "0.0.0.0" - bind_port = int(cmdline_args.bind) - bind_address = bind_address.lstrip('[').rstrip(']') + bind_address, bind_port = x2gobroker.utils.split_host_address(cmdline_args.bind, default_address="0.0.0.0") cmdline_args.bind = "[{address}]:{port}".format(address=bind_address, port=bind_port) urls = () diff --git a/debian/changelog b/debian/changelog index 141d2ee..e7d18e7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -150,6 +150,7 @@ x2gobroker (0.0.3.0-0x2go1) UNRELEASED; urgency=low performing the query. - Make sure bind_address and bind_port are correctly detected from /etc/default/x2gobroker-daemon and /etc/x2go/broker/defaults.cfg. + - Move split_host_address() code into x2gobroker.utils. * debian/control: + Provide separate bin:package for SSH brokerage: x2gobroker-ssh. + Replace LDAP support with session brokerage support in LONG_DESCRIPTION. diff --git a/x2gobroker/utils.py b/x2gobroker/utils.py index 8baaed4..f296b03 100644 --- a/x2gobroker/utils.py +++ b/x2gobroker/utils.py @@ -192,3 +192,32 @@ def drop_privileges(uid, gid): # set the new user's home directory as $HOME os.environ['HOME'] = pwd.getpwnam(uid).pw_dir + +def split_host_address(host, default_address=None, default_port=22): + + # do some stripping first... + host = host.strip() + host = host.lstrip('*') + host = host.lstrip(':') + + if ':' in host: + bind_address, bind_port = host.rsplit(':', 1) + try: + bind_port = int(bind_port) + except TypeError: + # obviously we split an IPv6 address + bind_address = host + bind_port = 22 + else: + if default_address is not None: + bind_address = default_address + bind_port = int(host) + elif default_port is not None: + bind_address = host + bind_port = default_port + else: + bind_address = host + bind_port = 0 + bind_address = bind_address.lstrip('[').rstrip(']') + + return bind_address, bind_port -- Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/x2gobroker.git