Implementing imet blocking

This commit is contained in:
xss 2022-02-27 12:29:43 +11:00
parent 0affb308fc
commit 1ffeef2cab
3 changed files with 21 additions and 2 deletions

View File

@ -233,6 +233,15 @@ resource "aws_lambda_function" "ham_sns_to_mqtt" {
Name = "sns-to-mqtt"
}
vpc_config {
security_group_ids = [
"sg-05f795128b295c504",
]
subnet_ids = [
aws_subnet.private["us-east-1b"].id
]
}
}
resource "aws_lambda_permission" "ham_sns_to_mqtt" {

View File

@ -230,12 +230,22 @@ def telemetry_filter(telemetry):
_id_msg += " Note: MRZ sondes may take a while to get an ID."
return (False, _id_msg)
# https://github.com/projecthorus/sondehub-infra/issues/56
if "iMet-4" == telemetry["type"] or "iMet-1" == telemetry["type"]:
if telemetry["software_name"] == "radiosonde_auto_rx":
if parse_autorx_version(telemetry["software_version"]) < (1,5,9):
return (False,f"Autorx version is out of date and doesn't handle iMet-1 and iMet-4 radiosondes correctly. Please update to 1.5.9 or later")
if "dev" in telemetry:
return (False, "All checks passed however payload contained dev flag so will not be uploaded to the database")
return (True, "")
def parse_autorx_version(version):
try:
m = re.search(r'(\d+)\.(\d+)(?:\.(\d+))?', version)
return tuple([int(x if x != None else 0) for x in m.groups()])
except:
return (0,0,0)
def set_connection_header(request, operation_name, **kwargs):
request.headers['Connection'] = 'keep-alive'

View File

@ -36,7 +36,7 @@ payload = {
"time": "31/Jan/2021:00:10:25 +0000",
"timeEpoch": 1612051825409,
},
"body": "H4sIAHJJCGIAA31TTW/UMBC991esct4Yf8abvSEQcOCAaIVQqyqa3cxuLSVOsJ2lBfHfiV1VOBAxhxzmzXt5fmPfXW3m+pm+sQo/nMJ3cNhY6LHYbwoHrRn8YFtsYApD4x6L7cr4BZ03g40MRhSp86Fp7AZo0TVH6Dpvzmnq7Uf29cPq1Dh4E5617goliK54sS0YJVKzYkvv1zhgA1oLUVi92m3ef8qVg+mxcXhEc8E2jnDKeUl5yfgNF3ul9lISVquKqduc10LAyF2hVHtKCU21oPRgpxMcw+TQRdoXMB46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