rel 0.9
This commit is contained in:
@@ -35,7 +35,7 @@ class CurrentClients:
|
|||||||
|
|
||||||
def start_client(self, client, args):
|
def start_client(self, client, args):
|
||||||
process = subprocess.Popen(
|
process = subprocess.Popen(
|
||||||
[f'{self.venv_path}/bin/python3', args.ase_receiver, client],
|
[f'{self.venv_path}/bin/python3 {args.ase_receiver} {client}'],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
text=True
|
text=True
|
||||||
@@ -82,7 +82,7 @@ def ctrl_client_mod(client, userdata, message):
|
|||||||
def get_credentials(args):
|
def get_credentials(args):
|
||||||
url = args.wallet + "get"
|
url = args.wallet + "get"
|
||||||
data = {
|
data = {
|
||||||
"master_password": "Ase#2024@wallet!",
|
"master_password": os.getenv('WALLET_MASTER_PASSWORD'),
|
||||||
"site": "mqtt_control"
|
"site": "mqtt_control"
|
||||||
}
|
}
|
||||||
response = requests.post(url, json=data)
|
response = requests.post(url, json=data)
|
||||||
|
|||||||
@@ -75,6 +75,23 @@ def get_password(site, cipher):
|
|||||||
return username, decrypted_password
|
return username, decrypted_password
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
|
# Cancella una password dal database
|
||||||
|
def delete_password(site):
|
||||||
|
conn = sqlite3.connect(db_file)
|
||||||
|
cursor = conn.cursor()
|
||||||
|
cursor.execute("DELETE FROM passwords WHERE site = ?", (site,))
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
# Ottieni la lista di tutti i siti
|
||||||
|
def list_sites():
|
||||||
|
conn = sqlite3.connect(db_file)
|
||||||
|
cursor = conn.cursor()
|
||||||
|
cursor.execute("SELECT site FROM passwords")
|
||||||
|
sites = [row[0] for row in cursor.fetchall()]
|
||||||
|
conn.close()
|
||||||
|
return sites
|
||||||
|
|
||||||
# Endpoint per aggiungere una password
|
# Endpoint per aggiungere una password
|
||||||
@app.route('/add', methods=['POST'])
|
@app.route('/add', methods=['POST'])
|
||||||
def add_password_api():
|
def add_password_api():
|
||||||
@@ -109,6 +126,29 @@ def get_password_api():
|
|||||||
|
|
||||||
return jsonify({"site": site, "username": username, "password": password})
|
return jsonify({"site": site, "username": username, "password": password})
|
||||||
|
|
||||||
|
# Endpoint per cancellare una password
|
||||||
|
@app.route('/delete', methods=['POST'])
|
||||||
|
def delete_password_api():
|
||||||
|
master_password = request.json.get('master_password')
|
||||||
|
site = request.json.get('site')
|
||||||
|
|
||||||
|
if not authenticate(master_password):
|
||||||
|
return jsonify({"error": "Master password errata"}), 403
|
||||||
|
|
||||||
|
delete_password(site)
|
||||||
|
return jsonify({"message": "Password cancellata con successo"})
|
||||||
|
|
||||||
|
# Endpoint per listare tutti i siti
|
||||||
|
@app.route('/list', methods=['POST'])
|
||||||
|
def list_sites_api():
|
||||||
|
master_password = request.json.get('master_password')
|
||||||
|
|
||||||
|
if not authenticate(master_password):
|
||||||
|
return jsonify({"error": "Master password errata"}), 403
|
||||||
|
|
||||||
|
sites = list_sites()
|
||||||
|
return jsonify({"sites": sites})
|
||||||
|
|
||||||
# Avvio dell'app
|
# Avvio dell'app
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
init_db()
|
init_db()
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ After=network.target
|
|||||||
[Service]
|
[Service]
|
||||||
WorkingDirectory=/var/lib/mosquitto
|
WorkingDirectory=/var/lib/mosquitto
|
||||||
ExecStart=/var/lib/mosquitto/.venv/bin/python3 ./control_mqtt.py
|
ExecStart=/var/lib/mosquitto/.venv/bin/python3 ./control_mqtt.py
|
||||||
|
EnvironmentFile=/var/lib/mosquitto/data/.env
|
||||||
Restart=always
|
Restart=always
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
|
|||||||
@@ -15,5 +15,6 @@ print(f"Inizio elaborazione per {username} (PID: {os.getpid()})")
|
|||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
time.sleep(5) # Simula un lavoro in corso
|
time.sleep(5) # Simula un lavoro in corso
|
||||||
|
print(os.getenv('WALLET_MASTER_PASSWORD'))
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print(f"Processo per {username} terminato")
|
print(f"Processo per {username} terminato")
|
||||||
Reference in New Issue
Block a user