diff --git a/app.py b/app.py index 53529b5..a15bf70 100644 --- a/app.py +++ b/app.py @@ -106,7 +106,7 @@ def create_conf_post(): if os.path.exists(folder): shutil.rmtree(folder) - db.add_conf_image(config_name+".squashfs", token_name) + db.add_conf_image(config_name+".squashfs", token_name, ip) return send_file(os.path.join(app.config['UPLOAD_FOLDER'], config_name+".pub")) diff --git a/configs/create.sh b/configs/create.sh index bfbfb7d..d38086d 100755 --- a/configs/create.sh +++ b/configs/create.sh @@ -28,7 +28,7 @@ shift $((OPTIND-1)) CONFIGS=$(pwd) echo "${CONFIGS}" - +squashfs #sudo apt update #sudo apt install cmake make g++ gcc libssl-dev libgmp-dev diff --git a/db.py b/db.py index 0e067fb..94e7055 100644 --- a/db.py +++ b/db.py @@ -25,7 +25,8 @@ def connect(): id SERIAL PRIMARY KEY, image_name VARCHAR(255) NOT NULL, token VARCHAR(255) NOT NULL, - created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + vpn_ip INET );""") conn.commit() cur.execute(""" @@ -75,13 +76,13 @@ def get_one(sql, value): return None -def add_conf_image(name, token): +def add_conf_image(name, token, ip): connect() with get_cur() as cur: cur.execute(""" - INSERT INTO image (image_name, token) - VALUES (%s, %s) - """, (name, token,)) + INSERT INTO image (image_name, token, vpn_ip) + VALUES (%s, %s, %s) + """, (name, token,ip, )) conn.commit() @@ -182,11 +183,11 @@ def get_images(): connect() with get_cur() as cur: cur.execute(""" - SELECT id, token, image_name FROM image""") + SELECT id, token, image_name, vpn_ip FROM image""") try: images_all = images.ImageManager() for row in cur.fetchall(): - image = images.Image(id = row[0], token=row[1], name=row[2]) + image = images.Image(id = row[0], token=row[1], name=row[2], vpn_ip=row[3]) images_all.add_image(image) return images_all except: diff --git a/images.py b/images.py index 1462a2b..491bf2b 100644 --- a/images.py +++ b/images.py @@ -1,8 +1,9 @@ class Image: - def __init__(self, id, token, name): + def __init__(self, id, token, name, vpn_ip): self.id = id self.name = name self.token = token + self.vpn_ip = vpn_ip class ImageManager: def __init__(self): diff --git a/templates/images.html b/templates/images.html index 6ffa24d..7436f63 100644 --- a/templates/images.html +++ b/templates/images.html @@ -12,6 +12,7 @@