def upload_iptables()

in blocky-client.py [0:0]


def upload_iptables():
    global BANLIST, LAST_UPLOAD
    # First, get our rules and post 'em to the server
    ychains = CONFIG.get('iptables', {}).get('chains')
    chains = ychains or ['INPUT']
    LOCK.acquire(blocking=True)
    BANLIST = []
    for chain in chains:
        BANLIST += getbans(chain)
    mylistbare = copy.deepcopy(BANLIST)
    LOCK.release()
    apiurl = "%s/myrules" % CONFIG['server']['apiurl']
    try:
        for el in mylistbare:
            del el['asNet']
        js = {
            'hostname': CONFIG['client']['hostname'],
            'iptables': mylistbare
        }
        rv = requests.put(apiurl, json=js)
        print(rv.status_code)
        assert (rv.status_code == 200)
        LAST_UPLOAD = time.time()
    except Exception as e:
        print("Could not send my iptables list to server at %s - server down?" % apiurl)

    # Respawn upload process later...
    t = threading.Timer(CONFIG['client'].get('uploadinterval', 300), upload_iptables)
    t.start()