BananeMan

Untitled

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