Repository: youtube-dl
Issue: SOCKS proxy mechanism does not support IPv6
Labels: bug

## Please follow the guide below

- You will be asked some questions and requested to provide some information, please read them **carefully** and answer honestly
- Put an `x` into all the boxes [ ] relevant to your *issue* (like this: `[x]`)
- Use the *Preview* tab to see what your issue will actually look like

---

### Make sure you are using the *latest* version: run `youtube-dl --version` and ensure your version is *2018.01.18*. If it's not, read [this FAQ entry](https://github.com/rg3/youtube-dl/blob/master/README.md#how-do-i-update-youtube-dl) and update. Issues with outdated version will be rejected.
- [x] I've **verified** and **I assure** that I'm running youtube-dl **2018.01.18**

### Before submitting an *issue* make sure you have:
- [x] At least skimmed through the [README](https://github.com/rg3/youtube-dl/blob/master/README.md), **most notably** the [FAQ](https://github.com/rg3/youtube-dl#faq) and [BUGS](https://github.com/rg3/youtube-dl#bugs) sections
- [x] [Searched](https://github.com/rg3/youtube-dl/search?type=Issues) the bugtracker for similar issues including closed ones

### What is the purpose of your *issue*?
- [x] Bug report (encountered problems with youtube-dl)
- [ ] Site support request (request for adding support for a new site)
- [ ] Feature request (request for a new functionality)
- [ ] Question
- [ ] Other

---

### If the purpose of this *issue* is a *bug report*, *site support request* or you are not completely sure provide the full verbose output as follows:

```
$ youtube-dl.real -v --proxy socks5://fuyu.home.romanrm.net:1080/ https://www.youtube.com/watch?v=s8kOsoPZUkc
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'-v', u'--proxy', u'socks5://fuyu.home.romanrm.net:1080/', u'https://www.youtube.com/watch?v=s8kOsoPZUkc']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2018.01.18
[debug] Python version 2.7.13 (CPython) - Linux-4.14.8-rm1+-x86_64-with-debian-8.10
[debug] exe versions: ffmpeg 3.2.5-1, ffprobe 3.2.5-1
[debug] Proxy map: {u'http': u'socks5://fuyu.home.romanrm.net:1080/', u'https': u'socks5://fuyu.home.romanrm.net:1080/'}
[youtube] s8kOsoPZUkc: Downloading webpage
ERROR: Unable to download webpage: <urlopen error [Errno -2] Name or service not known> (caused by URLError(gaierror(-2, 'Name or service not known'),))
  File "/usr/local/bin/youtube-dl.real/youtube_dl/extractor/common.py", line 517, in _request_webpage
    return self._downloader.urlopen(url_or_request)
  File "/usr/local/bin/youtube-dl.real/youtube_dl/YoutubeDL.py", line 2198, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "/usr/lib/python2.7/urllib2.py", line 429, in open
    response = self._open(req, data)
  File "/usr/lib/python2.7/urllib2.py", line 447, in _open
    '_open', req)
  File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain
    result = func(*args)
  File "/usr/local/bin/youtube-dl.real/youtube_dl/utils.py", line 1089, in https_open
    req, **kwargs)
  File "/usr/lib/python2.7/urllib2.py", line 1198, in do_open
    raise URLError(err)

$ host fuyu.home.romanrm.net
fuyu.home.romanrm.net has IPv6 address fd39::101

$ ping6 fuyu.home.romanrm.net
PING fuyu.home.romanrm.net(fd39::101 (fd39::101)) 56 data bytes
64 bytes from fd39::101 (fd39::101): icmp_seq=1 ttl=64 time=0.238 ms
64 bytes from fd39::101 (fd39::101): icmp_seq=2 ttl=64 time=0.232 ms
^C
--- fuyu.home.romanrm.net ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.232/0.235/0.238/0.003 ms
```

---

### Description of your *issue*, suggested solution and other information

Does not work with proxy hostnames which resolve to IPv6 only.

Does not work with bare IPv6 specified (in brackets) instead of the hostname either. The error then becomes

```
ERROR: Unable to download webpage: <urlopen error [Errno -9] Address family for hostname not supported> (caused by URLError(gaierror(-9, 'Address family for hostname not supported'),))
```