|
|
|
|
@ -48,11 +48,10 @@ typedef enum {
|
|
|
|
|
SECTION_NAT, |
|
|
|
|
SECTION_TCP_PROXY_CLIENT, |
|
|
|
|
SECTION_TCP_PROXY_SERVER, |
|
|
|
|
SECTION_CHATSERVER, |
|
|
|
|
SECTION_NETWORK, |
|
|
|
|
SECTION_GUI, |
|
|
|
|
SECTION_CHAT, |
|
|
|
|
SECTION_NTP, |
|
|
|
|
SECTION_CHATSERVER, |
|
|
|
|
SECTION_LOG_UDP |
|
|
|
|
} section_type_t; |
|
|
|
|
|
|
|
|
|
@ -760,7 +759,7 @@ static int parse_chatserver(const char *key, const char *value, struct global_co
|
|
|
|
|
global->chatserver_storage_unit_size = sz; |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_CONFIG, "%s:%d: Unknown chatserver option '%s'. Valid: join_policy, join_password, allowed_groups, storage_total_size, storage_unit_size", filename, line_num, key); |
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_CONFIG, "%s:%d: Unknown chatserver option '%s'. Valid: db_path, join_password, allowed_groups, storage_total_size, storage_unit_size, storage_autoload, storage_autoload_maxsize_mb, storage_maxsize_gb, opus_codec_preset, compressor_enabled, compressor_max_gain_db, compressor_rise_rate, media_download_max_peers", filename, line_num, key); |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -801,10 +800,12 @@ static section_type_t parse_section_header(const char *line, char *name, size_t
|
|
|
|
|
if (strcasecmp(section, "nat") == 0) return SECTION_NAT; |
|
|
|
|
if (strcasecmp(section, "tcp_proxy_client") == 0) return SECTION_TCP_PROXY_CLIENT; |
|
|
|
|
if (strcasecmp(section, "tcp_proxy_server") == 0) return SECTION_TCP_PROXY_SERVER; |
|
|
|
|
if (strcasecmp(section, "chatserver") == 0) return SECTION_CHATSERVER; |
|
|
|
|
if (strcasecmp(section, "ntp") == 0) return SECTION_NTP; |
|
|
|
|
if (strcasecmp(section, "gui") == 0) return SECTION_GUI; |
|
|
|
|
if (strcasecmp(section, "chat") == 0) return SECTION_CHAT; |
|
|
|
|
if (strcasecmp(section, "chatserver") == 0) return SECTION_CHATSERVER; |
|
|
|
|
if (strcasecmp(section, "ntp") == 0) return SECTION_NTP; |
|
|
|
|
if (strcasecmp(section, "gui") == 0) return SECTION_GUI; |
|
|
|
|
if (strcasecmp(section, "log_udp") == 0) return SECTION_LOG_UDP; |
|
|
|
|
|
|
|
|
|
char *colon = strchr(section, ':'); |
|
|
|
|
@ -1040,15 +1041,14 @@ static struct utun_config* parse_config_internal(FILE *fp, const char *filename)
|
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_CONFIG, "%s:%d: Unknown ntp option '%s'. Valid: enabled, server, interval", filename, line_num, key); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case SECTION_CHAT: |
|
|
|
|
if (chat_setting_set(key, value) < 0) { |
|
|
|
|
/* chat_setting_set уже напечатал ошибку */ |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case SECTION_CHATSERVER: |
|
|
|
|
cfg->global.chatserver_enabled = 1; |
|
|
|
|
if (parse_chatserver(key, value, &cfg->global, filename, line_num) < 0) { |
|
|
|
|
/* parse_chatserver already printed the error */ |
|
|
|
|
cfg->global.db_sync_enabled = 1; |
|
|
|
|
if (strcmp(key, "db_path") == 0) { |
|
|
|
|
assign_string(cfg->global.db_path, sizeof(cfg->global.db_path), value); |
|
|
|
|
} else if (parse_chatserver(key, value, &cfg->global, filename, line_num) < 0 && |
|
|
|
|
chat_setting_set(key, value) < 0) { |
|
|
|
|
/* both failed — errors already printed */ |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case SECTION_GUI: |
|
|
|
|
@ -1179,8 +1179,7 @@ struct utun_config* parse_config_from_buf(const char *buf, size_t len, const cha
|
|
|
|
|
case SECTION_TCP_PROXY_SERVER: cfg->global.tcp_proxy_server_enabled = 1; if (strcmp(key, "tcp_recv_buf") == 0) cfg->global.tcp_recv_buf = atoi(value); break; |
|
|
|
|
case SECTION_NETWORK: if (cur_network) parse_network(key, value, cur_network, filename, line_num); break; |
|
|
|
|
case SECTION_NTP: if (strcmp(key, "enabled") == 0) cfg->global.ntp_enabled = strcasecmp(value, "yes") == 0 || strcasecmp(value, "1") == 0 || strcasecmp(value, "true") == 0; else if (strcmp(key, "server") == 0) { struct CFG_NTP_SERVER *ns = u_calloc(1, sizeof(struct CFG_NTP_SERVER)); if (ns) { strncpy(ns->name, value, sizeof(ns->name) - 1); ns->name[sizeof(ns->name) - 1] = '\0'; ns->next = cfg->global.ntp_servers; cfg->global.ntp_servers = ns; cfg->global.ntp_server_count++; } } else if (strcmp(key, "interval") == 0) { cfg->global.ntp_resync_interval = atoi(value); if (cfg->global.ntp_resync_interval < 60) cfg->global.ntp_resync_interval = 60; } else DEBUG_ERROR(DEBUG_CATEGORY_CONFIG, "%s:%d: Unknown ntp option '%s'", filename, line_num, key); break; |
|
|
|
|
case SECTION_CHAT: chat_setting_set(key, value); break; |
|
|
|
|
case SECTION_CHATSERVER: cfg->global.chatserver_enabled = 1; parse_chatserver(key, value, &cfg->global, filename, line_num); break; |
|
|
|
|
case SECTION_CHATSERVER: cfg->global.chatserver_enabled = 1; cfg->global.db_sync_enabled = 1; if (strcmp(key, "db_path") == 0) assign_string(cfg->global.db_path, sizeof(cfg->global.db_path), value); else if (parse_chatserver(key, value, &cfg->global, filename, line_num) < 0) chat_setting_set(key, value); break; |
|
|
|
|
case SECTION_GUI: break; |
|
|
|
|
case SECTION_LOG_UDP: |
|
|
|
|
if (strcmp(key, "ip") == 0) strncpy(cfg->global.log_udp_ip, value, sizeof(cfg->global.log_udp_ip) - 1); |
|
|
|
|
|