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

Support SOCKS5 proxies #3373

Open
adamhotep opened this issue Jul 28, 2016 · 27 comments
Open

Support SOCKS5 proxies #3373

adamhotep opened this issue Jul 28, 2016 · 27 comments

Comments

@adamhotep
Copy link

It would be nice to have a config item like socks_proxy or socks5_proxy to support SOCKS proxies.

At the moment, even commands like tsocks mpv http://server/test.webm fail to work, and though curl --socks5 localhost:1080 http://server/test.webm |mpv --cache=512 works, you can't seek since mpv isn't controlling the network stream.

This SO question explains the issue farther.

@haasn
Copy link
Member

haasn commented Jul 28, 2016

If you can use a regular HTTP proxy instead of a SOCKS proxy, you can set the environment variable HTTP_PROXY="url" to make FFmpeg and youtube-dl pick up on it.

Judging by a quick glance at FFmpeg code, it doesn't seem to support socks proxies at all, so any support for them in mpv would be blocked by this. (Also keep in mind that youtube-dl would also need support for them if you plan on using it)

@lamarpavel
Copy link

The combination of privoxy, HTTP_PROXY/HTTPS_PROXY as envvar and youtube-dl works well enough. I would argue that additional code for this in mpv would be an unnecessary burden to maintain.

@nxtreaming
Copy link

Why do you need socks5?

There is no a good open source SOCKS 5 server available.

@adamhotep
Copy link
Author

adamhotep commented Jul 28, 2016

OpenSSH is an open source SOCKS 5 server. It's even the one I use (ssh -D1080 myserver). I do not use an HTTP proxy and am not interested in setting one up on my remote server. If the right move is to escalate to FFMPEG (and youtube-dl), then so be it. I was just hoping it would be attractive enough to implement here.

@v2px
Copy link

v2px commented Sep 20, 2016

I just found this after looking at the man page and not seeing anything socks related. At least for the youtube-dl integration it works for me, like this:

http_proxy=socks5://127.0.0.1:9050 mpv [...]

mpv 0.18.0
youtube-dl 2016.07.09.2

@liaowang11
Copy link

liaowang11 commented Dec 30, 2016

@v2px I tried

http_proxy=socks5://127.0.0.1:9050 mpv [...]

But it no longer works. Found polipo to the rescue.

@haasn
Copy link
Member

haasn commented Dec 30, 2016

Btw, I forgot to mention this, but proxychains mpv works fine. I use it for watching youtube videos over tor (which also exposes a SOCKS proxy).

@Justsoos
Copy link

Justsoos commented Jan 29, 2017

Hope mpv could provide proxy support, might you not know, the VPNs are slaughtered in some countries, like China, Iran, North Korea, and people of those nations have to set up socks and http proxy to get the Youtube, Google and so on.
So nicely handy thing if MPV could have a proxy support.

@Justsoos
Copy link

@haasn yeap, proxychains is good at linux and unices, but in windows, it is hard to find a handy way except a proxy included in mpv.

@ilf
Copy link

ilf commented Aug 18, 2017

I would also love SOCKS proxy support. It's the proxy of choice for Tor.

@Justsoos
Copy link

Justsoos commented Nov 19, 2017

resolved.
first, set your environment variable with:
$ set http_proxy=http://127.0.0.1:1080
$ set https_proxy=http://127.0.0.1:1080

second, with privoxy or gost to transfer remote socks5 proxy service to a local http proxy port -> 127.0.0.1:1080.

then mpv can use local http proxy instead of any socks ones.

@garoto
Copy link
Contributor

garoto commented Nov 19, 2017

AFAIK, the http_proxy envvar will cover both secure and non-secure http variants, so no need for a set https=... one?

But otherwise, good info I guess.

@lamarpavel
Copy link

@garoto This is application dependant and I wouldn't trust all programs to get this right. It doesn't hurt to simply

export http_proxy=http://127.0.0.1:8118
export HTTP_PROXY="$http_proxy"
export https_proxy="$http_proxy"
export HTTPS_PROXY="$http_proxy"
export ftp_proxy="$http_proxy"
export rsync_proxy="$http_proxy"
export no_proxy="localhost,127.0.0.1"

to reduce risk of information leaks.

@garoto
Copy link
Contributor

garoto commented Nov 19, 2017

