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

ipRestriction not catching ::ffff:127.0.0.1 #3723

Closed
jnatmorris opened this issue Dec 4, 2024 · 2 comments · Fixed by #3727
Closed

ipRestriction not catching ::ffff:127.0.0.1 #3723

jnatmorris opened this issue Dec 4, 2024 · 2 comments · Fixed by #3727
Labels

Comments

@jnatmorris
Copy link

jnatmorris commented Dec 4, 2024

What version of Hono are you using?

4.6.12

What runtime/platform is your app running on? (with version if possible)

Node

What steps can reproduce the bug?

import { serve } from "@hono/node-server";
import { Hono } from "hono";
import { logger } from "hono/logger";
import { ipRestriction } from "hono/ip-restriction";
import { getConnInfo } from "@hono/node-server/conninfo";

const app = new Hono()
.use(logger())
.use(async (c, next) => {
console.log(getConnInfo(c));
await next();
})
.use(
"*",
ipRestriction(getConnInfo, {
denyList: [],
allowList: ["127.0.0.1", "::1", "::ffff:127.0.0.1"],
}),
)
.get("/", (c) => {
return c.text("will not reach");
})

What is the expected behavior?

HTTP requests from any of the allowed list shall be able to reach the .get("/",(c)=>{...}.

What do you see instead?

When making HTTP requests from the same computer (localhost), a 403 is returned.

Screenshot 2024-12-04 at 20 37 44

Additional information

At first I was only making my HTTP requests from a nextjs server component. This did not work. I then used an HTTP making client, and am running into the same issue.

@EdamAme-x
Copy link
Contributor

EdamAme-x commented Dec 5, 2024

In internal, ::ffff:127.0.0.1 converted to ::ffff:127

@jnatmorris
Copy link
Author

Thank you for your response. I can have a try allowing the other IP you provided and get back to you later on that.

I'm not too well versed in IP semantics beyond the basics so maybe I'm missing something, but shouldn't it still accept the original as well as the converted one? Or maybe a clarification in the docs of why this other IP is required and not the original?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants