Hi, print some "echo" to a debug file, I found the problem is at the connectFTL function, cannot create the socket
Here, in FTL.php, function return an empty $socket and $errn=0
function connectFTL($address, $port=4711)
{
if($address == "127.0.0.1")
{
// Read port
$portfile = file_get_contents("/var/run/pihole-FTL.port");
if(is_numeric($portfile))
$port = intval($portfile);
}
// Open Internet socket connection
$socket = @fsockopen($address, $port, $errno, $errstr, 1.0);
#My logs
file_put_contents('/tmp/fitxer.log', 'FTL.php'.PHP_EOL,FILE_APPEND);
file_put_contents('/tmp/fitxer.log', 'FTL.php Address --> '.$address.PHP_EOL,FILE_APPEND);
file_put_contents('/tmp/fitxer.log', 'FTL.php Port --> '.$port.PHP_EOL,FILE_APPEND);
file_put_contents('/tmp/fitxer.log', 'FTL.php Errn --> '.$errno.PHP_EOL,FILE_APPEND);
file_put_contents('/tmp/fitxer.log', 'FTL.php Errstr --> '.$errstr.PHP_EOL,FILE_APPEND);
file_put_contents('/tmp/fitxer.log', 'FTL.php Socket --> '.$socket.PHP_EOL,FILE_APPEND);
return $socket;
}
So in api_FTL.php, the call backs empty
socket = connectFTL($FTL_IP);
file_put_contents('/tmp/fitxer.log', 'api_FTL.php'.PHP_EOL,FILE_APPEND);
file_put_contents('/tmp/fitxer.log', 'api_FTL.php Socket -->'.$socket.PHP_EOL,FILE_APPEND);
if(!is_resource($socket))
{
$data = array_merge($data, array("FTLnotrunning" => true));
file_put_contents('/tmp/fitxer.log', 'api_FTL.php FTLnotRunning'.PHP_EOL,FILE_APPEND);
}
Logs generated by the "file_put_contents". Both "Socket --> XXXX" are empty and then "!is_resource"
FTL.php
FTL.php Address --> 127.0.0.1
FTL.php Port --> 4711
FTL.php Errn --> 0
FTL.php Errstr -->
FTL.php Socket -->
api_FTL.php
api_FTL.php Socket -->
api_FTL.php FTLnotRunning
EDIT: I created a Test.php with a basic code to test against Google.
<?php
$fp = @fsockopen ("172.217.169.14", 80, $errno, $errstr, 10);
if (!$fp) {
echo "$errstr ($errno)
\n";
}else
{
echo "fsockopen Is Working Perfectly.";
}
fclose ($fp);
?>
First I test with telnet and tcpdump and the connection is established
root@localhost:/home/android# telnet 172.217.169.14 80
Trying 172.217.169.14...
Connected to 172.217.169.14.
Escape character is '^]'.
^C
oot@localhost:/home/android# tcpdump -i any host 172.217.169.14
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes
04:30:55.677785 IP localhost.48101 > lhr25s26-in-f14.1e100.net.http: Flags [S], seq 1601191793, win 65535, options [mss 1460,sackOK,TS val 4557073 ecr 0,nop,wscale 7], length 0
04:30:55.720540 IP lhr25s26-in-f14.1e100.net.http > localhost.48101: Flags [S.], seq 2836713301, ack 1601191794, win 60192, options [mss 1380,sackOK,TS val 2877321768 ecr 4557073,nop,wscale 8], length 0
04:30:55.720662 IP localhost.48101 > lhr25s26-in-f14.1e100.net.http: Flags [.], ack 1, win 685, options [nop,nop,TS val 4557078 ecr 2877321768], length 0
04:30:56.518574 IP localhost.48101 > lhr25s26-in-f14.1e100.net.http: Flags [P.], seq 1:6, ack 1, win 685, options [nop,nop,TS val 4557157 ecr 2877321768], length 5: HTTP
04:30:56.561024 IP lhr25s26-in-f14.1e100.net.http > localhost.48101: Flags [.], ack 6, win 236, options [nop,nop,TS val 2877322612 ecr 4557157], length 0
But when I load the Test.php, a 0 is returned and no traffic is captured by the tcpdump.
So I conclude the fsockopen is not working. Any dependency or permission I should consider?
Thanks