]> git.mxchange.org Git - fba.git/commitdiff
Mark wildcard blocks as such
authorMint <>
Mon, 8 Aug 2022 11:29:44 +0000 (14:29 +0300)
committerMint <>
Mon, 8 Aug 2022 11:29:44 +0000 (14:29 +0300)
api.py
index.html

diff --git a/api.py b/api.py
index d37d22e7bdc46caadc223e24fdf378baabba18ea..ca3badb03df5c3fa8e1baec59734f681340d6ff4 100644 (file)
--- a/api.py
+++ b/api.py
@@ -39,7 +39,7 @@ def blocked(domain: str = None, reason: str = None):
     if domain != None:
         wildchar = "*." + ".".join(domain.split(".")[-domain.count("."):])
         punycode = domain.encode('idna').decode('utf-8')
-        c.execute("select blocker, block_level, reason from blocks where blocked = ? or blocked = ? or blocked = ? or blocked = ? or blocked = ? or blocked = ?",
+        c.execute("select blocker, blocked, block_level, reason from blocks where blocked = ? or blocked = ? or blocked = ? or blocked = ? or blocked = ? or blocked = ?",
                   (domain, "*." + domain, wildchar, get_hash(domain), punycode, "*." + punycode))
     else:
         c.execute("select * from blocks where reason like ? and reason != ''", ("%"+reason+"%",))
@@ -48,19 +48,21 @@ def blocked(domain: str = None, reason: str = None):
 
     result = {}
     reasons = {}
+    wildcards = {}
     if domain != None:
-        for domain, block_level, reason in blocks:
+        for domain, blocked, block_level, reason in blocks:
             if block_level in result:
                 result[block_level].append(domain)
             else:
                 result[block_level] = [domain]
-                
+            if blocked == "*." + ".".join(blocked.split(".")[-blocked.count("."):]):
+                wildcards.append(domain)
             if reason != "":
                 if block_level in reasons:
                     reasons[block_level][domain] = reason
                 else:
                     reasons[block_level] = {domain: reason}
-        return {"blocks": result, "reasons": reasons}
+        return {"blocks": result, "reasons": reasons, "wildcards": wildcards}
 
     for blocker, blocked, reason, block_level in blocks:
         if block_level in result:
@@ -88,7 +90,7 @@ def index(request: Request, domain: str = None, reason: str = None):
         if not blocks.ok:
             raise HTTPException(status_code=blocks.status_code, detail=blocks.text)
         blocks = blocks.json()
-    return templates.TemplateResponse("index.html", {"request": request, "domain": domain, "blocks": blocks, "reason": reason, "info": info})
+    return templates.TemplateResponse("index.html", {"request": request, "domain": domain, "blocks": blocks, "wildcards": wildcards, "reason": reason, "info": info})
 
 if __name__ == "__main__":
     uvicorn.run("api:app", host="127.0.0.1", port=port, log_level="info")
index 4ba78b3f3e947d73072cc776d6d534c64c0bb9a2..98194025fa6c08cba2710e2e2800ca8a5bf88f6d 100644 (file)
         input[type="submit"]:hover {
             border-color: #f08;
         }
+
+        span[title] {
+            text-decoration: underline dotted;
+        }
     </style>
 </head>
 <body>
                 {% for block in blocks.blocks[block_level] %}
                     <div class="block">
                         <img src="https://proxy.duckduckgo.com/ip3/{{block}}.ico" width=16/>
-                        <b><a href="https://{{block}}">{{block}}</a></b><br/>
+                        <b><a href="https://{{block}}">{{block}}</a></b>
+                        {% if block in wildcards %}
+                            (<span title="wildcard block">&lowast;</span>)
+                        {% endif %}
+                        <br/>
                         {% if block_level in blocks.reasons %}
                             {{blocks.reasons[block_level][block]}}
                         {% endif %}