]> git.mxchange.org Git - fba.git/blobdiff - daemon.py
Continued:
[fba.git] / daemon.py
index 4ae10a49e81fbb6080969f558790ed4878a8876e..bfede5053fd4d0b566d77089092de532ee12a3cc 100755 (executable)
--- a/daemon.py
+++ b/daemon.py
@@ -22,7 +22,6 @@ import re
 from datetime import datetime
 from email.utils import format_datetime
 from pathlib import Path
-from urllib.parse import urlparse
 
 import fastapi
 from fastapi import Request, HTTPException, Query
@@ -39,6 +38,7 @@ from fba import utils
 
 from fba.helpers import blacklist
 from fba.helpers import config
+from fba.helpers import domain as domain_helper
 from fba.helpers import json as json_helper
 from fba.helpers import tidyup
 
@@ -140,7 +140,7 @@ def api_index(request: Request, mode: str, value: str, amount: int):
         )
     elif mode in ["domain", "reverse"]:
         domain = tidyup.domain(value)
-        if not utils.is_domain_wanted(domain):
+        if not domain_helper.is_wanted(domain):
             raise HTTPException(status_code=500, detail=f"domain='{domain}' is not wanted")
 
         wildchar = "*." + ".".join(domain.split(".")[-domain.count("."):])
@@ -220,7 +220,7 @@ def api_domain(domain: str):
     # Tidy up domain name
     domain = tidyup.domain(domain).encode("idna").decode("utf-8")
 
-    if not utils.is_domain_wanted(domain):
+    if not domain_helper.is_wanted(domain):
         raise HTTPException(status_code=500, detail=f"domain='{domain}' is not wanted")
 
     # Fetch domain data
@@ -386,7 +386,7 @@ def list_domains(request: Request, mode: str, value: str, amount: int = config.g
 def top(request: Request, mode: str, value: str, amount: int = config.get("api_limit")):
     if mode == "block_level" and not blocks.valid(value, "block_level"):
         raise HTTPException(status_code=500, detail="Invalid block level provided")
-    elif mode in ["domain", "reverse"] and not utils.is_domain_wanted(value):
+    elif mode in ["domain", "reverse"] and not domain_helper.is_wanted(value):
         raise HTTPException(status_code=500, detail="Invalid or blocked domain specified")
 
     response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/top.json?mode={mode}&value={value}&amount={amount}")
@@ -422,7 +422,7 @@ def infos(request: Request, domain: str):
     # Tidy up domain name
     domain = tidyup.domain(domain).encode("idna").decode("utf-8")
 
-    if not utils.is_domain_wanted(domain):
+    if not domain_helper.is_wanted(domain):
         raise HTTPException(status_code=500, detail=f"domain='{domain}' is not wanted")
 
     response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/domain.json?domain={domain}")