Exemplo n.º 1
0
 else:
     write_length = 0
     while write_length != len(packet):
         try:
             write_length = cache.sendto(packet, CACHESOCK)
         except:
             pass
     cache_query = ''
     while len(cache_query) != 1:
         if len(POLL([0], [], [], 1)[0]) == 1:
             try:
                 cache_query = cache.recv(1)
             except:
                 pass
     if cache_query == '\x00':
         if filter(udpmsg4.unframe(packet)) != 0:
             os.write(
                 2,
                 'hub.py: ' + CLIENT + ' successful read from client\n')
             for REMOTE in REMOTE_SOCKS:
                 if not REMOTE in SOCKET_QUEUE:
                     try:
                         SENDSOCKETS[REMOTE] = socket.socket(
                             socket.AF_UNIX, socket.SOCK_DGRAM)
                         SENDSOCKETS[REMOTE].setblocking(0)
                         try:
                             os.remove(HUBDIR + '/send/' + PID + 'TO' +
                                       REMOTE)
                         except:
                             pass
                         SENDSOCKETS[REMOTE].bind(
Exemplo n.º 2
0
 else:
     write_length=0
     while write_length!=len(packet):
         try:
             write_length=cache.sendto(packet,CACHESOCK)
         except:
             pass
     cache_query=''
     while len(cache_query)!=1:
         if len(POLL([0],[],[],1)[0])==1:
             try:
                 cache_query=cache.recv(1)
             except:
                 pass
     if cache_query=='\x00':
         if filter(udpmsg4.unframe(packet))!=0:
             os.write(2,'hub.py: '+CLIENT+' successful read from client\n')
             for REMOTE in REMOTE_SOCKS:
                 if not REMOTE in SOCKET_QUEUE:
                     try:
                         SENDSOCKETS[REMOTE]=socket.socket(socket.AF_UNIX,socket.SOCK_DGRAM)
                         SENDSOCKETS[REMOTE].setblocking(0)
                         try:
                             os.remove(HUBDIR+'/send/'+PID+'TO'+REMOTE)
                         except:
                             pass
                         SENDSOCKETS[REMOTE].bind((HUBDIR+'/send/'+PID+'TO'+REMOTE))
                         SOCKET_QUEUE[REMOTE]=collections.deque([],MAX_QUEUE)
                     except socket.error, ex:
                         if ex.errno == 24:
                             os.write(2,'hub.py: '+CLIENT+' failed to create sendsocket for '+REMOTE+'\n')
Exemplo n.º 3
0
     while packet_length != len(packet[2::]):
         if 6 in selections([6], [], [], TIMEOUT)[0]:
             buffer = os.read(6, packet_length - len(packet[2::]))
             if buffer != "":
                 packet += buffer
             else:
                 break
 except:
     pass
 if packet_length == 0 or len(packet) <= 2:
     os.write(2, "ucspi-server2hub: " + CLIENT + " connection to server died\n")
     break
 elif packet_length != len(packet[2::]):
     os.write(2, "ucspi-server2hub: " + CLIENT + " fatal protocol error from server\n")
     break
 kvps = udpmsg4.unframe(packet)
 checksum = sha512(packet).digest()
 if kvps == 0:
     os.write(2, "ucspi-server2hub: " + CLIENT + " rejected protocol error from server\n")
 elif not checksum in SHA512_CACHE and filter(kvps) != 0:
     CLIENT_QUEUE += [packet]
     SHA512_CACHE += [checksum]
     os.write(
         2,
         "ucspi-server2hub: "
         + CLIENT
         + " CLIENT_QUEUE=["
         + str(len(CLIENT_QUEUE))
         + "] SERVER_QUEUE=["
         + str(len(SERVER_QUEUE))
         + "]\n",
Exemplo n.º 4
0
                        packet += buffer
                    else:
                        break
        except:
            pass
        if packet_length == 0 or len(packet) <= 2:
            os.write(
                2,
                'ucspi-server2hub: ' + CLIENT + ' connection to server died\n')
            break
        elif packet_length != len(packet[2::]):
            os.write(
                2, 'ucspi-server2hub: ' + CLIENT +
                ' fatal protocol error from server\n')
            break
        kvps = udpmsg4.unframe(packet)
        checksum = sha512(packet).digest()
        if kvps == 0:
            os.write(
                2, 'ucspi-server2hub: ' + CLIENT +
                ' rejected protocol error from server\n')
        elif not checksum in SHA512_CACHE and filter(kvps) != 0:
            CLIENT_QUEUE += [packet]
            SHA512_CACHE += [checksum]
            os.write(
                2, 'ucspi-server2hub: ' + CLIENT + ' CLIENT_QUEUE=[' +
                str(len(CLIENT_QUEUE)) + '] SERVER_QUEUE=[' +
                str(len(SERVER_QUEUE)) + ']\n')

    if 0 in readable:
        try: