BananeMan

Untitled

Sep 21st, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. --*****************************--
  2. --********BANQUE SERVEUR*******--
  3. --*****************************--
  4.  
  5. --Décalaration de variable
  6.  
  7. local checkstartup = false
  8. local checkfiles = false
  9. local checkshell2 = false
  10. local filesnumb = 0
  11. fileserror = 0
  12. local id = os.getComputerID()
  13. local st = ""
  14. local ver = "0.0.1"
  15. local string = ""
  16.  
  17. local usersf = "/files/users/"
  18. local adminsf = "/files/admins.txt"
  19. local atmsf = "/files/atms.txt"
  20. local ronda = "/libs/rondanet"
  21. local crypto = "/disk/crypto"
  22.  
  23. local privekey = ""
  24. local publickey = ""
  25. local allkey = ""
  26. --Fin de décalaration de variable
  27.  
  28. function startup()
  29. print("Démarage du serveur")
  30. print("Id de l'ordinateur:", id)
  31. print("Version: "..ver)
  32. print("Vérification des fichiers utilisateur")
  33. verif(usersf)
  34. verif(adminsf)
  35. verif(crypto)
  36. verif(atmsf)
  37. verif(ronda)
  38. if fileserror == 0 then
  39. print(filesnumb, "fichiers on été vérifier")
  40. else
  41. print(fileserror, "fichiers on n'on pas été vérifier !")
  42. sleep(2)
  43. os.shutdown()
  44. end
  45.  
  46. print("\n\n\n")
  47. print("Load des apis")
  48. os.loadAPI(crypto)
  49. os.loadAPI(ronda)
  50. print("Création des clées de cryptage")
  51. allkey = crypto.generate()
  52. publickey = allkey.public
  53. privkey = allkey.private
  54. print("Ouverture de rondanet")
  55. rondanet.open("front")
  56. print("Fin du startup")
  57. parallel.waitForAll(redne, idre)
  58. end
  59.  
  60. function verif(var)
  61. if fs.exists(var) then
  62. print(var.." existant")
  63. filesnumb = filesnumb + 1
  64. else
  65. print(var.." n'existe pas !")
  66. fileserror = fileserror + 1
  67. sleep(10)
  68. os.shutdown()
  69. end
  70. end
  71.  
  72. function files(string)
  73. local response
  74.  
  75. return(response)
  76. end
  77.  
  78. function redne()
  79. print("Ecoute activée !")
  80. while true do
  81. local senderid, mess, proto = rondanet.receive("superproto")
  82. print("[BANQUE]", "[SenderID]:",senderid,"[Message]:", mess)
  83. local table = textutils.unserialize(mess)
  84. if table.action == "login" then
  85. local user = table.User
  86. local pass = table.Pass
  87. if fs.exists("/files/users/"..user) then
  88. local file fs.open("/files/users/"..user, "r")
  89.  
  90. local id = file.readLine()
  91. local pseudo = file.readLine()
  92. local mot = file.readLine()
  93. local argent = file.readLine()
  94. local historique = file.readLine()
  95. local entreprise = file.readLine()
  96. file.close()
  97. if user == pseudo and mot == pass then
  98. local table = {action = "login", user = pseudo, response = "yes"}
  99. rondanet.send(senderid, table)
  100. else
  101. local table = {action = "login", user = pseudo, response = "no"}
  102. rondanet.send(senderid, table)
  103. end
  104. elseif table.action == "keyretrive" then
  105. rondanet.send(senderid, publickey)
  106. print("Clée public envoyée a",senderid)
  107. else
  108. print("Pas implementer", table.action)
  109. end
  110. end
  111. end
  112. rondanet.close()
  113. end
  114.  
  115. function shell2()
  116. shell.openTab("shell")
  117. end
  118.  
  119. function acces()
  120. end
  121.  
  122. function token(pseudo)
  123.  
  124. end
  125.  
  126. function idre()
  127. while true do
  128. if rondanet.isOpen("left") then
  129. print("Host has opened")
  130. rondanet.host("babanque", "server")
  131. break
  132. else
  133. sleep(5)
  134. end
  135. end
  136. end
  137.  
  138. parallel.waitForAll(startup, shell2)
Add Comment
Please, Sign In to add comment