@graft<EOL>def network_info():
def extract(host, family):<EOL><INDENT>return socket.getaddrinfo(host, None, family)[<NUM_LIT:0>][<NUM_LIT:4>][<NUM_LIT:0>]<EOL><DEDENT>host = socket.gethostname()<EOL>response = {<EOL>'<STR_LIT>': host,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None<EOL>}<EOL>with suppress(IndexError, socket.gaierror):<EOL><INDENT>response['<STR_LIT>'] = extract(host, socket.AF_INET)<EOL><DEDENT>with suppress(IndexError, socket.gaierror):<EOL><INDENT>response['<STR_LIT>'] = extract(host, socket.AF_INET6)<EOL><DEDENT>return response<EOL>
Returns hostname, ipv4 and ipv6.