This commit is contained in:
2026-08-24 23:11:35 +02:00
parent 42fe8d9a76
commit ecc110641b
5 changed files with 32 additions and 13 deletions
+1 -1
View File
@@ -11,6 +11,6 @@ RUN pip3 install -r /requirements.txt
COPY ./run.sh /run.sh
COPY ./app/ /app
RUN mkdir /app/hosts.d/
WORKDIR /app
CMD ["/run.sh"]
+15 -4
View File
@@ -26,13 +26,22 @@ def init_db(path: str) -> None:
USERNAME TEXT NOT NULL UNIQUE,
PWHASH TEXT NOT NULL,
PWSALT TEXT NOT NULL,
EMAIL TEXT
EMAIL TEXT,
IS_ADMIN INTEGER NOT NULL DEFAULT 0
)
''')
connection.commit()
cursor.close()
cursor.execute('''
SELECT COUNT(*) FROM Users
''')
if cursor.fetchone()[0] == 0:
username = "root"
password = urandom(8).hex()
create_user(path, username, password, is_admin=True)
print(f"No users detected, created new admin\nUser: {username}\nPass: {password}", flush=True)
def check_token_domain(db_path: str, token: str, domain: str) -> bool:
with sqlite3.connect(db_path) as connection:
@@ -287,7 +296,9 @@ def create_user(db_path: str, username: str, password: str, domains: list = [],
cursor = connection.cursor()
username.strip()
email.strip()
if email is not None:
email.strip()
cursor.execute('''
SELECT COUNT(*) FROM Users
+6 -6
View File
@@ -1,11 +1,12 @@
from flask import Flask, jsonify, request, render_template, redirect, session, flash
import auth
import re
from os import environ, urandom
HOSTS_PATH = "/app/hosts.d/izbi"
DB_PATH = "/app/sqlite.db"
HOSTS_PATH = ( environ["HOSTS"] if "HOSTS" in environ else"/app/data/hosts.d/" ) + "/izbi"
DB_PATH = environ["DB_PATH"] if "DB_PATH" in environ else "/app/data/sqlite.db"
@@ -14,12 +15,11 @@ app.config["SESSION_PERMANENT"] = True
app.config["SESSION_TYPE"] = "memcached"
app.config["PERMANENT_SESSION_LIFETIME"] = 3600
app.config["SECRET_KEY"] = "dsadasda"
app.config["SECRET_KEY"] = environ["SECRET_KEY"] if "SECRET_KEY" in environ else urandom(32).hex()
hosts = {}
def update_hosts(path: str, hosts: dict = {}) -> bool:
try:
hosts_str = ""
@@ -216,7 +216,7 @@ def change_password():
if "pass" not in request.form or "pass-new" not in request.form or "pass-rep" not in request.form:
flash("password change failed")
return reidrect("/dashboard")
return redirect("/dashboard")
if request.form["pass"] == "" or request.form["pass-new"] == "" or request.form["pass-rep"] == "":
flash("password change failed")
return redirect("/dashboard")
@@ -281,4 +281,4 @@ def update_addr():
if __name__ == '__main__':
auth.init_db(DB_PATH)
app.run(host="0.0.0.0", port=8080, debug=True)
app.run(host="0.0.0.0", port=8080, debug=False)
+7 -1
View File
@@ -3,6 +3,12 @@ services:
image: izbi-dns
build: .
restart: unless-stopped
environment:
- HOSTS_PATH=/app/data/hosts.d/
- DB_PATH=/app/data/sqlite.db
- SECRET_KEY=CHANGEME
ports:
- "127.0.0.1:8080:8080"
- "127.0.0.1:55:5353/udp"
- "127.0.0.1:5353:5353/udp"
volumes:
- "./data/:/app/data/"
+3 -1
View File
@@ -1,6 +1,8 @@
#!/bin/sh
/usr/sbin/dnsmasq -d --hostsdir /app/hosts.d/ -p 5353 &
mkdir -p "$HOSTS_PATH"
/usr/sbin/dnsmasq -d --hostsdir "$HOSTS_PATH" -p 5353 &
/usr/local/bin/python3 /app/main.py &