Compare commits

...
2 Commits
Author SHA1 Message Date
wiktr 07ff654baa update docker compose dns port 2026-08-24 23:13:12 +02:00
wiktr ecc110641b hotfix 2026-08-24 23:11:35 +02:00
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 ./run.sh /run.sh
COPY ./app/ /app COPY ./app/ /app
RUN mkdir /app/hosts.d/ WORKDIR /app
CMD ["/run.sh"] CMD ["/run.sh"]
+15 -4
View File
@@ -26,13 +26,22 @@ def init_db(path: str) -> None:
USERNAME TEXT NOT NULL UNIQUE, USERNAME TEXT NOT NULL UNIQUE,
PWHASH TEXT NOT NULL, PWHASH TEXT NOT NULL,
PWSALT TEXT NOT NULL, PWSALT TEXT NOT NULL,
EMAIL TEXT EMAIL TEXT,
IS_ADMIN INTEGER NOT NULL DEFAULT 0 IS_ADMIN INTEGER NOT NULL DEFAULT 0
) )
''') ''')
connection.commit() cursor.execute('''
cursor.close() 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: def check_token_domain(db_path: str, token: str, domain: str) -> bool:
with sqlite3.connect(db_path) as connection: 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() cursor = connection.cursor()
username.strip() username.strip()
email.strip()
if email is not None:
email.strip()
cursor.execute(''' cursor.execute('''
SELECT COUNT(*) FROM Users SELECT COUNT(*) FROM Users
+6 -6
View File
@@ -1,11 +1,12 @@
from flask import Flask, jsonify, request, render_template, redirect, session, flash from flask import Flask, jsonify, request, render_template, redirect, session, flash
import auth import auth
import re import re
from os import environ, urandom
HOSTS_PATH = "/app/hosts.d/izbi" HOSTS_PATH = ( environ["HOSTS"] if "HOSTS" in environ else"/app/data/hosts.d/" ) + "/izbi"
DB_PATH = "/app/sqlite.db" 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["SESSION_TYPE"] = "memcached"
app.config["PERMANENT_SESSION_LIFETIME"] = 3600 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 = {} hosts = {}
def update_hosts(path: str, hosts: dict = {}) -> bool: def update_hosts(path: str, hosts: dict = {}) -> bool:
try: try:
hosts_str = "" 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: if "pass" not in request.form or "pass-new" not in request.form or "pass-rep" not in request.form:
flash("password change failed") flash("password change failed")
return reidrect("/dashboard") return redirect("/dashboard")
if request.form["pass"] == "" or request.form["pass-new"] == "" or request.form["pass-rep"] == "": if request.form["pass"] == "" or request.form["pass-new"] == "" or request.form["pass-rep"] == "":
flash("password change failed") flash("password change failed")
return redirect("/dashboard") return redirect("/dashboard")
@@ -281,4 +281,4 @@ def update_addr():
if __name__ == '__main__': if __name__ == '__main__':
auth.init_db(DB_PATH) 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 image: izbi-dns
build: . build: .
restart: unless-stopped restart: unless-stopped
environment:
- HOSTS_PATH=/app/data/hosts.d/
- DB_PATH=/app/data/sqlite.db
- SECRET_KEY=CHANGEME
ports: ports:
- "127.0.0.1:8080:8080" - "127.0.0.1:8080:8080"
- "127.0.0.1:55:5353/udp" - "53:5353/udp"
volumes:
- "./data/:/app/data/"
+3 -1
View File
@@ -1,6 +1,8 @@
#!/bin/sh #!/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 & /usr/local/bin/python3 /app/main.py &