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

Listen on IPv4 and IPv6 #37

Closed
hhartzer opened this issue Feb 7, 2024 · 2 comments · Fixed by #42
Closed

Listen on IPv4 and IPv6 #37

hhartzer opened this issue Feb 7, 2024 · 2 comments · Fixed by #42

Comments

@hhartzer
Copy link
Contributor

hhartzer commented Feb 7, 2024

Hi,

Is it possible to listen on IPv4 and IPv6 at the same time? On Linux, the default is generally that IPv6 sockets also listen on IPv4. On FreeBSD this is not the default, so one would have to launch two servers to serve both.

Thank you!

@emikulic
Copy link
Owner

I haven't looked into how to do this on FreeBSD. I'd be willing to merge a patch that did this.

@hhartzer
Copy link
Contributor Author

Sounds good!

I started working on this and noticed an interesting bug.

$ ./darkhttpd --ipv6
darkhttpd/1.15.from.git, copyright (c) 2003-2024 Emil Mikulic.
listening on: http://0.0.0.0:8080/
^C
$ ./darkhttpd . --ipv6
darkhttpd/1.15.from.git, copyright (c) 2003-2024 Emil Mikulic.
listening on: http://[::]:8080/
^C

I also wonder if the best behavior, down the road, might be accepting --listen arguments that would take IP and port pairs (or maybe just IP). Could also just be multiple --addr and IPv4/IPv6 support could be handled that way.

hhartzer added a commit to hhartzer/darkhttpd that referenced this issue Feb 28, 2024
This could have already been the default behavior on your OS, but
now it will be consistently utilized. Prior to this, to support IPv4
and IPv6 you would have to run two servers or set the relevant sysctl.

Also fixes incorrect inet_pton() usage.

Closes: emikulic#37
emikulic pushed a commit that referenced this issue Feb 28, 2024
This could have already been the default behavior on your OS, but
now it will be consistently utilized. Prior to this, to support IPv4
and IPv6 you would have to run two servers or set the relevant sysctl.

Also fixes incorrect inet_pton() usage.

Closes: #37
This issue was closed.
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 a pull request may close this issue.

2 participants