in blocky-client.py [0:0]
def main():
global CONFIG
# Figure out who we are
me = socket.getfqdn()
# Try opening the epoch file
epoch = 0
try:
last_boot = int(time.time() - uptime())
epoch = int(open("epoch.dat").read())
print("Last boot: %s" % last_boot)
print("Epoch: %s" % epoch)
if epoch < last_boot:
print("Computer was rebooted since last check, resetting cache")
epoch = 0
except:
pass
# Set new epoch
with open("epoch.dat", "w") as f:
f.write("%u" % time.time())
f.close()
# Load YAML
CONFIG = yaml.safe_load(open('./blocky.yaml').read())
if 'client' not in CONFIG:
CONFIG['client'] = {}
if 'hostname' not in CONFIG['client']:
CONFIG['client']['hostname'] = me
# Get current list of bans in iptables, upload it to blocky server
upload_iptables()
# Start async loop
asyncio.get_event_loop().run_until_complete(hello(epoch))
print("EXITING")