Converts mask from /xx format to xxx.xxx.xxx.xxx Example: if mask is 24 function returns 255.255.255.0 :rtype: str
(mask: int)
| 739 | |
| 740 | |
| 741 | def dotted_netmask(mask: int) -> str: |
| 742 | """Converts mask from /xx format to xxx.xxx.xxx.xxx |
| 743 | |
| 744 | Example: if mask is 24 function returns 255.255.255.0 |
| 745 | |
| 746 | :rtype: str |
| 747 | """ |
| 748 | bits = 0xFFFFFFFF ^ (1 << 32 - mask) - 1 |
| 749 | return socket.inet_ntoa(struct.pack(">I", bits)) |
| 750 | |
| 751 | |
| 752 | def is_ipv4_address(string_ip: str) -> bool: |
no outgoing calls