Skip to content

Commit

Permalink
Also make <domain> optional in the setupVars.conf migration process
Browse files Browse the repository at this point in the history
Signed-off-by: DL6ER <[email protected]>
  • Loading branch information
DL6ER committed Feb 22, 2025
1 parent 23fd011 commit 5bcd1a0
Showing 1 changed file with 13 additions and 5 deletions.
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

0 comments on commit 5bcd1a0

Please sign in to comment.