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 3d19311
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/config/setupVars.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,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 3d19311

Please sign in to comment.