Created
November 23, 2022 17:11
-
-
Save fagci/ba0126f7d4c271e5993db54dedef4dfc to your computer and use it in GitHub Desktop.
Faster WAN ip generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import getrandbits | |
from socket import inet_ntoa | |
from struct import pack | |
def wan_ip(): | |
while True: | |
int_ip = 0x01000000 + getrandbits(32) % 0xfeffffff | |
if (0xe0000000 <= int_ip < 0xffffffff | |
or 0xA000000 <= int_ip < 0xb000000 | |
or 0x7F000000 <= int_ip < 0x80000000 | |
or 0x64400000 <= int_ip < 0x64800000 | |
or 0xAC100000 <= int_ip < 0xac200000 | |
or 0xC6120000 <= int_ip < 0xc6140000 | |
or 0xA9FE0000 <= int_ip < 0xa9ff0000 | |
or 0xC0A80000 <= int_ip < 0xc0a90000 | |
or 0xC0000000 <= int_ip < 0xc0000100 | |
or 0xC0000200 <= int_ip < 0xc0000300 | |
or 0xc0586300 <= int_ip < 0xc0586400 | |
or 0xC6336400 <= int_ip < 0xc6336500 | |
or 0xCB007100 <= int_ip < 0xcb007200 | |
or 0xe9fc0000 <= int_ip < 0xe9fc0100): | |
continue | |
return inet_ntoa(pack('>I', int_ip)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment