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

Caching of getaddrinfo pins port #2

Open
jayvdb opened this issue Feb 5, 2020 · 0 comments
Open

Caching of getaddrinfo pins port #2

jayvdb opened this issue Feb 5, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@jayvdb
Copy link

jayvdb commented Feb 5, 2020

>>> socket.getaddrinfo('www.ros.org', 80)
[(<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 6, '', ('140.211.9.4', 80)), (<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_DGRAM: 2>, 17, '', ('140.211.9.4', 80)), (<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_RAW: 3>, 0, '', ('140.211.9.4', 80)), (<AddressFamily.AF_INET6: 10>, <SocketKind.SOCK_STREAM: 1>, 6, '', ('2605:bc80:3010:104::8cd3:904', 80, 0, 0)), (<AddressFamily.AF_INET6: 10>, <SocketKind.SOCK_DGRAM: 2>, 17, '', ('2605:bc80:3010:104::8cd3:904', 80, 0, 0)), (<AddressFamily.AF_INET6: 10>, <SocketKind.SOCK_RAW: 3>, 0, '', ('2605:bc80:3010:104::8cd3:904', 80, 0, 0))]
>>> socket.getaddrinfo('www.ros.org', 443)
[(<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 6, '', ('140.211.9.4', 443)), (<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_DGRAM: 2>, 17, '', ('140.211.9.4', 443)), (<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_RAW: 3>, 0, '', ('140.211.9.4', 443)), (<AddressFamily.AF_INET6: 10>, <SocketKind.SOCK_STREAM: 1>, 6, '', ('2605:bc80:3010:104::8cd3:904', 443, 0, 0)), (<AddressFamily.AF_INET6: 10>, <SocketKind.SOCK_DGRAM: 2>, 17, '', ('2605:bc80:3010:104::8cd3:904', 443, 0, 0)), (<AddressFamily.AF_INET6: 10>, <SocketKind.SOCK_RAW: 3>, 0, '', ('2605:bc80:3010:104::8cd3:904', 443, 0, 0))]

velocity patched_addr would cache the first result, pinning port 80 into the cache, and then a request for port 443 will return results for port 80.

This breaks usage of requests with websites where port 80 redirects to port 443, which is extremely common now.

velocity patched_addr also ignores the other args provided, which means it caches results which are inappropriate for subsequent invocations.

@s0md3v s0md3v added the bug Something isn't working label Feb 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants