From 69302fcd9ffdcbb19d5831e967a44342ea5c8f0d Mon Sep 17 00:00:00 2001 From: Sun Knudsen Date: Thu, 10 Dec 2020 07:24:56 -0500 Subject: [PATCH] Refactored ulagen.py to Python 3 --- .../README.md | 6 +++--- .../ulagen.py | 10 +++++----- .../ulagen.py.sig | Bin 566 -> 566 bytes 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/how-to-self-host-hardened-strongswan-ikev2-ipsec-vpn-server-for-ios-and-macos/README.md b/how-to-self-host-hardened-strongswan-ikev2-ipsec-vpn-server-for-ios-and-macos/README.md index b40657b..de72117 100644 --- a/how-to-self-host-hardened-strongswan-ikev2-ipsec-vpn-server-for-ios-and-macos/README.md +++ b/how-to-self-host-hardened-strongswan-ikev2-ipsec-vpn-server-for-ios-and-macos/README.md @@ -231,7 +231,7 @@ $ source ~/.bashrc #### Install cURL and Python ```shell -apt install -y curl python +apt install -y curl python3 ``` #### Generate random IPv6 ULA and save to environment variables @@ -241,8 +241,8 @@ Shout out to [Andrew Ho](https://gist.github.com/andrewlkho/31341da4f5953b8d977a The following command downloads and runs [ulagen.py](./ulagen.py) ([PGP signature](./ulagen.py.sig), [PGP public key](https://sunknudsen.com/sunknudsen.asc)). ```console -$ curl -s https://sunknudsen.com/static/media/privacy-guides/how-to-self-host-hardened-strongswan-ikev2-ipsec-vpn-server-for-ios-and-macos/ulagen.py | python | grep "First subnet" | awk '{print "STRONGSWAN_IPV6_ULA="$3}' | tee -a ~/.bashrc -STRONGSWAN_IPV6_ULA=fdcb:f7a1:38ec::/64 +$ curl -s https://sunknudsen.com/static/media/privacy-guides/how-to-self-host-hardened-strongswan-ikev2-ipsec-vpn-server-for-ios-and-macos/ulagen.py | python3 | grep "First subnet" | awk '{print "STRONGSWAN_IPV6_ULA="$3}' | tee -a ~/.bashrc +STRONGSWAN_IPV6_ULA=fdba:8ce0:c301::/64 $ source ~/.bashrc ``` diff --git a/how-to-self-host-hardened-strongswan-ikev2-ipsec-vpn-server-for-ios-and-macos/ulagen.py b/how-to-self-host-hardened-strongswan-ikev2-ipsec-vpn-server-for-ios-and-macos/ulagen.py index 166c578..7cd5be1 100755 --- a/how-to-self-host-hardened-strongswan-ikev2-ipsec-vpn-server-for-ios-and-macos/ulagen.py +++ b/how-to-self-host-hardened-strongswan-ikev2-ipsec-vpn-server-for-ios-and-macos/ulagen.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import hashlib import time @@ -16,13 +16,13 @@ def time_ntpformat(): def main(): h = hashlib.sha1() - h.update(get_eui64() + str(time_ntpformat())) + h.update(str(get_eui64() + str(time_ntpformat())).encode("utf-8")) globalid = h.hexdigest()[0:10] prefix = ":".join(("fd" + globalid[0:2], globalid[2:6], globalid[6:10])) - print "Prefix: " + prefix + "::/48" - print "First subnet: " + prefix + "::/64" - print "Last subnet: " + prefix + ":ffff::/64" + print("Prefix: " + prefix + "::/48") + print("First subnet: " + prefix + "::/64") + print("Last subnet: " + prefix + ":ffff::/64") if __name__ == "__main__": main() diff --git a/how-to-self-host-hardened-strongswan-ikev2-ipsec-vpn-server-for-ios-and-macos/ulagen.py.sig b/how-to-self-host-hardened-strongswan-ikev2-ipsec-vpn-server-for-ios-and-macos/ulagen.py.sig index 023cfca7bd6aa77d8d8fba5c1286f19f668c6b05..fa4bdcadd4c000d403ef6c40567a87482f05d04e 100644 GIT binary patch delta 542 zcmV+(0^$9(1hxc_BY)8AG5`t*5Fe*!hAX`j1^T!T{v(3h`0Py8RNmaNNQYQ#aB(WE z(F{{_-eT|lCMNHgP>&jIm|6=_Uu-8_tcX^@EA0`0Ws6^eoGS<>+VBQ)nV0Xjxxf%b zLLHo-<&kz&Yv`tSpkZA29I&qGHb}xWVkcGed6|4f0U4Y6UVnCQo5KzNQf{HYypw(7 z`WS2fLFfJ@x`z@b3EDd~m&J-V6NQu3A)4ETW;kLJEU>H1&O5~rlQ+fRWfL%vV&R_@ zrj+~Sar5~4n4 z{~t|>GMTS<;D5ELTu(i-B)_6i&$6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