unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "J.P." <jp@neverwas.me>
To: Jacobo <gnuhacker@member.fsf.org>
Cc: 53941@debbugs.gnu.org
Subject: bug#53941: 27.2; socks + tor dont work with https
Date: Sat, 05 Mar 2022 18:58:55 -0800	[thread overview]
Message-ID: <87pmmz947k.fsf@neverwas.me> (raw)
In-Reply-To: <87wnh7hkgi.fsf@gnu.org> (Jacobo's message of "Sun, 06 Mar 2022 03:40:45 +0100")

Jacobo <gnuhacker@member.fsf.org> writes:

> "J.P." <jp@neverwas.me> writes:
>
>> v3. Passing around an opener function was clunky, so I've opted for
>> passing around contact params instead. I've also gone back to explicitly
>> setting the coding to binary because folks may not be using
>> `url-open-stream' (which does this indirectly by let-binding
>> `coding-system-for-{read,write}').
>
> Emacs 28.0.91 compiled with this patches, dont work, connections dont
> use the proxy

As I tried to explain up thread, the patches only get you half way
there. But perhaps that wasn't clear. You still need to do something
like the following, which is what I MemoServ'd you about (but I guess
you didn't get it). Quoting from there:

  ;; This works with eww. Try https://check.torproject.org

  (require 'socks)
  (require 'gnutls)
  (require 'nsm)

  (setq socks-server '("tor" "127.0.0.1" 9050 5)
        socks-username "user"
        socks-password ""
        url-gateway-method 'socks)

  (defun my-socks-open-https (orig name buffer host service &rest params)
    (let ((proc (apply orig name buffer host service params)))
      (advice-add 'network-lookup-address-info :override #'socks-tor-resolve)
      (unwind-protect
          (when (eq service 443)
            (gnutls-negotiate :process proc :hostname host)
            (unless (string-suffix-p ".onion" host)
              (nsm-verify-connection proc host service)))
        (advice-remove 'network-lookup-address-info #'socks-tor-resolve))
      proc))

  (defun my-url-open-stream (args)
    (pcase-let ((`(,name ,buffer ,host ,service ,gateway-method) args))
      (when (and (eq url-gateway-method 'socks)
                 (eq gateway-method 'tls))
        (setq gateway-method nil))
      (list name buffer host service gateway-method)))

  (advice-add 'socks-open-network-stream :around #'my-socks-open-https)
  (advice-add 'url-open-stream :filter-args #'my-url-open-stream)


The above is an example of what I was getting at in my initial reply
about mimicking the recipe in the last patch (the ERT test). If you have
questions about how to use it, I can help you in real time on Libera, as
we did with applying the patches. Also, please try this with emacs -Q.
Thanks.





  reply	other threads:[~2022-03-06  2:58 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-11 11:09 bug#53941: 27.2; socks + tor dont work with https Jacobo
2022-02-14 12:37 ` J.P.
2022-02-19 21:04   ` Jacobo
2022-02-21 15:01     ` J.P.
2022-03-01 14:29       ` J.P.
2022-03-02  2:37         ` J.P.
2022-03-06  2:40           ` Jacobo
2022-03-06  2:58             ` J.P. [this message]
2022-03-07  7:09               ` J.P.
2022-03-10  8:58                 ` J.P.
2022-11-28 15:30                   ` bug#53941: Last-minute socks.el improvements for Emacs 29? J.P.
2022-11-28 17:12                     ` Eli Zaretskii
2022-11-29 14:24                       ` J.P.
2022-11-29 14:36                         ` Eli Zaretskii
2023-09-06 22:25                           ` bug#53941: 27.2; socks + tor dont work with https Stefan Kangas
2023-09-07  5:53                             ` Eli Zaretskii
2023-09-07 13:25                               ` J.P.
2023-09-07 13:47                                 ` Stefan Kangas
2023-09-08  2:55                                   ` J.P.
2023-09-08 11:04                                     ` Stefan Kangas
2023-10-18 13:38                                     ` J.P.
2023-12-19 16:29                                       ` J.P.
2023-09-08 13:28                                 ` J.P.
2023-09-09 14:05                                   ` J.P.

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pmmz947k.fsf@neverwas.me \
    --to=jp@neverwas.me \
    --cc=53941@debbugs.gnu.org \
    --cc=gnuhacker@member.fsf.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).