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

strip the prefix from ipv4-mapped addresses #73

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

eworm-de
Copy link
Contributor

This allows to have plain IPv4 addresses in log, even if listening on an IPv6 socket.

@hhartzer
Copy link
Contributor

This is cool! I think it's a good idea, but I feel like some test cases for it might be a good idea.

I'm also not 100% sure that it's safe under all circumstances. At first glance it certainly looks fine, though.

Just my two cents.

@eworm-de
Copy link
Contributor Author

I could not come up with a situation that could cause trouble... But yes, looks too easy to be real. 😜

darkhttpd.c Outdated Show resolved Hide resolved
@emikulic
Copy link
Owner

Could you please give me an example of how this looks? I guess in the access log?

@eworm-de
Copy link
Contributor Author

eworm-de commented Jan 25, 2025

Yes, this is for access log. Before:

::ffff:10.7.7.72 - - [24/Jan/2025:22:15:54 +0100] "GET /archive.tar.zst HTTP/1.1" 200 72194 "" "pacredir/0.4.8 (arch/x86_64)"

After:

10.7.7.72 - - [24/Jan/2025:22:15:54 +0100] "GET /archive.tar.zst HTTP/1.1" 200 72194 "" "pacredir/0.4.8 (arch/x86_64)"

@eworm-de eworm-de force-pushed the strip-mapped branch 2 times, most recently from e3c12c4 to 0793a4b Compare January 27, 2025 10:25
@eworm-de
Copy link
Contributor Author

Updated again... There's a macro IN6_IS_ADDR_V4MAPPED to detect this kind of addresses... Use that instead of string comparison to make it more efficient.

@eworm-de eworm-de force-pushed the strip-mapped branch 2 times, most recently from ac48ad1 to 9e5738c Compare January 27, 2025 14:59
... to use it again later.
This allows to have plain IPv4 addresses in log, even if listening
on an IPv6 socket.

Before:

    ::ffff:10.7.7.72 - - [24/Jan/2025:22:15:54 +0100] "GET /archive.tar.zst HTTP/1.1" 200 72194 "" "pacredir/0.4.8 (arch/x86_64)"

After:

    10.7.7.72 - - [24/Jan/2025:22:15:54 +0100] "GET /archive.tar.zst HTTP/1.1" 200 72194 "" "pacredir/0.4.8 (arch/x86_64)"
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.

3 participants