- New centralized logfile system for Network, DNS & VPN,

- Now kill VPN suprocesses,
- Move file config in syscoinfig file,
- Misc fixes.
This commit is contained in:
2025-07-24 18:27:01 +02:00
parent 3aaaf15e45
commit 19392dfa14
5 changed files with 210 additions and 100 deletions

View File

@@ -31,17 +31,17 @@ declare -g DNS_A_ID_LIST
declare -Ag DNS_PTR_TAB
declare -g DNS_PTR_ID_LIST
declare -g DNS_CACHE_FILE="/var/cache/network/dns.cache"
declare -g DNS_CACHE_LOCK="/var/lock/network/dns.lock"
declare -g DNS_CACHE_FILE
declare -g DNS_CACHE_LOCK
#declare -g DNS_CACHE_LOCK="${DNS_CACHE_FILE}"
declare -g DNS_CACHE_UPDATED=0
if [ ! -v LOG ] || [[ "${LOG}" == "" ]]
then
export LOG=":"
fi
#if [ ! -v LOG ] || [[ "${LOG}" == "" ]]
#then
# export LOG=":"
#fi
@@ -53,13 +53,13 @@ fi
dns_tab_load()
{
${LOG} 1>&2 "Loading DNS cache..."
log_print "DNS" "Loading DNS cache..."
file_lock "${DNS_CACHE_LOCK}" READ 9
if [[ ( -e "${DNS_CACHE_FILE}" ) && ( "${NETWORK_CONFIG_FILE}" -ot "${DNS_CACHE_FILE}" ) ]]
then
${LOG} 1>&2 "DNS: Read CacheFile"
log_print "DNS" "Read CacheFile"
while IFS= read -r line
do
@@ -76,7 +76,7 @@ dns_tab_load()
fi
done < ${DNS_CACHE_FILE}
else
${LOG} 1>&2 "DNS: Init CacheFile"
log_print "DNS" "Init CacheFile"
>${DNS_CACHE_FILE}
fi
@@ -96,13 +96,13 @@ dns_tab_load()
dns_tab_save()
{
${LOG} 1>&2 "Saving DNS cache..."
log_print "DNS" "Saving DNS cache..."
if [[ "${DNS_CACHE_UPDATED}" != "0" ]]
then
file_lock "${DNS_CACHE_LOCK}" WRITE 9
${LOG} 1>&2 "DNS: Write CacheFile"
log_print "DNS" "Write CacheFile"
(
for key in "${!DNS_A_TAB[@]}"
@@ -143,7 +143,7 @@ dns_tab_get()
then
dns_value="${DNS_A_TAB["${dns_key}"]}"
else
${LOG} "DNS: Lookup failed: Type: [${dns_type}] Key: [${dns_key}]"
log_print "DNS" "Lookup failed: Type: [${dns_type}] Key: [${dns_key}]"
return 1
fi
;;
@@ -153,13 +153,13 @@ dns_tab_get()
then
dns_value="${DNS_PTR_TAB["${dns_key}"]}"
else
${LOG} "DNS: Lookup failed: Type: [${dns_type}] Key: [${dns_key}]"
log_print "DNS" "Lookup failed: Type: [${dns_type}] Key: [${dns_key}]"
return 1
fi
;;
esac
${LOG} "DNS: Lookup succeed: Type: [${dns_type}] Key: [${dns_key}] Value: [${dns_value}]"
log_print "DNS" "Lookup succeed: Type: [${dns_type}] Key: [${dns_key}] Value: [${dns_value}]"
return 0
}
@@ -181,9 +181,9 @@ dns_tab_put()
if [[ "${dtp_value}" == "" ]]
then
${LOG} 1>&2 "DNS: Skiping cache entry: Type: [${dtp_type}] Key: [${dtp_key}] Value: [${dtp_value}]"
log_print "DNS" "Skiping cache entry: Type: [${dtp_type}] Key: [${dtp_key}] Value: [${dtp_value}]"
else
${LOG} 1>&2 "DNS: Update cache entry: Type: [${dtp_type}] Key: [${dtp_key}] Value: [${dtp_value}]"
log_print "DNS" "Update cache entry: Type: [${dtp_type}] Key: [${dtp_key}] Value: [${dtp_value}]"
var_assign DNS_${dtp_type}_ID_LIST "${dtp_key}" INC
tab_assign DNS_${dtp_type}_TAB "${dtp_key}" "${dtp_value}"
@@ -216,7 +216,7 @@ dns_lookup()
if [[ "$?" != "0" ]]
then
${LOG} "DNS: Out of Cache: Type: [${dl_type}] Key: [${dl_key}] Flag: [${dl_flag}]"
log_print "DNS" "Out of Cache: Type: [${dl_type}] Key: [${dl_key}] Flag: [${dl_flag}]"
case ${dl_type}
in