From 1e63bea61371ba2b9641bffd31b013782a843061 Mon Sep 17 00:00:00 2001 From: Fabio Ambauen <1833932+open-dynaMIX@users.noreply.github.com> Date: Mon, 19 Oct 2020 10:44:50 +0200 Subject: [PATCH] chore: move prevention of processing empty lines to run() This is a prerequisite for future features. --- anonip.py | 9 ++++++--- docker-compose.yml | 9 +++++++++ nginx.conf | 27 +++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 docker-compose.yml create mode 100644 nginx.conf diff --git a/anonip.py b/anonip.py index 01c7b02..1f93677 100755 --- a/anonip.py +++ b/anonip.py @@ -146,6 +146,12 @@ def run(self, input_file=None): while line: line = line.rstrip() + if line.strip() == "": + logger.debug("Empty line detected. Doing nothing.") + yield line + line = input_file.readline() + continue + logger.debug("Got line: %r", line) yield self.process_line(line) @@ -180,9 +186,6 @@ def process_line(self, line): :param line: str :return: str """ - if line.strip() == "": - logger.debug("Empty line detected. Doing nothing.") - return line loglist = line.split(self.delimiter) for index in self.columns: diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..6cc3522 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +version: "3" + +services: + nginx: + image: nginx + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf + ports: + - "8080:80" diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..918f423 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,27 @@ +events { + worker_connections 1024; +} + + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + server { + listen 80; + server_name localhost; + + root /usr/share/nginx/html; + index index.html index.htm; + + location /401 { + return 401; + } + } +}