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

Function islocal

sshuttle/helpers.py:159–172  ·  view source on GitHub ↗
(ip, family)

Source from the content-addressed store, hash-verified

157
158
159def islocal(ip, family):
160 sock = socket.socket(family)
161 try:
162 try:
163 sock.bind((ip, 0))
164 except socket.error:
165 _, e = sys.exc_info()[:2]
166 if e.args[0] == errno.EADDRNOTAVAIL:
167 return False # not a local IP
168 else:
169 raise
170 finally:
171 sock.close()
172 return True # it's a local IP, or there would have been an error
173
174
175def family_ip_tuple(ip):

Callers 1

onaccept_tcpFunction · 0.90

Calls 2

bindMethod · 0.80
closeMethod · 0.80

Tested by

no test coverage detected