Add an rule to csf allowed hosts
    See :func:`_access_rule`.
    1- Add an IP:
    CLI Example:

    .. code-block:: bash

        salt '*' csf.allow 127.0.0.1
        salt '*' csf.allow 127.0.0.1 comment="Allow localhost"
773849
def allow(ip,
        port=None,
        proto='tcp',
        direction='in',
        port_origin='d',
        ip_origin='s',
        ttl=None,
        comment=''):
    '''
    
    '''
    return _access_rule('allow',
                        ip,
                        port=port,
                        proto=proto,
                        direction=direction,
                        port_origin=port_origin,
                        ip_origin=ip_origin,
                        comment=comment)
321655
def save(filename=None, family='ipv4'):
    '''
    
    '''
    if _conf() and not filename:
        filename = _conf(family)

    log.debug('Saving rules to %s', filename)

    parent_dir = os.path.dirname(filename)
    if not os.path.isdir(parent_dir):
        os.makedirs(parent_dir)
    cmd = '{0}-save'.format(_iptables_cmd(family))
    ipt = __salt__['cmd.run'](cmd)

    # regex out the output if configured with filters
    if _conf_save_filters():
        ipt = _regex_iptables_save(ipt)

    out = __salt__['file.write'](filename, ipt)
    return out
120027
private void setCorsPolicy(String bucketName, List<String> allowedOrigins, String dcHost) {
        // If list is null or empty, add a default value
        if (null == allowedOrigins || allowedOrigins.isEmpty()) {
            allowedOrigins = new ArrayList<>();
            allowedOrigins.add("https://*");
        } else { // If list is not empty, append DuraCloud host to allow streaming via DurAdmin
            allowedOrigins.add("https://" + dcHost);
        }

        List<CORSRule> corsRules = new ArrayList<>();

        for (String allowedOrigin : allowedOrigins) {
            CORSRule corsRule = new CORSRule();
            corsRule.setAllowedOrigins(allowedOrigin);
            corsRule.setAllowedMethods(CORSRule.AllowedMethods.GET, CORSRule.AllowedMethods.HEAD);
            corsRule.setMaxAgeSeconds(3000);
            corsRule.setAllowedHeaders("*");
            corsRules.add(corsRule);
        }

        BucketCrossOriginConfiguration corsConfig =
            new BucketCrossOriginConfiguration().withRules(corsRules);

        s3Client.setBucketCrossOriginConfiguration(bucketName, corsConfig);
    }
508290
def add_host(zone, name, ttl, ip, keyname, keyfile, nameserver, timeout,
             port=53, keyalgorithm='hmac-md5'):
    '''
    
    '''
    res = []
    if zone in name:
        name = name.replace(zone, '').rstrip('.')
    fqdn = '{0}.{1}'.format(name, zone)

    ret = create(zone, name, ttl, 'A', ip, keyname, keyfile, nameserver,
                 timeout, port, keyalgorithm)
    res.append(ret[fqdn])

    parts = ip.split('.')[::-1]
    i = len(parts)
    popped = []

    # Iterate over possible reverse zones
    while i > 1:
        p = parts.pop(0)
        i -= 1
        popped.append(p)

        zone = '{0}.{1}'.format('.'.join(parts), 'in-addr.arpa.')
        name = '.'.join(popped)
        rev_fqdn = '{0}.{1}'.format(name, zone)
        ret = create(zone, name, ttl, 'PTR', "{0}.".format(fqdn), keyname,
                     keyfile, nameserver, timeout, port, keyalgorithm)

        if "Created" in ret[rev_fqdn]:
            res.append(ret[rev_fqdn])
            return {fqdn: res}

    res.append(ret[rev_fqdn])

    return {fqdn: res}
546248
def allow_cors(func):
    """"""
    def wrapper(*args, **kwargs):
        response.headers['Access-Control-Allow-Origin'] = '*'
        response.headers['Access-Control-Allow-Methods'] = \
            'PUT, GET, POST, DELETE, OPTIONS'
        response.headers['Access-Control-Allow-Headers'] = \
            'Origin, Accept, Content-Type, X-Requested-With, X-CSRF-Token'
        return func(*args, **kwargs)
    return wrapper
799697
def _client_allowed(self):
    """"""
    client_ip = self._client_address[0]
    if not client_ip in self._settings.allowed_clients and \
       not 'ALL' in self._settings.allowed_clients:
      content = 'Access from host {} forbidden.'.format(client_ip).encode('utf-8')
      self._send_content(content, 'text/html')
      return False
    return True
306708
public static function allowCors()
    {
        $origin = filter_input(INPUT_SERVER, 'HTTP_ORIGIN');
        $protocol = filter_input(INPUT_SERVER, 'REQUEST_SCHEME') ?? 'http';
        $host = preg_replace("/^http(s)?:\/{2}/", "", $origin);
        $allowedHosts = cfg::ALLOW_CORS;
        $allowedHosts[] = cfg::HOST_DEV;

        if (in_array($host, $allowedHosts)) {
            header("Access-Control-Allow-Origin: " . $protocol . "://" . $host);
        }
    }
