|
|
@@ -40,15 +40,16 @@ class ClientThread(threading.Thread): |
|
|
|
# print ("J'envoie la chaine randomise au client : %s" % (random_chaine)) |
|
|
|
self.clientsocket.send(encrypt(random_chaine)) |
|
|
|
# Choix d'un chiffre au hasard et d'une lettre en fonction |
|
|
|
random_indice = random.randint(1,26) |
|
|
|
random_indice = random.randint(1,25) |
|
|
|
random_carac = random_chaine[random_indice] |
|
|
|
self.clientsocket.send(encrypt(random_carac)) |
|
|
|
# print ("Je veux l'indice du caractere : %s" % (random_carac)) |
|
|
|
# print ("Le client doit donc me renvoyer : %s" % (random_indice)) |
|
|
|
# Reception |
|
|
|
r = decrypt(self.clientsocket.recv(2048)) |
|
|
|
# print ("Le client a envoye : %s" % (r)) |
|
|
|
print ("Le client a envoye : %s" % (r)) |
|
|
|
if int(r) == int(random_indice): # Si le client a bien repondu |
|
|
|
change = 0 |
|
|
|
fichier=open(fichier_zone, 'r') # on ouvre le fichier |
|
|
|
new_line=[] # on prepare une liste vide qui va contenir les changements |
|
|
|
for line in fichier: # on lit chaque ligne |
|
|
@@ -59,6 +60,8 @@ class ClientThread(threading.Thread): |
|
|
|
s = "\t" |
|
|
|
line = s.join(item)+"\n" # on reforme la ligne |
|
|
|
if "home" in item: # si un des items est le mot home |
|
|
|
print item[3] |
|
|
|
print self.ip |
|
|
|
if item[3] != self.ip : # Si IP differente |
|
|
|
change = 1 |
|
|
|
item[3] = self.ip+"\n" |
|
|
@@ -66,6 +69,7 @@ class ClientThread(threading.Thread): |
|
|
|
line = s.join(item) |
|
|
|
new_line.append(line) |
|
|
|
if change == 1 : |
|
|
|
print "on change" |
|
|
|
# RESTE A FAIRE |
|
|
|
# deplacer l'ancien fichier en old |
|
|
|
# deplacer le nouveau fichier |