diff options
author | Devaev Maxim <[email protected]> | 2018-12-16 02:28:13 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2018-12-16 02:28:13 +0300 |
commit | d7fb06d22ebfad8134c5d1a1e2bd6f6001baf8c4 (patch) | |
tree | 4ec7f3d4e10601767f9f97b9b8ecc49979f6c64c | |
parent | e5dfc9e30688752752c3ec20714c9b8c83efa4f7 (diff) |
better access log
-rw-r--r-- | configs/kvmd/platforms/kvmd.v1-hdmi.yaml | 1 | ||||
-rw-r--r-- | configs/kvmd/platforms/kvmd.v1-vga.yaml | 1 | ||||
-rw-r--r-- | kvmd/apps/kvmd/__init__.py | 1 | ||||
-rw-r--r-- | kvmd/apps/kvmd/server.py | 16 | ||||
-rw-r--r-- | testenv/kvmd.yaml | 1 |
5 files changed, 16 insertions, 4 deletions
diff --git a/configs/kvmd/platforms/kvmd.v1-hdmi.yaml b/configs/kvmd/platforms/kvmd.v1-hdmi.yaml index 1991e4c5..305c5ae6 100644 --- a/configs/kvmd/platforms/kvmd.v1-hdmi.yaml +++ b/configs/kvmd/platforms/kvmd.v1-hdmi.yaml @@ -6,6 +6,7 @@ kvmd: host: 127.0.0.1 port: 8081 heartbeat: 3.0 + access_log_format: "[%{X-Real-IP}i] '%r' => %s; size=%b --- referer='%{Referer}i'; user_agent='%{User-Agent}i'" auth: htpasswd: /etc/kvmd/htpasswd diff --git a/configs/kvmd/platforms/kvmd.v1-vga.yaml b/configs/kvmd/platforms/kvmd.v1-vga.yaml index 5688f306..ffc1ceab 100644 --- a/configs/kvmd/platforms/kvmd.v1-vga.yaml +++ b/configs/kvmd/platforms/kvmd.v1-vga.yaml @@ -6,6 +6,7 @@ kvmd: host: 127.0.0.1 port: 8081 heartbeat: 3.0 + access_log_format: "[%{X-Real-IP}i] '%r' => %s; size=%b --- referer='%{Referer}i'; user_agent='%{User-Agent}i'" auth: htpasswd: /etc/kvmd/htpasswd diff --git a/kvmd/apps/kvmd/__init__.py b/kvmd/apps/kvmd/__init__.py index 480a1017..e8b74abc 100644 --- a/kvmd/apps/kvmd/__init__.py +++ b/kvmd/apps/kvmd/__init__.py @@ -94,6 +94,7 @@ def main() -> None: msd=msd, streamer=streamer, + access_log_format=str(config["server"]["access_log_format"]), heartbeat=float(config["server"]["heartbeat"]), streamer_shutdown_delay=float(config["streamer"]["shutdown_delay"]), msd_chunk_size=int(config["msd"]["chunk_size"]), diff --git a/kvmd/apps/kvmd/server.py b/kvmd/apps/kvmd/server.py index 3981f59b..b204df7d 100644 --- a/kvmd/apps/kvmd/server.py +++ b/kvmd/apps/kvmd/server.py @@ -198,6 +198,7 @@ class Server: # pylint: disable=too-many-instance-attributes msd: MassStorageDevice, streamer: Streamer, + access_log_format: str, heartbeat: float, streamer_shutdown_delay: float, msd_chunk_size: int, @@ -214,6 +215,7 @@ class Server: # pylint: disable=too-many-instance-attributes self.__msd = msd self.__streamer = streamer + self.__access_log_format = access_log_format self.__heartbeat = heartbeat self.__streamer_shutdown_delay = streamer_shutdown_delay self.__msd_chunk_size = msd_chunk_size @@ -251,17 +253,23 @@ class Server: # pylint: disable=too-many-instance-attributes assert port or unix_path if unix_path: - kwargs: Dict = {} + socket_kwargs: Dict = {} if unix_rm and os.path.exists(unix_path): os.remove(unix_path) server_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) server_socket.bind(unix_path) if unix_mode: os.chmod(unix_path, unix_mode) - kwargs = {"sock": server_socket} + socket_kwargs = {"sock": server_socket} else: - kwargs = {"host": host, "port": port} - aiohttp.web.run_app(app, print=self.__run_app_print, **kwargs) + socket_kwargs = {"host": host, "port": port} + + aiohttp.web.run_app( + app=app, + access_log_format=self.__access_log_format, + print=self.__run_app_print, + **socket_kwargs, + ) async def __make_info(self) -> Dict: return { diff --git a/testenv/kvmd.yaml b/testenv/kvmd.yaml index da37e9d8..e8c10539 100644 --- a/testenv/kvmd.yaml +++ b/testenv/kvmd.yaml @@ -3,6 +3,7 @@ kvmd: host: 0.0.0.0 port: 8081 heartbeat: 3.0 + access_log_format: "[%{X-Real-IP}i] '%r' => %s; size=%b --- referer='%{Referer}i'; user_agent='%{User-Agent}i'" auth: htpasswd: /etc/kvmd/htpasswd |