Beispiel #1
0
    def __init__(self, name, app_dict, appnode_catchall, ipfilters):
        if not nginx_util.looks_like_app_name(name):
            raise ValueError("Invalid application name: %s", name)
        self.name = name
        self.server_name = [util.HostIPPort(server_name)
                            for server_name in util.flatten(app_dict.pop('fqdn'))]
        self.catchall = appnode_catchall[app_dict.pop('catchall')]

        runtime_port = app_dict.pop('runtime_port', None)
        if runtime_port is not None:
            if not nginx_util.looks_like_port(runtime_port):
                raise ValueError("Invalid runtime port: %s", runtime_port)
            self.runtime_port = int(runtime_port)
        else:
            self.runtime_port = None

        self.staticfilexas = app_dict.pop('staticfilexas', True)
        self.mxclientsystem = app_dict.pop('mxclientsystem', None)
        self.x_frame_options = app_dict.pop('x_frame_options', None)
        self.authenticate = app_dict.pop('authenticate', 'none')
        self.mobile = app_dict.pop('mobile', None)

        if 'ipfilter' in app_dict:
            self.ipfilter = ipfilters[app_dict.pop('ipfilter')]
        else:
            self.ipfilter = None

        if 'root' in app_dict:
            self.root = app_dict.pop('root')
            if not nginx_util.looks_like_path(self.root):
                raise ValueError("Invalid root path: %s" % self.root)
        else:
            self.root = None

        if 'index' in app_dict:
            self.index = app_dict.pop('index')
            if not nginx_util.looks_like_index_html(self.index):
                raise ValueError("Invalid index name: %s" % self.index)
        else:
            self.index = None

        self.backup_servers = app_dict.pop('backup_server', [])

        self.client_max_body_size = app_dict.pop('client_max_body_size', '1G')
        if not nginx_util.looks_like_offset_number(self.client_max_body_size):
            raise ValueError("Invalid size for client_max_body_size: %s" %
                             self.client_max_body_size)

        self.unavailable = app_dict.pop('unavailable', False)
        if not isinstance(self.unavailable, bool):
            raise ValueError("unavailable option needs True or False as value, "
                             "%s given" % self.unavailable)

        self.request_handler = []
        for suburl, rh_dict in app_dict.pop('request_handler', {}).items():
            self.request_handler.append(AppnodeAppRequestHandler(suburl, rh_dict, ipfilters))
Beispiel #2
0
    def __init__(self, name, catchall_dict):
        self.name = name
        port = catchall_dict.pop('port')
        # see 1b4fefc only for multiple slot appnode bork:
        if isinstance(port, list):
            port = port[0]
        if not nginx_util.looks_like_port(port):
            raise ValueError("Invalid port: %s", port)
        self.port = int(port)

        self.listen = [
            util.HostIPPort('[::]:%s' % self.port),
            util.HostIPPort('0.0.0.0:%s' % self.port),
        ]