def MIN_TTL (io, ip, ttl): # None (ttl-security unset) or zero (maximum TTL) is the same thing if ttl: try: io.setsockopt(socket.IPPROTO_IP, socket.IP_MINTTL, ttl) except socket.error as exc: raise TTLError('This OS does not support IP_MINTTL (ttl-security) for %s (%s)' % (ip,errstr(exc))) except AttributeError: pass try: io.setsockopt(socket.IPPROTO_IP, socket.IP_TTL, ttl) except socket.error as exc: raise TTLError('This OS does not support IP_MINTTL or IP_TTL (ttl-security) for %s (%s)' % (ip,errstr(exc)))
def TTLv6(io, ip, ttl): if ttl: try: io.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_UNICAST_HOPS, ttl) except socket.error as exc: raise TTLError( 'This OS does not support unicast_hops (ttl-security) for %s (%s)' % (ip, errstr(exc)))
# None (ttl-security unset) or zero (maximum TTL) is the same thing if ttl: try: io.setsockopt(socket.IPPROTO_IP, socket.IP_MINTTL, ttl) except socket.error, exc: raise TTLError( 'This OS does not support IP_MINTTL (ttl-security) for %s (%s)' % (ip, errstr(exc))) except AttributeError: pass try: io.setsockopt(socket.IPPROTO_IP, socket.IP_TTL, ttl) except socket.error, exc: raise TTLError( 'This OS does not support IP_MINTTL or IP_TTL (ttl-security) for %s (%s)' % (ip, errstr(exc))) def async (io, ip): try: io.setblocking(0) except socket.error, exc: raise AsyncError('could not set socket non-blocking for %s (%s)' % (ip, errstr(exc))) def ready(io): logger = Logger() warned = False start = time.time()