Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also make <domain> optional in the setupVars.conf migration process #2248

Merged
merged 1 commit into from
Feb 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/config/setupVars.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,13 @@ static void get_revServer_from_setupVars(void)
char *domain_str = read_setupVarsconf("REV_SERVER_DOMAIN");
if(domain_str != NULL)
{
domain = strdup(domain_str);
trim_whitespace(domain);
if(strlen(domain_str) == 0)
log_info("setupVars.conf:REV_SERVER_DOMAIN -> Empty string, ignoring");
else
{
domain = strdup(domain_str);
trim_whitespace(domain);
}
}
else
log_info("setupVars.conf:REV_SERVER_DOMAIN -> Not set");
Expand All @@ -187,16 +192,19 @@ static void get_revServer_from_setupVars(void)
clearSetupVarsArray();

// Only add the entry if all values are present and active
if(cidr != NULL && target != NULL && domain != NULL)
if(cidr != NULL && target != NULL)
{
// Build comma-separated string of all values
// 9 = 3 commas, "true/false", and null terminator
char *old = calloc(strlen(cidr) + strlen(target) + strlen(domain) + 9, sizeof(char));
char *old = calloc(strlen(cidr) + strlen(target) + (domain != NULL ? strlen(domain) : 0) + 9, sizeof(char));
if(old != NULL)
{
// Add to new config
// active is always true as we only add active entries
sprintf(old, "%s,%s,%s,%s", active ? "true" : "false", cidr, target, domain);
if(domain != NULL && strlen(domain) > 0)
sprintf(old, "%s,%s,%s,%s", active ? "true" : "false", cidr, target, domain);
else
sprintf(old, "%s,%s,%s", active ? "true" : "false", cidr, target);
cJSON_AddItemToArray(config.dns.revServers.v.json, cJSON_CreateString(old));

// Parameter present in setupVars.conf
Expand Down
Loading