Fix api_endpoint API returning correct IPv6 address.

This commit is contained in:
Thulinma 2024-04-29 02:33:53 +02:00
parent 0e26d49bec
commit 4dfb261283

View file

@ -1139,7 +1139,7 @@ void Controller::handleAPICommands(JSON::Value &Request, JSON::Value &Response){
if (Request.isMember("api_endpoint")){
HTTP::URL url("http://localhost:4242");
url.host = Util::listenInterface;
if (url.host == "::"){url.host = "::1";}
if (url.host == "::"){url.host = "[::1]";}
if (url.host == "0.0.0.0"){url.host = "127.0.0.1";}
url.port = JSON::Value(Util::listenPort).asString();
Response["api_endpoint"] = url.getUrl();