pi-hole / web

Pi-hole Dashboard for stats and more
https://pi-hole.net
Other
2.02k stars 560 forks source link

Connect API fo FTL on another machine #589

Closed DL6ER closed 6 years ago

DL6ER commented 7 years ago

In raising this issue, I confirm the following (please check boxes, eg [X] - no spaces) Failure to fill the template will close your issue:

How familiar are you with the codebase?:

10


[BUG | ISSUE] Expected Behaviour:

It should be possible that the API connects to an FTL instance on another machine by changing the IP address in admin/api_FTL.php here.

[BUG | ISSUE] Actual Behaviour:

It seems like this is not possible.

[BUG | ISSUE] Steps to reproduce:

This template was created based on the work of udemy-dl.

DL6ER commented 7 years ago

Connecting to a distant FTL works without any problems. I set up two testing VMs for this:

Donor: 165.227.172.155

Acceptor: 165.227.162.148

I changed api_FTL.php#L15 from

$socket = connectFTL("127.0.0.1");

to

$socket = connectFTL("165.227.172.155");

However, there is an additional check in api.php#L77 that prevents the API from working when no local version of FTL is running. This will have to be changed if we allow non-local FTL instances to be used for generating a dash board.

For now, you could replace

if(!testFTL() && !isset($_GET["PHP"]))
{
    $data = array_merge($data, array("FTLnotrunning" => true));
}
else
{
    if(!isset($_GET["PHP"]))
    {
        require("api_FTL.php");
    }
    else
    {
        require("api_PHP.php");
    }
}

by

if(!isset($_GET["PHP"]))
    require("api_FTL.php");
else
    require("api_PHP.php");
DL6ER commented 7 years ago

I submitted a bug fix that will skip the test of a local installation if you specify an external IP address for the FTL instance to be used.