gaurishhs / elysia-ip

Get Client IP Address in Elysia
MIT License
50 stars 10 forks source link

returning ipv4 address as ipv6 #2

Closed shersch closed 9 months ago

shersch commented 9 months ago

Hi. First of all, thank you so much for this repo; it saved me a headache I was not interested in dealing with!

I'm only just getting started building out the app I'm working on, but I'm seeing this when I run the dev server and ping it from another device on my local network:

{
  address: "::ffff:192.168.1.154",
  family: "IPv6",
  port: 56144,
}

I know the client IPv4 address is 192.168.1.154; I'm not sure why it's showing up here as IPv6 though.

gaurishhs commented 9 months ago

hi!

IPv6 is the default Internet protocol and has priority over IPv4. Your client must be using IPv6 and that's why you're getting an IPv6 address but that is an IPv4 mapped IPv6 address.

shersch commented 9 months ago

Thanks for the response! Is there a way to prioritize ipv4, or just get both?

gaurishhs commented 9 months ago

You might want to ask Bun for this but as far as I know if you're using curl for making the request use the ipv4 argument which forces IPv4

curl --ipv4 host