Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Handle IPv6 Stack Unavailability in Traceroute Functionality (Generated by Ana - AI SDE) #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions connvitals/traceroute.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,20 @@ def __init__(self, host:utils.Host, ID:int, maxHops:int):
self.maxHops = maxHops

# A bunch of stuff needs to be tweaked if we're using IPv6
if host.family is socket.AF_INET6:
# BTW, this doesn't actually work. The RFCs for IPv6 don't define
# the behaviour of raw sockets - which are heavily utilized by
# `connvitals`. One of these days, I'll have to implement it using
# raw ethernet frames ...

self.receiver = socket.socket(family=host.family,
type=socket.SOCK_RAW,
proto=socket.IPPROTO_ICMPV6)
self.setTTL = self.setIPv6TTL
self.isMyTraceResponse = self.isMyIPv6TraceResponse
if host.family is socket.AF_INET6:
if socket.has_ipv6:
# BTW, this doesn't actually work. The RFCs for IPv6 don't define
# the behaviour of raw sockets - which are heavily utilized by
# `connvitals`. One of these days, I'll have to implement it using
# raw ethernet frames ...

self.receiver = socket.socket(family=host.family,
type=socket.SOCK_RAW,
proto=socket.IPPROTO_ICMPV6)
self.setTTL = self.setIPv6TTL
self.isMyTraceResponse = self.isMyIPv6TraceResponse
else:
raise EnvironmentError("IPv6 stack is not available on this system.")

else:
self.receiver = socket.socket(family=host.family,
Expand Down