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

Binding to IPv4 and IPv6 works differently than in the examples #67

Open
raek opened this issue Aug 3, 2022 · 4 comments
Open

Binding to IPv4 and IPv6 works differently than in the examples #67

raek opened this issue Aug 3, 2022 · 4 comments

Comments

@raek
Copy link

raek commented Aug 3, 2022

After some fiddling around I found that:

  • binding to "0.0.0.0" accepts IPv4 connections (as expected
  • binding to "" gives an error (it says that the IPv6 address is already in use)
  • binding to "::" accepts both IPv4 and IPv6 connections (even more surprisingly)

When binding to "::", the IPv4 addresses are displayed as ::ffff:139.162.187.208 in the log.

Maybe we should just update the documentation to reflect this. Or is there something that should be changed in the code?

@raek
Copy link
Author

raek commented Aug 3, 2022

I'm using Jetforce v0.9.1 and I'm happy to aid in debugging or digging into the code.

@makew0rld
Copy link

binding to "::" accepts both IPv4 and IPv6 connections (even more surprisingly)

This is pretty standard. This is usual behaviour for Linux in my experience, and is probably standardized somewhere. I doubt this is related to Jetforce.

@michael-lazar
Copy link
Owner

Here's what jetforce/twisted is doing under the hood with the sockets:

  • host=0.0.0.0
    • Bind to 0.0.0.0 with AF_INET
  • host=::
    • Bind to :: with AF_INET6
  • host=""
    • Bind to 0.0.0.0 with AF_INET
    • Bind to :: with AF_INET6

This ticket describes pretty much the exact behavior that we're seeing and why it's complicated: twisted/twisted#198

Basically it's operating system dependent. For me it works, but I'm developing on macOS and my production server only uses IPv4. I could see a couple of fixes here:

I'm open to a PR!

@nobrowser
Copy link

binding to "::" accepts both IPv4 and IPv6 connections (even more surprisingly)

This is pretty standard. This is usual behaviour for Linux in my experience, and is probably standardized somewhere. I doubt this is related to Jetforce.

I think this is controlled by the sysctl flag net.ipv6.bindv6only . Myself, I prefer to set it to 1 , in order to avoid this confusing behavior.

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

No branches or pull requests

4 participants