Whether to log unknown requests

main
bashrc 2026-01-13 15:43:21 +00:00
parent fbdd9a301b
commit 41e5a9d098
3 changed files with 16 additions and 2 deletions

View File

@ -484,6 +484,7 @@ class EpicyonServer(ThreadingHTTPServer):
robots_txt = None
last_llm_time = None
mitm_servers = []
log_unknown_requests: bool = False
watermark_width_percent = 0
watermark_position = 0
watermark_opacity = 0
@ -712,6 +713,14 @@ def run_daemon(accounts_data_dir: str,
# the last time when an LLM scraper was replied to
httpd.last_llm_time = None
# whether to log unknown requests
httpd.log_unknown_requests = \
get_config_param(base_dir, 'logUnknownRequests')
if httpd.log_unknown_requests is None:
httpd.log_unknown_requests = False
if not isinstance(httpd.log_unknown_requests, bool):
httpd.log_unknown_requests = False
# servers with man-in-the-middle transport encryption
httpd.mitm_servers = load_mitm_servers(base_dir)

View File

@ -6147,8 +6147,8 @@ def daemon_http_get(self) -> None:
'_GET', 'arbitrary json',
self.server.debug)
else:
if self.server.debug:
print('DEBUG: GET Unknown file')
if self.server.debug or self.server.log_unknown_requests:
print('DEBUG: GET Unknown request ' + self.path)
http_404(self, 144)
self.server.getreq_busy = False

View File

@ -1603,6 +1603,11 @@ def _command_options() -> None:
set_config_param(base_dir, 'instanceDescription',
'Just another ActivityPub server')
# whether to log unknown requests
log_unknown_requests = get_config_param(base_dir, 'logUnknownRequests')
if log_unknown_requests is None:
set_config_param(base_dir, 'logUnknownRequests', False)
# set the short instance description in config.json
desc_short = get_config_param(base_dir, 'instanceDescriptionShort')
if not desc_short: