hotfix
This commit is contained in:
+1
-1
@@ -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
@@ -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
@@ -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
@@ -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"
|
- "127.0.0.1:5353:5353/udp"
|
||||||
|
volumes:
|
||||||
|
- "./data/:/app/data/"
|
||||||
|
|||||||
Reference in New Issue
Block a user