Next: , Previous: , Up: Advanced Usage   [Contents][Index]

5.4 Integrations

5.4.1 URL

For anything to work, you’ll want to set url-irc-function to url-irc-erc. As a rule of thumb, libraries relying directly on url-retrieve should be fine out the box from Emacs 29.1 onward. On older versions of Emacs, you may need to (require 'erc) beforehand. See Retrieving URLs in URL.

For other apps and libraries, such as those relying on the higher-level browse-url, you’ll oftentimes be asked to specify a pattern, sometimes paired with a function that accepts a string URL as a first argument. For example, with EWW, you may need to tack something like "\\|\\`irc6?s?:" onto the end of eww-use-browse-url. But with gnus-button-alist, you’ll need a function as well:

  '("\\birc6?s?://[][a-z0-9.,@_:+%?&/#-]+" 0 t browse-url-irc 0)

Users on Emacs 28 and below may need to use browse-url instead.

5.4.2 SOCKS

People wanting to connect to IRC through a SOCKS proxy are most likely interested in doing so over TOR (The Onion Router). If that’s not you, please adapt these instructions accordingly. Otherwise, keep in mind that support for Tor is experimental and thus insufficient for safeguarding a user’s identity and location, especially in the case of targeted individuals.

ERC’s preferred Tor setup works by accessing a local Tor service through the built-in socks.el library that ships with Emacs. Other means of accessing Tor, such as via torsocks, are not supported. Before getting started, check that your Tor service is up and running. You can do that with the following command:

curl --proxy socks5h://localhost:9050 https://check.torproject.org | \
  grep 'Congratulations'

Networks and servers differ in how they expose Tor endpoints. In all cases, you’ll want to first set the option socks-server to something appropriate, like ("tor" "127.0.0.1" 9050 5). For some networks, setting erc-server-connect-function to socks-open-network-stream might be enough. Others, like ‘Libera.Chat’, involve additional setup. At the time of writing, connecting to that network requires both TLS and a permitted SASL mechanism, like ‘EXTERNAL’ (see Authenticating via SASL), as shown in the following example:

(require 'erc)
(require 'socks)

(defun my-erc-open-socks-tls-stream (&rest args)
  (let ((socks-username "")
        (socks-password "")
        (socks-server '("tor" "localhost" 9050 5)))
    (apply #'erc-open-socks-tls-stream args)))

(let* ((erc-modules (cons 'sasl erc-modules))
       (erc-sasl-mechanism 'external)
       (erc-server-connect-function #'my-erc-open-socks-tls-stream))
  (erc-tls
   :server "libera75jm6of4wxpxt4aynol3xjmbtxgfyjpu34ss4d7r7q2v5zrpyd.onion"
   :port 6697
   :nick "jrh"
   :user "jrandomhacker"
   :full-name "J. Random Hacker"
   :client-certificate (list "/home/jrh/key.pem" "/home/jrh/cert.pem")))

Here, the user-provided my-erc-open-socks-tls-stream ensures that the preferred values for socks-server and friends will be available when reconnecting. If you plan on using SOCKS with ERC exclusively, you can just set those options and variables globally and bind erc-server-connect-function to erc-open-socks-tls-stream instead.

Next: Options, Previous: Sample Configuration, Up: Advanced Usage   [Contents][Index]