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

Requests leak out of HTTP proxy #1384

Closed
cyqsimon opened this issue Jan 29, 2024 · 1 comment · Fixed by #1412
Closed

Requests leak out of HTTP proxy #1384

cyqsimon opened this issue Jan 29, 2024 · 1 comment · Fixed by #1412
Labels
bug Something isn't working

Comments

@cyqsimon
Copy link
Contributor

cyqsimon commented Jan 29, 2024

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

  1. On a host machine, install privoxy (or another proxy server of your choice).
  2. Configure privoxy to listen on all interfaces (in /etc/privoxy/config, set the value of listen-address to :8118).
  3. Start privoxy.
  4. Open up a quiet VM, ideally Linux. Make sure VM can access host's privoxy instance (check host's firewall?).
  5. On the VM, install ncspot and wireshark; start wireshark.
  6. In wireshark, set the following filter: tcp && ip.dst != <VM_IP>.
  7. In wireshark, enable "View > Name Resolution > Resolve Network Addresses".
  8. Start ncspot like so: http_proxy=http://<HOST_IP>:8118 ncspot (or whatever proxy address you are using).
  9. 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

wireshark capture

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.

ncspot.log

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.

@cyqsimon cyqsimon added the bug Something isn't working label Jan 29, 2024
@cyqsimon
Copy link
Contributor Author

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.

cyqsimon added a commit to cyqsimon/ncspot that referenced this issue Mar 9, 2024
@cyqsimon cyqsimon mentioned this issue Mar 9, 2024
2 tasks
hrkfdn added a commit that referenced this issue Mar 9, 2024
* Bump rspotify to 0.13.0

Fixes #1384

* Write changelog

* chore: Migrate away from deprecated constructor

---------

Co-authored-by: Henrik Friedrichsen <henrik@affekt.org>
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

Successfully merging a pull request may close this issue.

1 participant