Example #1
0
def getTrace(visit_file, direction=None):
    with open(visit_file, 'r') as f:
        sample = json.load(f)

    Config.hostname.update(sample[u'ip_to_name'])
    webId, traceId = sample['visit_log'][u'current_url'], sample['visit_log']['visit_id']
    
    trace = Trace(traceId, webId)
    for tcp_conn in sample['tcp_connections']:
        
        connection_id = tcp_conn['connection_id']
        
        TCP = TCPConnection(connection_id, webId, hostip=sample['visit_log'][u'host_ip'])

        for pkt in tcp_conn['packets']:
            pkt_time, pkt_size = pkt[0], abs(pkt[1])
            
            if pkt_size == 0:
                continue

            pkt_dir = Packet.Outgoing if pkt[1] < 0 else Packet.Incoming

            if direction is None or direction == pkt_dir:
                TCP.addPacket(Packet(pkt_time, pkt_size, pkt_dir))
        TCP._packets.sort(key=lambda x: x.getTime())
        trace.addTcpCon(TCP)
    
    return trace
Example #2
0
File: Test.py Project: goagile/gof
 def setUp(self):
     self.tcp = TCPConnection()
Example #3
0
    from UDPConnection import UDPConnection
    from TCPConnection import TCPConnection
    from AudioServer import AudioSocketServer

    HOST = socket.gethostbyname(socket.gethostname())
    PORT = 50007
    LISTEN_ALL_HOST = '0.0.0.0'

    app = QtWidgets.QApplication(sys.argv)
    application = MainWindow()
    application.show()

    UDP_socket = UDPConnection(HOST, PORT)
    UDP_socket.setsockopt_reuseaddr()
    UDP_socket.bind(LISTEN_ALL_HOST, PORT)
    UDP_socket.send_address_to_sender()
    UDP_socket.start_UDP_receiving()

    TCP_socket = TCPConnection(application.signal.new_mes)
    TCP_socket.setsockopt_reuseaddr()
    TCP_socket.bind(HOST, PORT)
    TCP_socket.listen(10)
    TCP_socket.set_server_socket()

    application.set_socket(TCP_socket)
    application.start_threading()

    audio_socket = AudioSocketServer(HOST, PORT + 1)

    sys.exit(app.exec())