716063
def add_url_rule(self, rule, endpoint=None, view_func=None, roles=None, **options):
        
        super().add_url_rule(rule, endpoint, view_func, **options)

        if roles:
            self.add_access_controller(
                endpoint, allow_access_for_roles(roles), endpoint=True
            )
88203
def console_host(self, new_host):
        
        server_config = Config.instance().get_section_config("Server")
        remote_console_connections = server_config.getboolean("allow_remote_console")
        if remote_console_connections:
            log.warning("Remote console connections are allowed")
            self._console_host = "0.0.0.0"
        else:
            self._console_host = new_host
161488
def add(alias_name, user, host, options)
      begin
        PRINTER.verbose_print "Adding\n"
        config_append = form(alias_name, user, host, options)
        PRINTER.verbose_print config_append
        unless options.test
          file = File.open(FILE_PATH, 'a+')
          file.write(config_append)
          file.close

          # causes a bug in fedore if permission was not updated to 0600
          File.chmod(0600, FILE_PATH)
          # system "chmod 600 #{FILE_PATH}"
        end
      rescue
        return permission_error
      end
      PRINTER.verbose_print "to #{FILE_PATH}"
      PRINTER.print "Successfully added `#{alias_name}` as an alias for `#{user}@#{host}`"
      PRINTER.print "Try sshez connect #{alias_name}"

      finish_exec
    end
721326
def add_access_policy_filter(request, query, column_name):
    
    q = d1_gmn.app.models.Subject.objects.filter(
        subject__in=request.all_subjects_set
    ).values('permission__sciobj')
    filter_arg = '{}__in'.format(column_name)
    return query.filter(**{filter_arg: q})
510081
def allow_ip(*ips: typing.Union[str, ipaddress.IPv4Network, ipaddress.IPv4Address]):
    
    for ip in ips:
        if isinstance(ip, ipaddress.IPv4Address):
            allowed_ips.add(ip)
        elif isinstance(ip, str):
            allowed_ips.add(ipaddress.IPv4Address(ip))
        elif isinstance(ip, ipaddress.IPv4Network):
            allowed_ips.update(ip.hosts())
        else:
            raise ValueError(f"Bad type of ipaddress: {type(ip)} ('{ip}')")
972494
def _do(name, fun, path=None):
    '''
    
    '''
    host = find_guest(name, quiet=True, path=path)
    if not host:
        return False

    client = salt.client.get_local_client(__opts__['conf_file'])
    cmd_ret = client.cmd_iter(
            host,
            'lxc.{0}'.format(fun),
            [name],
            kwarg={'path': path},
            timeout=60)
    data = next(cmd_ret)
    data = data.get(host, {}).get('ret', None)
    if data:
        data = {host: data}
    return data
231743
def add(self, host, **kwargs):
        
        if host in self.hosts_:
            raise ValueError("Host %s: exists (use update)." % host)
        self.hosts_.add(host)
        self.lines_.append(ConfigLine(line="", host=None))
        self.lines_.append(ConfigLine(line="Host %s" % host, host=host, key="Host", value=host))
        for k, v in kwargs.items():
            if type(v) not in [list, tuple]:
                v = [v]
            mapped_k = _remap_key(k)
            for value in v:
                self.lines_.append(ConfigLine(line="  %s %s" % (mapped_k, str(value)), host=host, key=mapped_k, value=value))
        self.lines_.append(ConfigLine(line="", host=None))
589259
def exists(method,
            ip,
            port=None,
            proto='tcp',
            direction='in',
            port_origin='d',
            ip_origin='d',
            ttl=None,
            comment=''):
    '''
    
    '''
    if method.startswith('temp'):
        return _temp_exists(method, ip)
    if port:
        rule = _build_port_rule(ip, port, proto, direction, port_origin, ip_origin, comment)
        return _exists_with_port(method, rule)
    exists = __salt__['cmd.run_all']("egrep ^'{0} +' /etc/csf/csf.{1}".format(ip, method))
    return not bool(exists['retcode'])
456625
def add_host(self, host_id=None, host='localhost', port=6379,
                 unix_socket_path=None, db=0, password=None,
                 ssl=False, ssl_options=None):
        
        if host_id is None:
            raise RuntimeError('Host ID is required')
        elif not isinstance(host_id, (int, long)):
            raise ValueError('The host ID has to be an integer')
        host_id = int(host_id)
        with self._lock:
            if host_id in self.hosts:
                raise TypeError('Two hosts share the same host id (%r)' %
                                (host_id,))
            self.hosts[host_id] = HostInfo(host_id=host_id, host=host,
                                           port=port, db=db,
                                           unix_socket_path=unix_socket_path,
                                           password=password, ssl=ssl,
                                           ssl_options=ssl_options)
            self._hosts_age += 1
807927
def add_arguments(cls, parser, sys_arg_list=None):
        
        parser.add_argument('--fixed_cidr', dest="fixed_cidr", required=True,
                            help="specify the route CIDR "
                                 "(only in fixedconf mode)")
        parser.add_argument('--fixed_hosts', dest="fixed_hosts", required=True,
                            help="list of host IPs, separated by ':' "
                                 "(only in fixedconf mode)")
        return ["fixed_cidr", "fixed_hosts"]