diff --git a/src/config_parser.c b/src/config_parser.c index ec6116673..09c24a003 100644 --- a/src/config_parser.c +++ b/src/config_parser.c @@ -293,15 +293,19 @@ static int parse_global(const char *key, const char *value, struct global_config return 0; } if (strcmp(key, "control_ip") == 0) { - // Store for later processing with control_port - return 0; // We'll handle this when we see control_port + // Store control_ip for later processing with control_port + strncpy(global->control_ip, value, sizeof(global->control_ip) - 1); + global->control_ip[sizeof(global->control_ip) - 1] = '\0'; + return 0; } if (strcmp(key, "control_port") == 0) { - // This is tricky - we need to get control_ip from previous parsing - // For now, we'll use a simple approach - struct global_config temp_global = *global; - // Assume we stored control_ip somewhere or use default - char control_ip[MAX_ADDR_LEN] = "127.0.0.1"; // Default + // Use control_ip from config, fallback to localhost if not set + char control_ip[MAX_ADDR_LEN]; + if (global->control_ip[0] != '\0') { + strncpy(control_ip, global->control_ip, sizeof(control_ip) - 1); + } else { + strcpy(control_ip, "127.0.0.1"); + } char port_str[16]; snprintf(port_str, sizeof(port_str), "%s", value); parse_sockaddr(control_ip, port_str, &global->control_sock); diff --git a/src/config_parser.h b/src/config_parser.h index 110ec0fda..45b05f78b 100644 --- a/src/config_parser.h +++ b/src/config_parser.h @@ -66,6 +66,7 @@ struct global_config { struct IP tun_ip; int mtu; struct sockaddr_storage control_sock; + char control_ip[MAX_ADDR_LEN]; // Control server IP address int net_debug; // Debug and logging configuration