Requests leak out of HTTP proxy
cyqsimon opened this issue · 1 comments
Description
When running ncspot with http_proxy
environment variable set, most requests are proxied correctly, but some requests to api.spotify.com
(which is CNAME
-ed to edge-web.dual-gslb.spotify.com
) are not. This is problematic if the network environment requires the use of a proxy for external network access.
Specifically, features like search and favourites are not accessible, although if a track is already selected it can continue to play (because the track streaming API calls are correctly proxied).
Steps to reproduce
- On a host machine, install privoxy (or another proxy server of your choice).
- Configure privoxy to listen on all interfaces (in
/etc/privoxy/config
, set the value oflisten-address
to:8118
). - Start privoxy.
- Open up a quiet VM, ideally Linux. Make sure VM can access host's privoxy instance (check host's firewall?).
- On the VM, install ncspot and wireshark; start wireshark.
- In wireshark, set the following filter:
tcp && ip.dst != <VM_IP>
. - In wireshark, enable "View > Name Resolution > Resolve Network Addresses".
- Start ncspot like so:
http_proxy=http://<HOST_IP>:8118 ncspot
(or whatever proxy address you are using). - Observe in wireshark's captures that while some requests are sent to host (these are correctly proxied), some requests are sent directly to
edge-web.dual-gslb.spotify.com
.
If you want to see what happens when a direct connection to api.spotify.com
is not possible, simply remove the default route in your VM: sudo ip route del default
. If you are using NetworkManager, you may have to do this by setting "IPv4 > Use only for resources on this connection" for the active network profile, then reconnecting the network.
Expected behaviour
All requests of ncspot are proxied.
Screenshots
System
- OS: Endeavour OS, 6.7.2-arch1-1 x86_64
- Terminal: Alacritty
- Version: 1.0.0
- Installed from: cargo
Debug log
For this log, I have blocked direct connection to api.spotify.com
so that these requests can error.
Additional context
I have also tried setting https_proxy
and ALL_PROXY
, but it seems like the only one that has any effect is http_proxy
.
Okay I think I'm able to trace the problem to rspotify_http
. Specifically, when using ureq
as the HTTP client library, proxy environment variable detection is not enabled by default.
I'll go make a PR there.