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(utils/ipaddr): support IPv6-mapped IPv4 address #3727

Merged
merged 1 commit into from
Dec 6, 2024

Conversation

usualoma
Copy link
Member

@usualoma usualoma commented Dec 5, 2024

fixes #3723

Return value of getConniInfo(c)

In all the runtimes, an IPv6-mapped IPv4 address was returned as the remote address, so I think it is appropriate to handle this by fixing convertIPv6BinaryToString.

import { Hono } from './src/'
import { getConnInfo } from './src/adapter/deno/conninfo' // or bun, node-server

export default new Hono().get('/', (c) => {
  return c.json(getConnInfo(c))
})
$ deno serve --unstable-sloppy-imports --host [::] app.ts
$ bun run app.ts
% curl http://[::ffff:127.0.0.1]:8000/
{"remote":{"address":"::ffff:127.0.0.1","port":64504,"transport":"tcp"}}
% curl http://[::ffff:7f00:1]:8000/
{"remote":{"address":"::ffff:127.0.0.1","port":64519,"transport":"tcp"}}

The author should do the following, if applicable

  • Add tests
  • Run tests
  • bun run format:fix && bun run lint:fix to format the code
  • Add TSDoc/JSDoc to document the code

@usualoma
Copy link
Member Author

usualoma commented Dec 5, 2024

@nakasyou @yusukebe

Would you please review?

Copy link

codecov bot commented Dec 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.72%. Comparing base (190e122) to head (87bda2d).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3727      +/-   ##
==========================================
+ Coverage   91.70%   91.72%   +0.02%     
==========================================
  Files         159      159              
  Lines       10158    10184      +26     
  Branches     2855     2879      +24     
==========================================
+ Hits         9315     9341      +26     
  Misses        842      842              
  Partials        1        1              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nakasyou
Copy link
Contributor

nakasyou commented Dec 5, 2024

Hi @usualoma, it looks good to me.

Copy link
Member

@yusukebe yusukebe left a comment

Choose a reason for hiding this comment

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

LGTM!

@yusukebe
Copy link
Member

yusukebe commented Dec 6, 2024

@usualoma

Thanks! Merging now.

@yusukebe yusukebe merged commit af5affc into honojs:main Dec 6, 2024
16 checks passed
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.

ipRestriction not catching ::ffff:127.0.0.1
3 participants