add password wallet
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import paho.mqtt.subscribe as subscribe
|
||||
import paho.mqtt.publish as publish
|
||||
import subprocess
|
||||
import argparse
|
||||
import requests
|
||||
import json
|
||||
import sys
|
||||
import os
|
||||
import logging
|
||||
|
||||
@@ -15,6 +14,7 @@ class CurrentClients:
|
||||
data = json.load(file)
|
||||
self.active_clients_list = [client["username"] for client in data["clients"]]
|
||||
self.active_clients_pids = {}
|
||||
self.venv_path = sys.prefix
|
||||
for username in self.active_clients_list:
|
||||
if username.endswith("_ase"):
|
||||
self.start_client(username, args)
|
||||
@@ -35,7 +35,7 @@ class CurrentClients:
|
||||
|
||||
def start_client(self, client, args):
|
||||
process = subprocess.Popen(
|
||||
["python3", args.ase_receiver, client],
|
||||
[f'{self.venv_path}/bin/python3', args.ase_receiver, client],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
text=True
|
||||
@@ -79,6 +79,19 @@ def ctrl_client_mod(client, userdata, message):
|
||||
if found_command:
|
||||
command_functions[found_command[0]](datas, userdata)
|
||||
|
||||
def get_credentials(args):
|
||||
url = args.wallet + "get"
|
||||
data = {
|
||||
"master_password": "Ase#2024@wallet!",
|
||||
"site": "mqtt_control"
|
||||
}
|
||||
response = requests.post(url, json=data)
|
||||
if response.status_code != 200:
|
||||
logging.error("Error to get pwd from wallet")
|
||||
exit(1)
|
||||
|
||||
return response.json().get('password')
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
|
||||
@@ -87,7 +100,7 @@ def main():
|
||||
parser.add_argument('-T', '--pub_topic', default="$CONTROL/dynamic-security/v1")
|
||||
parser.add_argument('-q', '--qos', type=int,default=0)
|
||||
parser.add_argument('-u', '--username', default="admin")
|
||||
parser.add_argument('-p', '--password', default="BatManu#171017")
|
||||
parser.add_argument('-w', '--wallet', default="http://localhost:5000/")
|
||||
parser.add_argument('-P', '--port', type=int, default=1883)
|
||||
parser.add_argument('-l', '--log', default='/var/log/mosquitto/subscriber_manager.log')
|
||||
parser.add_argument('-L', '--log_level', choices=['DEBUG', 'INFO', 'WARNING', 'ERROR'], default='INFO')
|
||||
@@ -102,8 +115,8 @@ def main():
|
||||
filename=args.log
|
||||
)
|
||||
|
||||
auth = {'username': args.username, 'password': get_credentials(args)}
|
||||
cur_clients = CurrentClients(args)
|
||||
auth = {'username': args.username, 'password': args.password}
|
||||
userdata = {'args': args, 'cur_clients': cur_clients, 'auth': auth}
|
||||
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user