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+"%",))
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:
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")
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">∗</span>)
+ {% endif %}
+ <br/>
{% if block_level in blocks.reasons %}
{{blocks.reasons[block_level][block]}}
{% endif %}