Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to run engine.py without --server-port & fix evolve.py engine log #62

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self, server_port,
server_side=False,
output_directory="trials",
log_level="info",
file_log_level="info",
file_log_level="debug",
enabled=True,
in_queue_num=None,
out_queue_num=None,
Expand Down Expand Up @@ -259,9 +259,15 @@ def initialize_nfqueue(self):
"""
Initializes the nfqueue for input and output forests.
"""
self.logger.debug("Engine created with strategy %s (ID %s) to port %s",
str(self.strategy).strip(), self.environment_id, self.server_port)
self.configure_iptables()
if self.server_port is not None:
self.logger.debug("Engine created with strategy %s (ID %s) to port %s",
str(self.strategy).strip(), self.environment_id, self.server_port)
else:
self.logger.debug("Engine created with strategy %s (ID %s) to NFQueue number %s for incoming packets and to NFQueue number %s for outcoming packets",
str(self.strategy).strip(), self.environment_id, self.in_queue_num, self.out_queue_num)

if self.server_port is not None:
self.configure_iptables()

self.out_nfqueue_started = False
self.in_nfqueue_started = False
Expand Down Expand Up @@ -313,7 +319,8 @@ def shutdown_nfqueue(self):
self.in_nfqueue.unbind()
if self.out_nfqueue:
self.out_nfqueue.unbind()
self.configure_iptables(remove=True)
if self.server_port is not None:
self.configure_iptables(remove=True)
self.socket.close()
self.out_nfqueue_socket.close()
self.in_nfqueue_socket.close()
Expand Down Expand Up @@ -422,7 +429,7 @@ def get_args():
"""
parser = argparse.ArgumentParser(description='The engine that runs a given strategy.')
# Store a string, not int, in case of port ranges/lists. The iptables command checks the port var
parser.add_argument('--server-port', action='store', required=True)
parser.add_argument('--server-port', action='store', required=False)
parser.add_argument('--environment-id', action='store', help="ID of the current strategy under test")
parser.add_argument('--sender-ip', action='store', help="IP address of sending machine, used for NAT")
parser.add_argument('--routing-ip', action='store', help="Public IP of this machine, used for NAT")
Expand Down