Skip to content

Conversation

@petraglyph
Copy link
Contributor

The existing code would never properly select the IPv4 address instead a fallback value was selected when the IPv4 option was used, the script is updated to that both IPv4 and IPv6 will be properly selected.

Copy link
Member

@debarshiray debarshiray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this @pennbauman ! It took me while to figure out what's going on - clearly I don't know Python or networking at all. :D

Let me see if I got it right.

You are beginning to accumulate some non-trivial commits in the project. You should consider adding yourself to the copyright notices of the files you have touched.

import socket; \
import sys; \
family = socket.AddressFamily.AF_INET if sys.argv[1] == "A" else 0; \
family = socket.AddressFamily.AF_INET6 if sys.argv[1] == "AAAA" else 0; \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, family was getting overwritten to 0 in the second line if sys.argv[1] is "A", right?

family = socket.AddressFamily.AF_INET if sys.argv[1] == "A" else 0; \
family = socket.AddressFamily.AF_INET6 if sys.argv[1] == "AAAA" else 0; \
addr = socket.getaddrinfo(sys.argv[2], None, family, socket.SocketKind.SOCK_RAW)[0][4][0]; \
family = {"A": socket.AddressFamily.AF_INET, "AAAA": socket.AddressFamily.AF_INET6}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we missing a trailing semi-colon?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the tests don't fail without the trailing semi-colon. Maybe they are getting skipped internally and not getting reflected as a failure?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I restored the semi-colon for the time being. The tests pass. Please let me know if I got that wrong.

debarshiray pushed a commit to petraglyph/toolbox that referenced this pull request Sep 13, 2025
The existing code was overwriting the address family from
socket.AddressFamily.AF_INET to 0, when an IPv4 address was requested by
setting sys.argv[1] to 'A'.

Fallout from 5bac0ba

containers#1598

Signed-off-by: Penn Bauman <me@pennbauman.com>
The existing code was overwriting the address family from
socket.AddressFamily.AF_INET to 0, when an IPv4 address was requested by
setting sys.argv[1] to 'A'.

Fallout from 5bac0ba

containers#1598

Signed-off-by: Penn Bauman <me@pennbauman.com>
@softwarefactory-project-zuul
Copy link

@debarshiray debarshiray merged commit e13a58c into containers:main Sep 13, 2025
3 checks passed
@debarshiray
Copy link
Member

Thanks again, @pennbauman !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants