Preserve Android debug level and accept all core categories
This commit is contained in:
1 parent
7fa7a42673
commit
5f5d4f964a
3 files changed
+13
-6
No files matched your search
+9
-3
@@ -1180,7 +1180,7 @@ static struct utun_config* parse_config_internal(FILE *fp, const char *filename)
|
||||
break;
|
||||
case SECTION_DEBUG:
|
||||
// Format: category=level (e.g., etcp=debug, crypto=info)
|
||||
if (cfg->global.debug_levels.count < 16) {
|
||||
if (cfg->global.debug_levels.count < DEBUG_CATEGORY_COUNT) {
|
||||
strncpy(cfg->global.debug_levels.category[cfg->global.debug_levels.count],
|
||||
key, 15);
|
||||
cfg->global.debug_levels.category[cfg->global.debug_levels.count][15] = '\0';
|
||||
@@ -1188,7 +1188,7 @@ static struct utun_config* parse_config_internal(FILE *fp, const char *filename)
|
||||
value, 15);
|
||||
cfg->global.debug_levels.level[cfg->global.debug_levels.count][15] = '\0';
|
||||
cfg->global.debug_levels.count++;
|
||||
}
|
||||
} else DEBUG_WARN(DEBUG_CATEGORY_CONFIG, "%s:%d: Too many debug categories, ignored %s=%s", filename, line_num, key, value);
|
||||
break;
|
||||
case SECTION_FIREWALL:
|
||||
if (strcmp(key, "allow") == 0) {
|
||||
@@ -1429,7 +1429,13 @@ struct utun_config* parse_config_from_buf(const char *buf, size_t len, const cha
|
||||
case SECTION_SERVER: if (cur_server) parse_server(key, value, cur_server, filename, line_num); break;
|
||||
case SECTION_CLIENT: if (cur_client) parse_client(key, value, cur_client, cfg->servers, filename, line_num); break;
|
||||
case SECTION_ROUTING: if (strcmp(key, "route_subnet") == 0) add_route_entry(&cfg->route_subnets, value); else if (strcmp(key, "my_subnet") == 0) add_route_entry(&cfg->my_subnets, value); else DEBUG_ERROR(DEBUG_CATEGORY_CONFIG, "%s:%d: Unknown routing option '%s'", filename, line_num, key); break;
|
||||
case SECTION_DEBUG: if (cfg->global.debug_levels.count < 16) { strncpy(cfg->global.debug_levels.category[cfg->global.debug_levels.count], key, 15); cfg->global.debug_levels.category[cfg->global.debug_levels.count][15] = '\0'; strncpy(cfg->global.debug_levels.level[cfg->global.debug_levels.count], value, 15); cfg->global.debug_levels.level[cfg->global.debug_levels.count][15] = '\0'; cfg->global.debug_levels.count++; } break;
|
||||
case SECTION_DEBUG:
|
||||
if (cfg->global.debug_levels.count < DEBUG_CATEGORY_COUNT) {
|
||||
int index = cfg->global.debug_levels.count++;
|
||||
strncpy(cfg->global.debug_levels.category[index], key, 15); cfg->global.debug_levels.category[index][15] = '\0';
|
||||
strncpy(cfg->global.debug_levels.level[index], value, 15); cfg->global.debug_levels.level[index][15] = '\0';
|
||||
} else DEBUG_WARN(DEBUG_CATEGORY_CONFIG, "%s:%d: Too many debug categories, ignored %s=%s", filename, line_num, key, value);
|
||||
break;
|
||||
case SECTION_FIREWALL: if (strcmp(key, "allow") == 0) parse_firewall_rule(value, &cfg->global); else DEBUG_ERROR(DEBUG_CATEGORY_CONFIG, "%s:%d: Unknown firewall option '%s'", filename, line_num, key); break;
|
||||
case SECTION_CONTROL: parse_control(key, value, &cfg->global, filename, line_num); break;
|
||||
case SECTION_ALLOWED_KEYS: if (strcmp(key, "allow_all") == 0) cfg->global.allowed_keys_allow_all = strcasecmp(value, "yes") == 0 || strcasecmp(value, "1") == 0 || strcasecmp(value, "true") == 0; else if (strcmp(key, "key") == 0) { struct CFG_ALLOWED_KEY *nk = u_calloc(1, sizeof(struct CFG_ALLOWED_KEY)); if (nk && strlen(value) == SC_PUBKEY_SIZE * 2 && hex_to_binary(value, nk->key_bin, SC_PUBKEY_SIZE) == 0) { nk->next = cfg->global.allowed_keys; cfg->global.allowed_keys = nk; cfg->global.allowed_keys_count++; } else u_free(nk); } else DEBUG_ERROR(DEBUG_CATEGORY_CONFIG, "%s:%d: Unknown allowed_keys option '%s'", filename, line_num, key); break;
|
||||
|
||||
+3
-2
@@ -8,6 +8,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "../lib/platform_compat.h"
|
||||
#include "../lib/debug_config.h"
|
||||
#include "secure_channel.h"
|
||||
#include "transport_layer/reality.h"
|
||||
#include "chat/chat_setting.h"
|
||||
@@ -155,8 +156,8 @@ struct global_config {
|
||||
|
||||
// Per-category debug levels (loaded from [debug] section)
|
||||
struct {
|
||||
char category[16][16]; // category name
|
||||
char level[16][16]; // level string
|
||||
char category[DEBUG_CATEGORY_COUNT][16]; // category name
|
||||
char level[DEBUG_CATEGORY_COUNT][16]; // level string
|
||||
int count;
|
||||
} debug_levels;
|
||||
|
||||
|
||||
@@ -615,6 +615,7 @@ class ConfigProvider(private val context: Context) {
|
||||
if (pubKey.length == 64) appendLine("my_public_key=$pubKey")
|
||||
if (privKey.length == 64) appendLine("my_private_key=$privKey")
|
||||
appendLine("db_path=$dbDir")
|
||||
appendLine("debug_level=${getString("debug.console_level") ?: "info"}")
|
||||
appendLine("db_sync_enabled=1")
|
||||
appendLine("chatserver_enabled=1")
|
||||
appendLine("auto_sockets=android")
|
||||
@@ -670,7 +671,6 @@ class ConfigProvider(private val context: Context) {
|
||||
appendLine("group_autoconnect=${getInt("chat.group_autoconnect")}")
|
||||
appendLine()
|
||||
appendLine("[debug]")
|
||||
appendLine("console_level=info")
|
||||
val dbgCat = getString("debug.categories") ?: ""
|
||||
if (dbgCat.isNotEmpty()) {
|
||||
for (entry in dbgCat.split(",")) {
|
||||
|
||||
Reference in new issue
Block a user