|
4 | 4 | This file is part of EEWIDS (Easily Expandable WIDS)
|
5 | 5 |
|
6 | 6 | Copyright (C) 2018 Alexander Paetzelt <techge+eewids posteo net>
|
| 7 | + Copyright (C) 2020 Alexander Paetzelt <techge+eewids posteo net> |
7 | 8 |
|
8 | 9 | This program is free software: you can redistribute it and/or modify
|
9 | 10 | it under the terms of the GNU General Public License as published by
|
|
24 | 25 | import argparse
|
25 | 26 | import json
|
26 | 27 | import pika
|
27 |
| -import requests |
28 | 28 |
|
29 | 29 | import parser as p
|
30 | 30 |
|
@@ -66,20 +66,22 @@ def main(rab_host, rab_port):
|
66 | 66 |
|
67 | 67 | # create queue for receiving raw capture data
|
68 | 68 | # TODO you probably do not want a random queue, but one which is used by multiple workers!!!
|
69 |
| - recv_channel.queue_declare(queue='eewids-parser', exclusive=False) |
| 69 | + result = recv_channel.queue_declare(queue='eewids-parser', exclusive=False) |
| 70 | + queue_name = result.method.queue |
70 | 71 | #recv_queue = recv_channel.queue.declare(exclusive=True)
|
71 | 72 | # TODO change routing key on capture tool and here, make it meaningful and global/as argument
|
72 |
| - recv_channel.queue_bind(exchange='capture-raw', queue='eewids-parser', routing_key='*.*.*') |
| 73 | + # FIXME do not abort if it does not exist |
| 74 | + recv_channel.queue_bind(exchange='capture-raw', queue=queue_name, routing_key='*') |
73 | 75 |
|
74 | 76 | def callback(ch, method, properties, body):
|
75 | 77 |
|
76 | 78 | parsed_data = p.packet_parse(body)
|
77 | 79 | distribute(parsed_data, send_channel)
|
78 | 80 |
|
79 | 81 | # TODO look up right arguments to make sure that this is dividable through multiple workers!
|
80 |
| - recv_channel.basic_consume(callback, |
81 |
| - queue='eewids-parser', |
82 |
| - no_ack=False) |
| 82 | + recv_channel.basic_consume(on_message_callback=callback, |
| 83 | + queue=queue_name, |
| 84 | + auto_ack=True) |
83 | 85 |
|
84 | 86 | print(' [*] Starting parsing. To exit press CTRL+C')
|
85 | 87 | recv_channel.start_consuming()
|
|
0 commit comments