Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --*****************************--
- --********BANQUE SERVEUR*******--
- --*****************************--
- --Décalaration de variable
- local checkstartup = false
- local checkfiles = false
- local checkshell2 = false
- local filesnumb = 0
- fileserror = 0
- local id = os.getComputerID()
- local st = ""
- local ver = "0.0.1"
- local string = ""
- local usersf = "/files/users/"
- local adminsf = "/files/admins.txt"
- local atmsf = "/files/atms.txt"
- local ronda = "/libs/rondanet"
- local crypt = "/disk/crypto"
- local privekey = ""
- local publickey = ""
- local allkey = ""
- local coter = "left"
- --Fin de décalaration de variable
- function startup()
- print("Démarage du serveur")
- print("Id de l'ordinateur:", id)
- print("Version: "..ver)
- print("Vérification des fichiers utilisateur")
- verif(usersf)
- verif(adminsf)
- verif(crypt)
- verif(atmsf)
- verif(ronda)
- if fileserror == 0 then
- print(filesnumb, "fichiers on été vérifier")
- else
- print(fileserror, "fichiers on n'on pas été vérifier !")
- sleep(2)
- os.shutdown()
- end
- print("\n\n\n")
- print("Load des apis")
- os.loadAPI(crypt)
- os.loadAPI(ronda)
- print("Création des clées de cryptage")
- allkey = crypto.generate()
- publickey = allkey.public
- privkey = allkey.private
- print("Ouverture de rondanet")
- rondanet.open(coter)
- print("Fin du startup")
- parallel.waitForAll(redne, idre)
- end
- function verif(var)
- if fs.exists(var) then
- print(var.." existant")
- filesnumb = filesnumb + 1
- else
- print(var.." n'existe pas !")
- fileserror = fileserror + 1
- sleep(10)
- os.shutdown()
- end
- end
- function files(string)
- local response
- return(response)
- end
- function redne()
- print("Ecoute activée !")
- while true do
- local senderid, mess, proto = rondanet.receive("superproto")
- print("[BANQUE]", "[SenderID]:",senderid,"[Message]:", mess)
- local table = textutils.unserialize(mess)
- if table.action == "login" then
- local user = table.User
- local pass = table.Pass
- if fs.exists("/files/users/"..user) then
- local file fs.open("/files/users/"..user, "r")
- local id = file.readLine()
- local pseudo = file.readLine()
- local mot = file.readLine()
- local argent = file.readLine()
- local historique = file.readLine()
- local entreprise = file.readLine()
- file.close()
- if user == pseudo and mot == pass then
- local table = {action = "login", user = pseudo, response = "yes"}
- rondanet.send(senderid, table)
- else
- local table = {action = "login", user = pseudo, response = "no"}
- rondanet.send(senderid, table)
- end
- elseif table.action == "keyretrive" then
- rondanet.send(senderid, publickey)
- print("Clée public envoyée a",senderid)
- else
- print("Pas implementer", table.action)
- end
- end
- end
- rondanet.close()
- end
- function shell2()
- shell.openTab("shell")
- end
- function acces()
- end
- function token(pseudo)
- end
- function idre()
- rednet.open(coter)
- rednet.host("2banque", "server")
- end
- parallel.waitForAll(startup, shell2)
Add Comment
Please, Sign In to add comment