def drop_trusted_ip(ip): global TRUSTED trusted = CONFIG.get("trusted", []) if ip in trusted: trusted.remove(ip) CONFIG["trusted"] = trusted TRUSTED.remove(ip) dumpJson(CONFIG, "config.json")
def register(name, obj): code = binascii.hexlify( marshal.dumps( getattr(obj, "__code__" if PY3 else "func_code") ) ) CONFIG["rules"] = dict( CONFIG.get("rules", {}), **{name: code.decode("utf-8") if isinstance(code, bytes) else code} ) dumpJson(CONFIG, "config.json")
def register_trusted_ip(ip): global TRUSTED CONFIG["trusted"] = list(set(CONFIG.get("trusted", []) + [ip])) TRUSTED.add(ip) dumpJson(CONFIG, "config.json")
def register_ipinfo_token(token): CONFIG["ipinfo token"] = token dumpJson(CONFIG, "config.json")
def drop(name): rule = CONFIG.get("rules", {}).pop(name, False) dumpJson(CONFIG, "config.json") return rule