(ifname)
| 24 | import struct |
| 25 | |
| 26 | def get_interface_ip(ifname): |
| 27 | def _bytes(value, encoding): |
| 28 | return bytes(value, encoding) |
| 29 | |
| 30 | sckt = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) |
| 31 | return socket.inet_ntoa( |
| 32 | fcntl.ioctl(sckt.fileno(), 0x8915, struct.pack("256s", _bytes(ifname[:15], "utf-8")))[20:24] # SIOCGIFADDR |
| 33 | ) |
| 34 | |
| 35 | |
| 36 | def get_lan_ip(): |
no test coverage detected