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)
| 91 | |
| 92 | |
| 93 | def 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 | |
| 116 | def _check_etc_hosts(): |
no test coverage detected