From 7ac4610885a741d050de99b740db254706ec707e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 3 Jun 2023 15:31:18 +0200 Subject: [PATCH] Continued: - added script to check if instance aka. "domain" is valid, not blacklisted and not already registered - in any of these conditions, an other status code is returned --- check_instance.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 check_instance.py diff --git a/check_instance.py b/check_instance.py new file mode 100755 index 0000000..d7711e1 --- /dev/null +++ b/check_instance.py @@ -0,0 +1,39 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + +# Fedi API Block - An aggregator for fetching blocking data from fediverse nodes +# Copyright (C) 2023 Free Software Foundation +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import json +import sys +import validators +from fba import * + +domain = sys.argv[1] + +if not validators.domain(domain): + print(f"WARNING: domain='{domain}' is not valid") + sys.exit(100) +elif fba.is_blacklisted(domain): + print(f"WARNING: domain='{domain}' is blacklisted") + sys.exit(101) +elif fba.is_instance_registered(domain): + print(f"WARNING: domain='{domain}' is already registered") + sys.exit(102) + +print(f"INFO: domain='{domain}' is not known") + +boot.shutdown() -- 2.39.5