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:
@@ -11,11 +11,16 @@
|
|||||||
# cvc90 2023 https://github.com/cvc90 GNU GPLv3 #
|
# cvc90 2023 https://github.com/cvc90 GNU GPLv3 #
|
||||||
#---------------------------------------------------------------------------------#
|
#---------------------------------------------------------------------------------#
|
||||||
|
|
||||||
$filename = "/app/.VERSION";
|
$filename = "/app/.VERSION";
|
||||||
if(file_exists($filename)) {
|
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";
|
else {
|
||||||
}
|
echo date('H:i:s') . " - N/A";
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ def get_entries(path, plugin_objects):
|
|||||||
# Use the detected encoding
|
# Use the detected encoding
|
||||||
encoding = result['encoding']
|
encoding = result['encoding']
|
||||||
|
|
||||||
|
# Order: MAC, IP, IsActive, NAME, Hardware
|
||||||
# Handle pihole-specific dhcp.leases files
|
# Handle pihole-specific dhcp.leases files
|
||||||
if 'pihole' in path:
|
if 'pihole' in path:
|
||||||
with open(path, 'r', encoding=encoding, errors='replace') as f:
|
with open(path, 'r', encoding=encoding, errors='replace') as f:
|
||||||
@@ -72,6 +73,24 @@ def get_entries(path, plugin_objects):
|
|||||||
extra = handleEmpty(path),
|
extra = handleEmpty(path),
|
||||||
foreignKey = handleEmpty(row[1])
|
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:
|
else:
|
||||||
# Handle generic dhcp.leases files
|
# Handle generic dhcp.leases files
|
||||||
leases = DhcpLeases(path)
|
leases = DhcpLeases(path)
|
||||||
|
|||||||
Reference in New Issue
Block a user