Lot of little stupid fix
This commit is contained in:
parent
d3d29e686f
commit
673807b655
5 changed files with 23 additions and 6 deletions
5
Core.py
5
Core.py
|
@ -13,3 +13,8 @@ if not isfile("Settings.conf"):
|
||||||
with shelve.open("Settings.conf") as settings:
|
with shelve.open("Settings.conf") as settings:
|
||||||
settings["keys"] = keys
|
settings["keys"] = keys
|
||||||
settings["register"] = list()
|
settings["register"] = list()
|
||||||
|
|
||||||
|
|
||||||
|
subprocess.check_call(["screen", "-S", "setup", "-d", "-m", "sudo", "python3.7", "Setup.py"])
|
||||||
|
subprocess.check_call(["screen", "-S", "internet", "-d", "-m", "sudo", "python3.7", "internet.py"])
|
||||||
|
subprocess.check_call(["screen", "-S", "yubikey", "-m", "sudo", "python3.7", "yubikey.py"])
|
||||||
|
|
3
Setup.py
3
Setup.py
|
@ -1,4 +1,4 @@
|
||||||
import io, socket, subprocess, shelve
|
import io, socket, subprocess, shelve, time
|
||||||
from requests import post, get
|
from requests import post, get
|
||||||
from flask import request, Flask
|
from flask import request, Flask
|
||||||
#hostapd system
|
#hostapd system
|
||||||
|
@ -32,6 +32,7 @@ def web_setup():
|
||||||
return "Error"
|
return "Error"
|
||||||
else:
|
else:
|
||||||
writeconfig(request.args.get("ssid"), request.args.get("password"))
|
writeconfig(request.args.get("ssid"), request.args.get("password"))
|
||||||
|
time.sleep(10)
|
||||||
if testinternet():
|
if testinternet():
|
||||||
id = request.args.get("id")
|
id = request.args.get("id")
|
||||||
with shelve.open("Settings.conf") as settings:
|
with shelve.open("Settings.conf") as settings:
|
||||||
|
|
|
@ -8,7 +8,10 @@ def web_unlock():
|
||||||
return "Error"
|
return "Error"
|
||||||
else:
|
else:
|
||||||
with shelve.open("Settings.conf") as settings:
|
with shelve.open("Settings.conf") as settings:
|
||||||
token = settings["token"]
|
if "token" in settings:
|
||||||
|
token = settings["token"]
|
||||||
|
else:
|
||||||
|
return "System not setup !"
|
||||||
if request.args.get("token") != token:
|
if request.args.get("token") != token:
|
||||||
return "Invalid Token"
|
return "Invalid Token"
|
||||||
if request.args.get("state") == "open":
|
if request.args.get("state") == "open":
|
||||||
|
|
14
lock.py
14
lock.py
|
@ -1,7 +1,10 @@
|
||||||
from gpiozero import LED
|
from gpiozero import LED #OutputDevice
|
||||||
import shelve, io, requests
|
import shelve, io, requests
|
||||||
|
|
||||||
|
mac = io.open("/sys/class/net/wlan0/address").read()
|
||||||
led = LED(17)
|
led = LED(17)
|
||||||
|
#open = OutputDevice(17, initial_value = False)
|
||||||
|
#close = OutputDevice(27, initial_value = False)
|
||||||
|
|
||||||
def state(current : bool = None):
|
def state(current : bool = None):
|
||||||
with shelve.open("Settings.conf") as settings:
|
with shelve.open("Settings.conf") as settings:
|
||||||
|
@ -17,14 +20,17 @@ def state(current : bool = None):
|
||||||
|
|
||||||
def unlock(keyid = None):
|
def unlock(keyid = None):
|
||||||
led.on()
|
led.on()
|
||||||
|
#close.off()
|
||||||
|
#open.on()
|
||||||
state(True)
|
state(True)
|
||||||
mac = io.open("/sys/class/net/wlan0/address").read()
|
r = requests.get(f"http://vps.flifloo.fr:5001/logs?mac={mac}&state=unlock&id={str(keyid)}")
|
||||||
requests.get(f"http://vps.flifloo.fr:5001/logs?mac={mac}&state=unlock&id={str(keyid)}")
|
|
||||||
|
|
||||||
def lock(keyid = None):
|
def lock(keyid = None):
|
||||||
|
#open.off()
|
||||||
|
#close.on()
|
||||||
led.off()
|
led.off()
|
||||||
state(False)
|
state(False)
|
||||||
requests.get(f"http://vps.flifloo.fr:5001/logs?mac={mac}&state=lock&id={str(keyid)}")
|
r = requests.get(f"http://vps.flifloo.fr:5001/logs?mac={mac}&state=lock&id={str(keyid)}")
|
||||||
|
|
||||||
def switch(keyid = None):
|
def switch(keyid = None):
|
||||||
if state():
|
if state():
|
||||||
|
|
|
@ -11,6 +11,8 @@ while True:
|
||||||
client = Yubico(id, settings["keys"][id], api_urls=('http://localhost/wsapi/2.0/verify',))
|
client = Yubico(id, settings["keys"][id], api_urls=('http://localhost/wsapi/2.0/verify',))
|
||||||
#client = Yubico(1, "QMho+Y4mtsY+KbCYu1gRKtDtwAM=", api_urls=('http://localhost/wsapi/2.0/verify',))
|
#client = Yubico(1, "QMho+Y4mtsY+KbCYu1gRKtDtwAM=", api_urls=('http://localhost/wsapi/2.0/verify',))
|
||||||
client.verify(inp)
|
client.verify(inp)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
break
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
|
Reference in a new issue