diff options
| author | Andrew Guschin <guschin.drew@gmail.com> | 2022-06-29 17:45:07 +0400 |
|---|---|---|
| committer | Andrew Guschin <guschin.drew@gmail.com> | 2022-06-29 17:45:07 +0400 |
| commit | fc8fa5a30bf464557051ac22a75ca83de3a29f7b (patch) | |
| tree | 39af088ddf259deb080f2f21f31d89c2206e6ab2 /utils.py | |
Diffstat (limited to 'utils.py')
| -rw-r--r-- | utils.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/utils.py b/utils.py new file mode 100644 index 0000000..00960d0 --- /dev/null +++ b/utils.py @@ -0,0 +1,18 @@ +import socket +import struct + + +def ip2int(addr): + return struct.unpack("!I", socket.inet_aton(addr))[0] + + +def int2ip(addr): + return socket.inet_ntoa(struct.pack("!I", addr)) + + +a = ip2int('10.13.37.254') +b = a + 1 +while (b & 0xFF) in (0x00, 0xFF): + b += 1 +c = int2ip(b) +print(a, b, c) |