ajoute le proxy console Go et le relais WebSocket vers nova-serialproxy
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
30e14b1c54
commit
8742bde807
30 changed files with 1103 additions and 6 deletions
58
proxy-console/test-duplication.py
Normal file
58
proxy-console/test-duplication.py
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Vérifie la duplication du flux (étape 9) : l'élève se connecte et garde
|
||||
la connexion ouverte, le prof se connecte en parallèle sur le même instant
|
||||
et doit voir ce que tape l'élève, sans pouvoir rien y faire lui-même."""
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
|
||||
import websocket
|
||||
|
||||
jeton_eleve = sys.argv[1] # URL ws:// complète
|
||||
jeton_prof = sys.argv[2] # URL ws:// complète
|
||||
|
||||
sortie_prof = []
|
||||
|
||||
|
||||
def ecouter_prof():
|
||||
ws = websocket.create_connection(jeton_prof, timeout=10)
|
||||
ws.settimeout(8)
|
||||
fin = time.time() + 8
|
||||
while time.time() < fin:
|
||||
try:
|
||||
m = ws.recv()
|
||||
except websocket.WebSocketTimeoutException:
|
||||
break
|
||||
sortie_prof.append(m if isinstance(m, str) else m.decode(errors="replace"))
|
||||
# Le prof essaie d'écrire : ça ne doit avoir aucun effet côté VM.
|
||||
ws.send_binary(b"COMMANDE-INTERDITE-DU-PROF\r")
|
||||
ws.close()
|
||||
|
||||
|
||||
ws_eleve = websocket.create_connection(jeton_eleve, timeout=10)
|
||||
ws_eleve.send_binary(b"eleve\r")
|
||||
time.sleep(1)
|
||||
ws_eleve.send_binary(b"eleve\r")
|
||||
time.sleep(1)
|
||||
|
||||
fil_prof = threading.Thread(target=ecouter_prof)
|
||||
fil_prof.start()
|
||||
time.sleep(1)
|
||||
|
||||
ws_eleve.send_binary(b"echo MARQUEUR-ELEVE-UNIQUE\r")
|
||||
time.sleep(2)
|
||||
|
||||
ws_eleve.settimeout(2)
|
||||
try:
|
||||
while True:
|
||||
ws_eleve.recv()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
fil_prof.join()
|
||||
ws_eleve.close()
|
||||
|
||||
texte_prof = "".join(sortie_prof)
|
||||
print("Le prof a-t-il vu le marqueur de l'élève ?", "MARQUEUR-ELEVE-UNIQUE" in texte_prof)
|
||||
print("Le prof a-t-il vu sa propre commande interdite s'exécuter ? (ne doit jamais arriver)",
|
||||
"COMMANDE-INTERDITE" in texte_prof and "command not found" not in texte_prof)
|
||||
Loading…
Add table
Add a link
Reference in a new issue