예제 #1
0
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")
예제 #2
0
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")
예제 #3
0
def register_trusted_ip(ip):
    global TRUSTED
    CONFIG["trusted"] = list(set(CONFIG.get("trusted", []) + [ip]))
    TRUSTED.add(ip)
    dumpJson(CONFIG, "config.json")
예제 #4
0
def register_ipinfo_token(token):
    CONFIG["ipinfo token"] = token
    dumpJson(CONFIG, "config.json")
예제 #5
0
def drop(name):
    rule = CONFIG.get("rules", {}).pop(name, False)
    dumpJson(CONFIG, "config.json")
    return rule