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

Incorrect address returned when listening to IPv6 #2994

Open
1 task done
moyanj opened this issue Aug 25, 2024 · 0 comments
Open
1 task done

Incorrect address returned when listening to IPv6 #2994

moyanj opened this issue Aug 25, 2024 · 0 comments
Labels

Comments

@moyanj
Copy link

moyanj commented Aug 25, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When I set the host to  :: , the returned IP address (both  request.client_ip and  request.ip ) is incorrect when accessing via IPv4.
Just like this: ::ffff:127.0.0.1

Code snippet

from sanic import Sanic, response
from sanic.request import Request
app = Sanic("MyApp")

@app.route("/")
async def test(request: Request):
    return response.text(request.ip)
   
if __name__ == "__main__":
    app.run(host="::", port=8080, debug=True)

Expected Behavior

Returns the correct IPv4 address

How do you run Sanic?

As a script (app.run or Sanic.serve)

Operating System

Linux

Sanic Version

24.6.0

Additional context

No response

@moyanj moyanj added the bug label Aug 25, 2024
@moyanj moyanj changed the title Listen to both IPv4 and IPv6 simultaneously. Incorrect address returned when listening to IPv6 Aug 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant