mirror of
https://github.com/sunknudsen/privacy-guides.git
synced 2025-02-22 16:53:56 +00:00
Refactored ulagen.py to Python 3
This commit is contained in:
parent
8858839a7b
commit
69302fcd9f
@ -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
|
||||
```
|
||||
|
@ -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()
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user