MCPcopy Index your code
hub / github.com/sshuttle/sshuttle / found_host

Function found_host

sshuttle/hostwatch.py:93–113  ·  view source on GitHub ↗

The provided name maps to the given IP. Add the host to the hostnames list, send the host to the sshuttle client via stdout, and write the host to the cache file.

(name, ip)

Source from the content-addressed store, hash-verified

91
92
93def found_host(name, ip):
94 """The provided name maps to the given IP. Add the host to the
95 hostnames list, send the host to the sshuttle client via
96 stdout, and write the host to the cache file.
97 """
98 hostname = re.sub(r'\..*', '', name)
99 hostname = re.sub(r'[^-\w\.]', '_', hostname)
100 if (ip.startswith('127.') or ip.startswith('255.') or
101 hostname == 'localhost'):
102 return
103
104 if hostname != name:
105 found_host(hostname, ip)
106
107 global SHOULD_WRITE_CACHE
108 oldip = hostnames.get(name)
109 if oldip != ip:
110 hostnames[name] = ip
111 debug1('Found: %s: %s' % (name, ip))
112 sys.stdout.write('%s,%s\n' % (name, ip))
113 SHOULD_WRITE_CACHE = True
114
115
116def _check_etc_hosts():

Callers 4

read_host_cacheFunction · 0.85
_check_etc_hostsFunction · 0.85
_check_revdnsFunction · 0.85
_check_dnsFunction · 0.85

Calls 3

debug1Function · 0.90
getMethod · 0.80
writeMethod · 0.80

Tested by

no test coverage detected