mirror of
https://github.com/michivonah/adguard-ddns-client.git
synced 2025-12-22 22:26:28 +01:00
create function for ip lookup
This commit is contained in:
parent
f4c18271b2
commit
5255edf997
2 changed files with 9 additions and 6 deletions
12
main.py
12
main.py
|
|
@ -2,6 +2,8 @@ import os
|
|||
from dotenv import load_dotenv
|
||||
import requests
|
||||
from requests.auth import HTTPBasicAuth
|
||||
import dns
|
||||
import dns.resolver
|
||||
|
||||
# Load envirommental variables
|
||||
load_dotenv()
|
||||
|
|
@ -41,13 +43,13 @@ def getClients(api_base_url, api_username, api_password):
|
|||
result = response.json()
|
||||
print(result["allowed_clients"])
|
||||
|
||||
def getIPAdress(domainname, dnsServer):
|
||||
endpoint = ""
|
||||
ip = "1.1.1.1"
|
||||
def getIPAdress(domainname):
|
||||
lookup = dns.resolver.resolve(domainname, 'A')
|
||||
for ipval in lookup:
|
||||
ip = ipval.to_text()
|
||||
return ip
|
||||
|
||||
|
||||
# Funktion aufrufen
|
||||
#add_ip_to_whitelist(API_BASE_URL, API_USERNAME, API_PASSWORD, IP_TO_WHITELIST)
|
||||
getClients(API_BASE_URL, API_USERNAME, API_PASSWORD)
|
||||
|
||||
#getClients(API_BASE_URL, API_USERNAME, API_PASSWORD)
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
# requirements.txt
|
||||
python-dotenv==1.0.0
|
||||
requests
|
||||
HTTPBasicAuth
|
||||
HTTPBasicAuth
|
||||
dnspython
|
||||
Loading…
Add table
Add a link
Reference in a new issue