<p>socks.setdefaultproxy() has a fourth arg for sending DNS requests through the proxy<br>
<a href="https://github.com/OfflineIMAP/offlineimap/blob/master/offlineimap/imapserver.py#L119">https://github.com/OfflineIMAP/offlineimap/blob/master/offlineimap/imapserver.py#L119</a></p>

<p>However, even with that fourth arg set to True, using getaddrinfo() bypasses SOCKS5 proxy for dns resolution. This also breaks .onion Tor hidden service resolution.<br>
<a href="https://github.com/OfflineIMAP/offlineimap/blob/master/offlineimap/imaplibutil.py#L77">https://github.com/OfflineIMAP/offlineimap/blob/master/offlineimap/imaplibutil.py#L77</a></p>

<p>Might consider socks.wrapmodule().<br>
<a href="https://github.com/Anorov/PySocks/search?utf8=%E2%9C%93&q=wrap">https://github.com/Anorov/PySocks/search?utf8=%E2%9C%93&q=wrap</a></p>

<p>ping <a href="https://github.com/xiaket" class="user-mention">@xiaket</a></p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href="https://github.com/OfflineIMAP/offlineimap/issues/189">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AKFSEF3tQhQRCuSJAMklpkXMwXQqEYnmks5n-o0bgaJpZM4D-9D3.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
  <div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
    <link itemprop="url" href="https://github.com/OfflineIMAP/offlineimap/issues/189"></link>
    <meta itemprop="name" content="View Issue"></meta>
  </div>
  <meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>