Пример #1
0
static ya_result
config_section_zone_stop(struct config_section_descriptor_s *csd)
{
#if CONFIG_SETTINGS_DEBUG
    formatln("config: section: zone: stop");
#endif
    
    // NOP
    zone_desc_s *zone_desc = (zone_desc_s*)csd->base;
    ya_result return_code;
    
    // ensure the descriptor is valid
    
    if(ISOK(return_code = zone_complete_settings(zone_desc)))
    {
        zone_setdefaults(zone_desc);
        
        if(logger_is_running())
        {
            log_debug("config: %{dnsname}: zone section parsed", zone_desc->origin);
        }
        
        // load the descriptor (most likely offline)

        if(config_section_zone_filter(zone_desc, config_section_zone_filter_params) == 1)
        {
            if(logger_is_running())
            {
                log_debug("config: %{dnsname}: sending zone to service", zone_desc->origin);
            }
            database_zone_desc_load(zone_desc);
        }
        else
        {
            
            zone_desc_s *current_zone_desc = zone_acquirebydnsname(zone_desc->origin);
            if(current_zone_desc != NULL)
            {
                if(logger_is_running())
                {
                    log_debug("config: %{dnsname}: clearing original zone drop status", zone_desc->origin);
                }
                zone_lock(current_zone_desc, ZONE_LOCK_REPLACE_DESC);
                zone_clear_status(current_zone_desc, ZONE_STATUS_DROP_AFTER_RELOAD);
                zone_unlock(current_zone_desc, ZONE_LOCK_REPLACE_DESC);
                
                zone_release(current_zone_desc);
            }
            
            zone_release(zone_desc);
        }
    }
    else
    {
        zone_release(zone_desc);
    }
        
    csd->base = NULL;
    
    return return_code;
}
Пример #2
0
static ya_result
config_zone_section_assign(config_data *config)
{
    u32 port = 0;
    ya_result return_code;

    config_zone_section_register(config);

    if(FAIL(return_code = parse_u32_check_range(config->server_port, &port, 1, MAX_U16, 10)))
    {
        osformatln(termerr, "config: zone: wrong dns port set in main '%s': %r", config->server_port, return_code);

        return return_code;
    }

    zone_set_lock(&config->zones);

    treeset_avl_iterator iter;
    treeset_avl_iterator_init(&config->zones.set, &iter);

    while(treeset_avl_iterator_hasnext(&iter))
    {
        treeset_node *zone_node = treeset_avl_iterator_next_node(&iter);
        zone_data *zone = (zone_data *)zone_node->data;

        zone_setdefaults(zone);

        if(!config_check_bounds_s32(SIGNATURE_VALIDITY_INTERVAL_MIN, SIGNATURE_VALIDITY_INTERVAL_MAX, zone->sig_validity_interval, "sig-validity-interval"))
        {
            return ERROR;
        }

        if(!config_check_bounds_s32(SIGNATURE_VALIDITY_REGENERATION_MIN, SIGNATURE_VALIDITY_REGENERATION_MAX, zone->sig_validity_regeneration, "sig-validity-regeneration"))
        {
            return ERROR;
        }

        if(!config_check_bounds_s32(SIGNATURE_VALIDITY_JITTER_MIN, SIGNATURE_VALIDITY_JITTER_MAX, zone->sig_validity_jitter, "sig-validity-jitter"))
        {
            return ERROR;
        }

        if(!config_check_bounds_s32(NOTIFY_RETRY_COUNT_MIN, NOTIFY_RETRY_COUNT_MAX, zone->notify.retry_count, "notify-retry-count"))
        {
            return ERROR;
        }

        if(!config_check_bounds_s32(NOTIFY_RETRY_PERIOD_MIN, NOTIFY_RETRY_PERIOD_MAX, zone->notify.retry_period, "notify-period-count"))
        {
            return ERROR;
        }

        if(!config_check_bounds_s32(NOTIFY_RETRY_PERIOD_INCREASE_MIN, NOTIFY_RETRY_PERIOD_INCREASE_MAX, zone->notify.retry_period_increase, "notify-period-increase"))
        {
            return ERROR;
        }

        zone->ctrl_flags |= ZONE_CTRL_FLAG_READ_FROM_CONF;
    }

    zone_set_unlock(&config->zones);

    return SUCCESS;
}