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

Function _check_netstat

sshuttle/hostwatch.py:162–184  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

160
161
162def _check_netstat():
163 debug2(' > netstat')
164 argv = ['netstat', '-n']
165 try:
166 p = ssubprocess.Popen(argv, stdout=ssubprocess.PIPE, stderr=null,
167 env=get_env())
168 content = p.stdout.read().decode("ASCII")
169 p.wait()
170 except OSError:
171 _, e = sys.exc_info()[:2]
172 log('%r failed: %r' % (argv, e))
173 return
174
175 # The same IPs may appear multiple times. Consolidate them so the
176 # debug message doesn't print the same IP repeatedly.
177 ip_list = []
178 for ip in re.findall(r'\d+\.\d+\.\d+\.\d+', content):
179 if ip not in ip_list:
180 ip_list.append(ip)
181
182 for ip in sorted(ip_list):
183 debug3('< %s' % ip)
184 check_host(ip)
185
186
187def check_host(hostname):

Callers

nothing calls this directly

Calls 5

debug2Function · 0.90
get_envFunction · 0.90
logFunction · 0.90
debug3Function · 0.90
check_hostFunction · 0.85

Tested by

no test coverage detected