mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 01:26:11 -08:00
dnsmasq dhcp.leases v0.1 #661 ⏬
This commit is contained in:
@@ -13,9 +13,14 @@
|
||||
|
||||
$filename = "/app/.VERSION";
|
||||
if(file_exists($filename)) {
|
||||
echo file_get_contents($filename);
|
||||
$fileContents = file_get_contents($filename);
|
||||
if(trim($fileContents) === 'Dev') {
|
||||
echo date('H:i:s') . " - " . $fileContents;
|
||||
} else {
|
||||
echo $fileContents;
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo date('Y-m-d H:i:s') . " - N/A";
|
||||
echo date('H:i:s') . " - N/A";
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -56,6 +56,7 @@ def get_entries(path, plugin_objects):
|
||||
# Use the detected encoding
|
||||
encoding = result['encoding']
|
||||
|
||||
# Order: MAC, IP, IsActive, NAME, Hardware
|
||||
# Handle pihole-specific dhcp.leases files
|
||||
if 'pihole' in path:
|
||||
with open(path, 'r', encoding=encoding, errors='replace') as f:
|
||||
@@ -72,6 +73,24 @@ def get_entries(path, plugin_objects):
|
||||
extra = handleEmpty(path),
|
||||
foreignKey = handleEmpty(row[1])
|
||||
)
|
||||
elif 'dnsmasq' in path:
|
||||
# [Lease expiry time] [mac address] [ip address] [hostname] [client id, if known]
|
||||
# e.g.
|
||||
# 1715932537 01:5c:5c:5c:5c:5c:5c 192.168.1.115 ryans-laptop 01:5c:5c:5c:5c:5c:5c
|
||||
with open(path, 'r', encoding=encoding, errors='replace') as f:
|
||||
for line in f:
|
||||
row = line.rstrip().split()
|
||||
if len(row) > 3:
|
||||
plugin_objects.add_object(
|
||||
primaryId = handleEmpty(row[1]),
|
||||
secondaryId = handleEmpty(row[2]),
|
||||
watched1 = handleEmpty('True'),
|
||||
watched2 = handleEmpty(row[3]),
|
||||
watched3 = '',
|
||||
watched4 = handleEmpty('True'),
|
||||
extra = handleEmpty(path),
|
||||
foreignKey = handleEmpty(row[1])
|
||||
)
|
||||
else:
|
||||
# Handle generic dhcp.leases files
|
||||
leases = DhcpLeases(path)
|
||||
|
||||
Reference in New Issue
Block a user