Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
D
dns-unbound-cache-reader
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Conditions générales et politique de confidentialité
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
smart-home-network-security
dns-unbound-cache-reader
Validations
07cfbcfe
Valider
07cfbcfe
rédigé
Il y a 7 mois
par
François De Keersmaeker
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Added function update_dns_table + refactor
parent
a81b754a
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Pipeline
#57292
réussi
Il y a 7 mois
Étape : test
Modifications
2
Pipelines
1
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
dns_unbound_cache_reader/__init__.py
+1
-0
1 ajout, 0 suppression
dns_unbound_cache_reader/__init__.py
dns_unbound_cache_reader/dns_unbound_cache_reader.py
+35
-15
35 ajouts, 15 suppressions
dns_unbound_cache_reader/dns_unbound_cache_reader.py
avec
36 ajouts
et
15 suppressions
dns_unbound_cache_reader/__init__.py
+
1
−
0
Voir le fichier @
07cfbcfe
...
...
@@ -2,5 +2,6 @@ from .dns_unbound_cache_reader import (
DnsCacheSection
,
DnsRtype
,
DnsTableKeys
,
update_dns_table
,
read_dns_cache
)
Ce diff est replié.
Cliquez pour l'agrandir.
dns_unbound_cache_reader/dns_unbound_cache_reader.py
+
35
−
15
Voir le fichier @
07cfbcfe
...
...
@@ -55,30 +55,22 @@ class DnsTableKeys(Enum):
ALIAS
=
"
alias
"
def
read_dns_cache
(
def
update_dns_table
(
dns_table
:
dict
=
{},
host
:
str
=
"
127.0.0.1
"
,
file
:
str
=
None
)
->
dict
:
"""
Read the Unbound DNS cache and return it as a dictionary,
in the format:
{
DnsTableKeys.IP: {
ip_address: domain_name,
...
},
DnsTableKeys
.
ALIAS
:
{
canonical_name
:
alias
,
...
}
}
Update the given DNS table by reading the current DNS cache.
Args:
dns_table (dict): Dictionary containing the current DNS table.
host (str): IP address of the Unbound DNS server. Default is localhost.
file (str): Path to a file containing the Unbound DNS cache. Default is None.
If specified, the function reads the cache from the file instead of the server.
Returns:
dict: Updated DNS table.
"""
### Get DNS cache ###
dns_cache
=
None
...
...
@@ -116,7 +108,6 @@ def read_dns_cache(
end_idx
=
len
(
dns_cache
)
# Loop through the RRSET section
dns_table
=
{}
for
line
in
dns_cache
[
start_idx
+
1
:
end_idx
]:
# Lines containing metadata, skip
...
...
@@ -204,3 +195,32 @@ def read_dns_cache(
return
dns_table
def
read_dns_cache
(
host
:
str
=
"
127.0.0.1
"
,
file
:
str
=
None
)
->
dict
:
"""
Read the Unbound DNS cache and return it as a dictionary,
in the format:
{
DnsTableKeys.IP: {
ip_address: domain_name,
...
},
DnsTableKeys
.
ALIAS
:
{
canonical_name
:
alias
,
...
}
}
Args:
host (str): IP address of the Unbound DNS server. Default is localhost.
file (str): Path to a file containing the Unbound DNS cache. Default is None.
If specified, the function reads the cache from the file instead of the server.
Returns:
dict: Dictionary containing the DNS table read from the cache.
"""
return
update_dns_table
({},
host
,
file
)
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter