Archived
1
0
Fork 0

Lot of little stupid fix

This commit is contained in:
Ethanell 2019-05-22 15:40:28 +02:00
parent d3d29e686f
commit 673807b655
5 changed files with 23 additions and 6 deletions

View file

@ -13,3 +13,8 @@ if not isfile("Settings.conf"):
with shelve.open("Settings.conf") as settings:
settings["keys"] = keys
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"])

View file

@ -1,4 +1,4 @@
import io, socket, subprocess, shelve
import io, socket, subprocess, shelve, time
from requests import post, get
from flask import request, Flask
#hostapd system
@ -32,6 +32,7 @@ def web_setup():
return "Error"
else:
writeconfig(request.args.get("ssid"), request.args.get("password"))
time.sleep(10)
if testinternet():
id = request.args.get("id")
with shelve.open("Settings.conf") as settings:

View file

@ -8,7 +8,10 @@ def web_unlock():
return "Error"
else:
with shelve.open("Settings.conf") as settings:
if "token" in settings:
token = settings["token"]
else:
return "System not setup !"
if request.args.get("token") != token:
return "Invalid Token"
if request.args.get("state") == "open":

14
lock.py
View file

@ -1,7 +1,10 @@
from gpiozero import LED
from gpiozero import LED #OutputDevice
import shelve, io, requests
mac = io.open("/sys/class/net/wlan0/address").read()
led = LED(17)
#open = OutputDevice(17, initial_value = False)
#close = OutputDevice(27, initial_value = False)
def state(current : bool = None):
with shelve.open("Settings.conf") as settings:
@ -17,14 +20,17 @@ def state(current : bool = None):
def unlock(keyid = None):
led.on()
#close.off()
#open.on()
state(True)
mac = io.open("/sys/class/net/wlan0/address").read()
requests.get(f"http://vps.flifloo.fr:5001/logs?mac={mac}&state=unlock&id={str(keyid)}")
r = requests.get(f"http://vps.flifloo.fr:5001/logs?mac={mac}&state=unlock&id={str(keyid)}")
def lock(keyid = None):
#open.off()
#close.on()
led.off()
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):
if state():

View file

@ -11,6 +11,8 @@ while True:
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.verify(inp)
except KeyboardInterrupt:
break
except:
pass
else: