def main(): ifs = get_ifs() usage_message = create_usage(ifs) rpc_port = 26001 opts = None # parse command line options. try: opts, args = getopt.getopt( sys.argv[1:], "d:f:P:l:", ["device=", "filter=", "log_path=", "log_level=", "port="]) except getopt.GetoptError: log_error(usage_message) device = None pcap_filter = "" log_path = "./" log_level = 1 for opt, arg in opts: if opt in ("-d", "--device"): device = ifs[int(arg)] if opt in ("-f", "--filter"): pcap_filter = arg if opt in ("-P", "--log_path"): log_path = arg if opt in ("-l", "--log_level"): log_level = int(arg) if opt in "--port": rpc_port = int(arg) if not device: log_error(usage_message) try: servlet = NetworkMonitorPedrpcServer("0.0.0.0", rpc_port, device, pcap_filter, log_path, log_level) t = threading.Thread(target=servlet.serve_forever) t.daemon = True t.start() # Now wait in a way that will not block signals like SIGINT helpers.pause_for_signal() except Exception: pass
def main(): ifs = get_ifs() usage_message = create_usage(ifs) rpc_port = 26001 opts = None # parse command line options. try: opts, args = getopt.getopt(sys.argv[1:], "d:f:P:l:", ["device=", "filter=", "log_path=", "log_level=", "port="]) except getopt.GetoptError: log_error(usage_message) device = None pcap_filter = "" log_path = "./" log_level = 1 for opt, arg in opts: if opt in ("-d", "--device"): device = ifs[int(arg)] if opt in ("-f", "--filter"): pcap_filter = arg if opt in ("-P", "--log_path"): log_path = arg if opt in ("-l", "--log_level"): log_level = int(arg) if opt in "--port": rpc_port = int(arg) if not device: log_error(usage_message) try: servlet = NetworkMonitorPedrpcServer("0.0.0.0", rpc_port, device, pcap_filter, log_path, log_level) t = threading.Thread(target=servlet.serve_forever) t.daemon = True t.start() # Now wait in a way that will not block signals like SIGINT helpers.pause_for_signal() except: pass