If that's the case, then it sucks that there's no conventional way of doing it. Feels kinda dirty to polute your shell .rc with what might be redundant envvars afterall... (I'm on Windows btw).

@Justsoos
Copy link

@lamarpavel in Xinux, you can do better with proxychains-ng, u can use socks proxy directly instead of transfer for http proxy.

so, what I said is just for M$ windows.

@Justsoos
Copy link

@garoto AFAIK, the http_proxy envvar will cover both secure and non-secure http variants, so no need for a set https=... one?

bad news, in Win 10, you have to also set https_proxy env, or you can not access https website by proxy.

@garoto
Copy link
Contributor

garoto commented Nov 19, 2017

Ugh, I find it hard to believe that there's logic bult in "Win10" to differentiate between a http_proxy and a https_proxy env. variable, but who knows right?

@Justsoos
Copy link

Justsoos commented Mar 22, 2018

this is my workout in one line command with win 10:
cmd.exe /C "set http_proxy=http://127.0.0.1:1080 && set https_proxy=http://127.0.0.1:1080 && c:\mpv.exe "URL""
and before that, have to run privoxy first to convert socks5 proxy to http proxy.
terrible experience ...

@rypervenche
Copy link

Is this still not something that we can get? It's been a request for 2 years now.

@IamPARANOID
Copy link

I mean, you can do something like:

 mpv --ytdl-raw-options=proxy=[socks5://localhost:9050] videolinkhere

But there is some confusing language in the manual about this:

"A proxy URL can be passed for youtube-dl to use it in parsing
the website. This is useful for geo-restricted URLs. After
youtube-dl parsing, some URLs also require a proxy for playback,
so this can pass that proxy information to mpv. Take note that
SOCKS proxies aren't supported and https URLs also bypass the
proxy. This is a limitation in FFmpeg."

Judging by this text it is half supported, and you must choose between HTTPS or Proxy/Tor?

@garoto
Copy link
Contributor

garoto commented May 18, 2019

youtube-dl is only used to fetch the actual URL of the video (generally a googlevideo.com one) and then that URL is passed to the ffmpeg http downloader code, which doesnt support socks proxies.

For instance, if you feed the output of the command below to ffplay you get video:
$ youtube-dl.exe --get-url https://www.youtube.com/watch?v=8EKl9aF4NnM

I think Justsoos idea of using gost as a forwarder works great and probably the best solution right now.

#3373 (comment)

@Justsoos
Copy link

Justsoos commented Oct 19, 2019

in general, if you run mpv behind proxy, it must be a http proxy, if you have only socks proxy, transfer it to local http proxy first by privoxy or gost.

run it like, assuming your http proxy is 127.0.0.1:1080:
http_proxy=http://127.0.0.1:1080 mpv $URL
the http:// must be there, or error

if you run mpv to see youtube, you have to install youtube-dl first and run command line like:
http_proxy=http://127.0.0.1:1080 mpv --ytdl-raw-options=proxy=%14%127.0.0.1:1080 $YOUTUBE_URL

this command seems a CRAZY one which you MUST NOT change any letter of:
http_proxy=http://
and
proxy=%14%127.0.0.1:1080
the number 14 is the length of 127.0.0.1:1080, include the punctuation characters, if your proxy's word-length is not exact like my example, pls count them by yourself.

another way to avoid that maddening shackles is setting the mpv.conf like:

ytdl=yes
ytdl-raw-options=proxy=[http://127.0.0.1:1080]

so you do not need to count the numbers on your screen...
but you still need to run mpv like:
http_proxy=http://127.0.0.1:1080 mpv $YOUTUBE_URL
that is a flatter programmer's game, not for users, enjoy it!

@omnigenous
Copy link

@lamarpavel, @Justsoos is there a guide how to setup privoxy to convert socks5 proxy to http(s)?

@13ilya
Copy link

13ilya commented Aug 17, 2024

Why do you need socks5?

There is no a good open source SOCKS 5 server available.

https://3proxy.ru

@13ilya
Copy link

13ilya commented Aug 17, 2024

Still no acceptable solution except using vpn?

You can just forget about HTTP proxies, no video hosting does not work with http protocol!
I can't find a normal HTTPS proxy, they all give the error curl: (35) OpenSSL/3.1.4: error:0A00010B:SSL routines::wrong
version number
I can't always use vpn, so I need to be accessible from outside.

SOCKS5 is a perfect solution that works with browser and curl.

But unfortunately it doesn't work anymore neither through http nor through socks5 proxy. :-(
YouTube somehow understands that proxy is used.
yt-dlp --proxy socks5://127.0.0.1:1080 -F https://www.youtube.com/watch?v=glfh9XC-p9Q

[youtube] Extracting URL: https://www.youtube.com/watch?v=glfh9XC-p9Q
[youtube] glfh9XC-p9Q: Downloading webpage
[youtube] glfh9XC-p9Q: Downloading ios player API JSON
[youtube] glfh9XC-p9Q: Downloading web creator player API JSON
ERROR: [youtube] glfh9XC-p9Q: Sign in to confirm you’re not a bot. This helps protect our community. Learn more

yt-dlp --proxy http://127.0.0.1:3128 -F https://www.youtube.com/watch?v=glfh9XC-p9Q

[youtube] Extracting URL: https://www.youtube.com/watch?v=glfh9XC-p9Q
[youtube] glfh9XC-p9Q: Downloading webpage
[youtube] glfh9XC-p9Q: Downloading ios player API JSON
[youtube] glfh9XC-p9Q: Downloading web creator player API JSON
ERROR: [youtube] glfh9XC-p9Q: Sign in to confirm you’re not a bot. This helps protect our community. Learn more

@13ilya
Copy link

13ilya commented Aug 18, 2024

@lamarpavel, @Justsoos is there a guide how to setup privoxy to convert socks5 proxy to http(s)?

I used 3proxy for this.
/var/lib/3proxy/3proxy.cfg

auth iponly

allow * 127.0.0.1 *
parent 1000 socks5 SERVER PORT USER PASSWORD

socks -p1080
proxy -a -p3128

3proxy /var/lib/3proxy/3proxy.cfg
For test

curl -x socks5://127.0.0.1:1080 https://2ip.io
curl -x http://127.0.0.1:3128 https://2ip.io

The problem is that it doesn't work with YouTube anymore. :-(

@WeAreLiving1984
Copy link

https://en.wikipedia.org/wiki/Censorship_of_YouTube

I miss doing mpv https://youtube.com... :-(

Tried proxychains with no luck too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests