mirror of
https://github.com/pi-hole/web.git
synced 2026-04-25 03:10:18 +01:00
Get port number directly from pihole-FTL.conf
- Remove the code using FTL portfile - code simplification Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
const DEFAULT_FTLCONFFILE = '/etc/pihole/pihole-FTL.conf';
|
||||
const DEFAULT_FTL_IP = '127.0.0.1';
|
||||
const DEFAULT_FTL_PORT = 4711;
|
||||
const DEFAULT_FTL_PORTFILE = '/run/pihole-FTL.port';
|
||||
|
||||
function piholeFTLConfig($piholeFTLConfFile = DEFAULT_FTLCONFFILE, $force = false)
|
||||
{
|
||||
@@ -29,18 +28,19 @@ function piholeFTLConfig($piholeFTLConfFile = DEFAULT_FTLCONFFILE, $force = fals
|
||||
return $piholeFTLConfig;
|
||||
}
|
||||
|
||||
function connectFTL($address, $port)
|
||||
function connectFTL()
|
||||
{
|
||||
if ($address == DEFAULT_FTL_IP) {
|
||||
$config = piholeFTLConfig();
|
||||
// Read port
|
||||
$portfileName = isset($config['PORTFILE']) ? $config['PORTFILE'] : DEFAULT_FTL_PORTFILE;
|
||||
if ($portfileName != '') {
|
||||
$portfileContents = file_get_contents($portfileName);
|
||||
if (is_numeric($portfileContents)) {
|
||||
$port = intval($portfileContents);
|
||||
}
|
||||
}
|
||||
// We only use the default IP
|
||||
$address = DEFAULT_FTL_IP;
|
||||
|
||||
// Try to read port from FTL config. Use default if not found.
|
||||
$config = piholeFTLConfig();
|
||||
|
||||
// Use the port only if the value is numeric
|
||||
if (isset($config['FTLPORT']) && is_numeric($config['FTLPORT'])) {
|
||||
$port = intval($config['FTLPORT']);
|
||||
} else {
|
||||
$port = DEFAULT_FTL_PORT;
|
||||
}
|
||||
|
||||
// Open Internet socket connection
|
||||
@@ -89,9 +89,9 @@ function disconnectFTL($socket)
|
||||
}
|
||||
}
|
||||
|
||||
function callFTLAPI($request, $FTL_IP = DEFAULT_FTL_IP, $port = DEFAULT_FTL_PORT)
|
||||
function callFTLAPI($request)
|
||||
{
|
||||
$socket = connectFTL($FTL_IP, $port);
|
||||
$socket = connectFTL();
|
||||
|
||||
if (!is_resource($socket)) {
|
||||
$data = array('FTLnotrunning' => true);
|
||||
|
||||
Reference in New Issue
Block a user