INNER CODE UNIT · Python

random_ipv6_subnet

Mailu/Mailu · setup/server.py:42

def random_ipv6_subnet():
    eui64 = uuid.getnode() >> 24 << 48 | 0xfffe000000 | uuid.getnode() & 0xffffff
    eui64_canon = "-".join([format(eui64, "02X")[i:i+2] for i in range(0, 18, 2)])

    h = hashlib.sha1()
    h.update((eui64_canon + str(time.time() - time.mktime((1900, 1, 1, 0, 0, 0, 0, 1, -1)))).encode('utf-8'))
    globalid = h.hexdigest()[0:10]

    prefix = ":".join(("fd" + globalid[0:2], globalid[2:6], globalid[6:10]))
    return prefix

def build_app(path):

    app.jinja_env.trim_blocks = True
    app.jinja_env.lstrip_blocks = True

    @app.context_processor
    def app_context():

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…