Skip to content

Commit

Permalink
In the corner-case of a user explicitly having configured Pi-hole to …
Browse files Browse the repository at this point in the history
…NOT listen on lo (because there may be another webserver, etc.), the pihole CLI command may be unable to communicate with the API due to the hard-coded path "localhost". Change this to use the special "pi.hole" host name where interface-dependent replying is already implemented

Signed-off-by: DL6ER <[email protected]>
  • Loading branch information
DL6ER committed Feb 21, 2025
1 parent 03cc1d3 commit 47688b9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/webserver/webserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ unsigned short get_api_string(char **buf, const bool domain)
size_t len = 0;
// First byte has the length of the first string
**buf = 0;
const char *domain_str = domain ? config.webserver.domain.v.s : "localhost";
const char *domain_str = domain ? config.webserver.domain.v.s : "pi.hole";
size_t api_str_size = strlen(domain_str) + 20;

// Check if the string is too long for the TXT record
Expand Down
2 changes: 1 addition & 1 deletion test/test_suite.bats
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,7 @@
@test "API addresses reported correctly by CHAOS TXT local.api.ftl" {
run bash -c 'dig CHAOS TXT local.api.ftl +short @127.0.0.1'
printf "dig (full): %s\n" "${lines[@]}"
[[ ${lines[0]} == '"http://localhost:80/api/" "https://localhost:443/api/"' ]]
[[ ${lines[0]} == '"http://pi.hole:80/api/" "https://pi.hole:443/api/"' ]]
}

@test "API addresses reported by CHAOS TXT api.ftl identical to domain.api.ftl" {
Expand Down

0 comments on commit 47688b9

Please sign in to comment.