diff --git a/contrib/eddn-logs-archive b/contrib/eddn-logs-archive index ef30aef..972f710 100755 --- a/contrib/eddn-logs-archive +++ b/contrib/eddn-logs-archive @@ -87,7 +87,8 @@ do log " Archiving ${service}.log ..." # We have no means to tell the service to close and re-open output, it's # to stdout/err anyway. So we copy it. - COMPRESSED_NAME="${service}.log.$(date --iso-8601=seconds)" + TIMESTAMP="$(date --iso-8601=seconds)" + COMPRESSED_NAME="${service}.log.${TIMESTAMP}" cp ${service}.log "${COMPRESSED_NAME}" if [ $? -ne 0 ]; then @@ -97,6 +98,11 @@ do fi # Truncate the live file. :> ${service}.log + + # Produce a report on the just-rotated log + ${HOME}/.local/bin/eddn-report-log-errors "${COMPRESSED_NAME}" > \ + "${HOME}/reports/eddn-errors/by-log-rotation/eddn-errors-${TIMESTMAP}.txt" + # Now compress the newly archived log gzip -9v "${COMPRESSED_NAME}" log " DONE" diff --git a/scripts/eddn-report-log-errors b/scripts/eddn-report-log-errors index 5d2186f..45a95c7 100755 --- a/scripts/eddn-report-log-errors +++ b/scripts/eddn-report-log-errors @@ -117,9 +117,6 @@ def process_file(input_file: str) -> None: print(matches.group('err_msg')) print(line) - else: - print(line) - elif matches.group('software_name') == 'EDSM': # It's in-browser, no public source/releases if matches.group('software_version') == '1.0.1': @@ -174,7 +171,37 @@ def process_file(input_file: str) -> None: else: print(line) - ################################################################### + elif matches.group('software_name') == 'EliteLogAgent': + # + if matches.group('software_version') == '2.0.0.660': + print(line) + + # + # + elif matches.group('software_name') == 'Moonlight': + if matches.group('software_version') == '1.3.4': + if matches.group('schema_ref') == 'https://eddn.edcd.io/schemas/journal/1': + if matches.group('journal_event') == 'Scan': + # Ref: + if not matches.group('err_msg').startswith( + 'Failed Validation "[ + # + elif matches.group('software_name') == 'EVA [iPhone]': + pass + + #################################################################### # Issues we know about, but haven't yet alerted developers to ################################################################### ################################################################### diff --git a/scripts/testing/gateway-responses/test-bad-gzip.py b/scripts/testing/gateway-responses/test-bad-gzip.py deleted file mode 100644 index 9d50f1f..0000000 --- a/scripts/testing/gateway-responses/test-bad-gzip.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env python3 -# -# 2022-01-10: THIS SCRIPT DOES NOT PERFORM THE INTENDED PURPOSE -# BECAUSE IT SEEMS THAT `requests` (or underlying modules) IS TOO CLEVER -# AND APPLIES COMPRESSION WHEN WE SET THE `Content-Encoding: gzip` -# HEADER - -import json -import requests -import sys - -print(''' -DO NOT USE THIS SCRIPT, IT DOES NOT PERFORM THE INTENDED PURPOSE. - -USE THE `test-bad-gzip.sh` SCRIPT INSTEAD. - -''') -sys.exit(-1) - -if len(sys.argv) != 2: - print('test-sender.py ') - sys.exit(-1) - -with open(sys.argv[1], 'r') as f: - msg = f.read() - - s = requests.Session() - - # This apparently causes compression to actually happen - s.headers['Content-Encoding'] = 'gzip' - r = s.post( - 'https://dev.eddn.edcd.io:4432/upload/', - data=msg, - ) - - print(f'Response: {r!r}') - print(f'Body: {r.content.decode()}') - diff --git a/scripts/testing/gateway-responses/test-bad-gzip.sh b/scripts/testing/gateway-responses/test-bad-gzip.sh deleted file mode 100644 index 77592bf..0000000 --- a/scripts/testing/gateway-responses/test-bad-gzip.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -# -# python `requests` appears to perform compression when you set the -# 'Content-Encoding: gzip' header, so do this with curl. - -curl --verbose -d 'wegiuweuygtfawgep9aqe8fpq2387lfbr;iufvypq38764tpgf' -H 'Content-Encoding: gzip' 'https://dev.eddn.edcd.io:4432/upload/' diff --git a/scripts/testing/gateway-responses/test-gzip-bad-formdata.py b/scripts/testing/gateway-responses/test-gzip-bad-formdata.py deleted file mode 100644 index 0e3e1f0..0000000 --- a/scripts/testing/gateway-responses/test-gzip-bad-formdata.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python3 - -import json -import requests -import sys -import urllib3 -import zlib - -if len(sys.argv) != 2: - print('test-sender.py ') - sys.exit(-1) - -with open(sys.argv[1], 'r') as f: - # Read from provided file - msg = f.read() - - # Fake form-encode it - msg = 'wibble=' + msg - - # Compress it - msg_gzip = zlib.compress(msg.encode('utf-8')) - - http = urllib3.PoolManager() - - # Send that compressed data as a POST body - r = http.request( - 'POST', - 'https://dev.eddn.edcd.io:4432/upload/', - headers={ - 'Content-Encoding': 'gzip' - }, - body=msg_gzip - ) - - print(f'Response: {r.status!r}') - print(f'Body:\n{r.data.decode()}\n') - diff --git a/scripts/testing/gateway-responses/test-gzip-correct-formdata.py b/scripts/testing/gateway-responses/test-gzip-correct-formdata.py deleted file mode 100644 index e58c1d9..0000000 --- a/scripts/testing/gateway-responses/test-gzip-correct-formdata.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python3 - -import json -import requests -import sys -import urllib3 -import zlib - -if len(sys.argv) != 2: - print('test-sender.py ') - sys.exit(-1) - -with open(sys.argv[1], 'r') as f: - # Read from provided file - msg = f.read() - - # Fake form-encode it - msg = 'data=' + msg - - # Compress it - msg_gzip = zlib.compress(msg.encode('utf-8')) - - http = urllib3.PoolManager() - - # Send that compressed data as a POST body - r = http.request( - 'POST', - 'https://dev.eddn.edcd.io:4432/upload/', - headers={ - 'Content-Encoding': 'gzip' - }, - body=msg_gzip - ) - - print(f'Response: {r.status!r}') - print(f'Body:\n{r.data.decode()}\n') - diff --git a/scripts/testing/gateway-responses/test-gzip-plain-json.py b/scripts/testing/gateway-responses/test-gzip-plain-json.py deleted file mode 100644 index db7042a..0000000 --- a/scripts/testing/gateway-responses/test-gzip-plain-json.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python3 - -import json -import requests -import sys -import urllib3 -import zlib - -if len(sys.argv) != 2: - print('test-sender.py ') - sys.exit(-1) - -with open(sys.argv[1], 'r') as f: - # Read from provided file - msg = f.read() - - # Compress it - msg_gzip = zlib.compress(msg.encode('utf-8')) - - http = urllib3.PoolManager() - - # Send that compressed data as a POST body - r = http.request( - 'POST', - 'https://dev.eddn.edcd.io:4432/upload/', - headers={ - 'Content-Encoding': 'gzip' - }, - body=msg_gzip - ) - - print(f'Response: {r.status!r}') - print(f'Body:\n{r.data.decode()}\n') - diff --git a/scripts/testing/gateway-responses/test-plain-bad-formdata.py b/scripts/testing/gateway-responses/test-plain-bad-formdata.py deleted file mode 100644 index 04cc0bd..0000000 --- a/scripts/testing/gateway-responses/test-plain-bad-formdata.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env python3 - -import json -import sys -import urllib3 - -if len(sys.argv) != 2: - print('test-sender.py ') - sys.exit(-1) - -with open(sys.argv[1], 'r') as f: - # Read from provided file - msg = f.read() - - # Fake form-encode it - msg = 'wibble=' + msg - - http = urllib3.PoolManager() - - # Send that data as a POST body - r = http.request( - 'POST', - 'https://dev.eddn.edcd.io:4432/upload/', - body=msg - ) - - print(f'Response: {r.status!r}') - print(f'Body:\n{r.data.decode()}\n') - diff --git a/scripts/testing/gateway-responses/test-plain-correct-formdata.py b/scripts/testing/gateway-responses/test-plain-correct-formdata.py deleted file mode 100644 index a00815f..0000000 --- a/scripts/testing/gateway-responses/test-plain-correct-formdata.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env python3 - -import json -import sys -import urllib3 - -if len(sys.argv) != 2: - print('test-sender.py ') - sys.exit(-1) - -with open(sys.argv[1], 'r') as f: - # Read from provided file - msg = f.read() - - # Fake form-encode it - msg = 'data=' + msg - - http = urllib3.PoolManager() - - # Send that data as a POST body - r = http.request( - 'POST', - 'https://dev.eddn.edcd.io:4432/upload/', - body=msg - ) - - print(f'Response: {r.status!r}') - print(f'Body:\n{r.data.decode()}\n') - diff --git a/scripts/testing/gateway-responses/test-sender.py b/scripts/testing/gateway-responses/test-sender.py index de563a7..93f2fa0 100644 --- a/scripts/testing/gateway-responses/test-sender.py +++ b/scripts/testing/gateway-responses/test-sender.py @@ -1,20 +1,86 @@ #!/usr/bin/env python3 +# vim: tabstop=4 shiftwidth=4 expandtab smarttab textwidth=0 wrapmargin=0 -import json +import argparse import requests -import sys +import zlib -if len(sys.argv) != 2: - print('test-sender.py ') - sys.exit(-1) +upload_url = 'https://dev.eddn.edcd.io:4432/upload/' -with open(sys.argv[1], 'r') as f: - msg = f.read() +def send_message(url, args): + print(f''' +send_message: + URL: {url} + input file: "{args.messagefile}" +''') - s = requests.Session() + with open(args.messagefile, 'r') as f: + msg = f.read() - r = s.post('https://dev.eddn.edcd.io:4432/upload/', data=msg) + if args.formdata: + if args.formdata == 'good': + msg = 'data=' + msg - print(f'Response: {r!r}') - print(f'Body: {r.content.decode()}') + elif args.formdata == 'bad': + msg = 'BADLYENCODED=' + msg + s = requests.Session() + + if args.gzip: + # We assume that the argparse setup is enforcing the value being + # valid, i.e. `'good'` if it's not `'bad'`. + msg = zlib.compress(msg.encode('utf-8')) + s.headers['Content-Encoding'] = 'gzip' + + if args.gzip == 'bad': + # Prepend a character so it's not a valid gzip header + msg = b'w' + msg + + r = s.post(upload_url, data=msg) + + print(f'Response: {r!r}') + print(f'Body: {r.content.decode()}') + +if __name__ == "__main__": + __parser = argparse.ArgumentParser( + description='Send test messages to an EDDN /upload/ endpoint', + ) + + __parser.add_argument( + '--url', + metavar='', + help='The full URL of an EDDN /upload/ endpoint', + ) + + __parser.add_argument( + '--formdata', + choices=('good', 'bad'), + help='Specify to form-encode the request body', + ) + + __parser.add_argument( + '--gzip', + choices=('good', 'bad'), + help='Specify to gzip-compress the request body', + ) + + __parser.add_argument( + 'messagefile', + metavar='', + help='Name of a file containing the body of the EDDN message to be sent', + ) + + args = __parser.parse_args() + + if args.url: + # Allow for some short aliases, but NOT!!! for live !!! + if args.url == 'beta': + upload_url = 'https://beta.eddn.edcd.io:4431/upload/' + + elif args.url == 'dev': + upload_url = 'https://dev.eddn.edcd.io:4432/upload/' + + else: + upload_url = args.url + + send_message(upload_url, args)