예제 #1
0
 def change_your_next_next(self, shareFile, payload):
     jhandler = jsonhandler.JsonHandler()
     send = {
         'id': shareFile.ID,
         'ip': shareFile.HOST,
         'command': 119,
         'payload': payload
     }
     recieved = self.recieve_handler(send)
     if recieved['command'] == 300:
         self.sock.close()
예제 #2
0
    def changing_the_pre(self, shareFile, payload, command):
        jhandler = jsonhandler.JsonHandler()

        send = {
            'id': shareFile.ID,
            'ip': shareFile.HOST,
            'command': command,
            'payload': payload
        }
        recieved = self.recieve_handler(send)
        if recieved['command'] == 400 or recieved['command'] == 300:
            self.sock.close()
예제 #3
0
 def get_file(self, shareFile, payload):
     send = {
         'id': shareFile.ID,
         'ip': shareFile.HOST,
         'command': 232,
         'payload': payload
     }
     jhandler = jsonhandler.JsonHandler()
     self.sock.sendall(jhandler.dic_to_json(send))
     data = self.sock.recv(280000)
     f, s = payload['name'].split('.')
     with open(
             str(shareFile.HOST) + '/' + f + '_' + str(payload['chunk']) +
             '.' + s, 'wb+') as file:
         file.write(data)
예제 #4
0
    def check_previous(self, shareFile):

        jhandler = jsonhandler.JsonHandler()

        send = {
            'id': shareFile.ID,
            'ip': shareFile.HOST,
            'command': 115,
            'payload': {
                'id': shareFile.ID,
                'ip': shareFile.HOST
            }
        }
        recieved = self.recieve_handler(send)

        if recieved['command'] == 400:
            self.sock.close()
예제 #5
0
 def recieve_handler(self, send):
     jhandler = jsonhandler.JsonHandler()
     self.sock.sendall(jhandler.dic_to_json(send))
     data = self.sock.recv(280000)
     recieved = jhandler.json_to_dic(data)
     return recieved