diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 3bd9ff3..151482c 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -809,6 +809,27 @@ If nil, ERC will call `system-name' to get this information." :type '(choice (const :tag "Default system name" nil) string)) +(defcustom erc-ssl-servers nil + "Alist of networks to which ERC will connect to using SSL. +(ADDRESS PORT) where ADDRESS is the address of the IRC network +and PORT is the port on which the network accepts SSL connections." + :group 'erc + :type '(repeat + (list :tag "Network" + (string :tag "Network address") + (integer :tag "SSL Port")))) + +(defcustom erc-use-ssl nil + "If non-nil, all connections made by ERC will use SSL." + :group 'erc + :type 'boolean) + +(defcustom erc-ssl-blacklist nil + "List of server ERC will connect to without SSL. +Only useful when `erc-use-ssl' is non-nil" + :group 'erc + :type '(repeat (list string))) + (defcustom erc-ignore-list nil "List of regexps matching user identifiers to ignore. @@ -2094,18 +2115,23 @@ functions in here get called with the parameters SERVER and NICK." ;;;###autoload (defun erc-select-read-args () "Prompt the user for values of nick, server, port, and password." - (let (user-input server port nick passwd) + (let (user-input server port nick passwd ssl-port) (setq user-input (read-from-minibuffer "IRC server: " (erc-compute-server) nil nil 'erc-server-history-list)) + (setq ssl-port (if (not (assoc-string user-input erc-ssl-blacklist t)) + (nth 1 (assoc-string user-input erc-ssl-servers t)) + nil)) (if (string-match "\\(.*\\):\\(.*\\)\\'" user-input) (setq port (erc-string-to-port (match-string 2 user-input)) user-input (match-string 1 user-input)) (setq port (erc-string-to-port (read-from-minibuffer - "IRC port: " (erc-port-to-string - (erc-compute-port)))))) + "IRC port: " (if ssl-port + (number-to-string ssl-port) + (erc-port-to-string + (erc-compute-port))))))) (if (string-match "\\`\\(.*\\)@\\(.*\\)" user-input) (setq nick (match-string 1 user-input) @@ -2145,7 +2171,7 @@ functions in here get called with the parameters SERVER and NICK." ;;;###autoload (cl-defun erc (&key (server (erc-compute-server)) - (port (erc-compute-port)) + (port nil) (nick (erc-compute-nick)) password (full-name (erc-compute-full-name))) @@ -2156,7 +2182,7 @@ It permits you to select connection parameters, and then starts ERC. Non-interactively, it takes the keyword arguments (server (erc-compute-server)) - (port (erc-compute-port)) + (port nil) (nick (erc-compute-nick)) password (full-name (erc-compute-full-name))) @@ -2166,10 +2192,23 @@ That is, if called with (erc :server \"irc.freenode.net\" :full-name \"Harry S Truman\") then the server and full-name will be set to those values, whereas -`erc-compute-port', `erc-compute-nick' and `erc-compute-full-name' will -be invoked for the values of the other parameters." + `erc-compute-nick' and `erc-compute-full-name' will be invoked + for the values of the other parameters. If the server address is found in + `erc-ssl-servers', the port corresponding to the server will be used, or + `erc-compute-port' will be invoked for its value." (interactive (erc-select-read-args)) - (erc-open server port nick full-name t password)) + (let* ((use-ssl (equal nil (assoc-string server erc-ssl-blacklist t))) + (erc-server-connect-function + (if (or (and erc-use-ssl use-ssl) + (assoc-string server erc-ssl-servers t)) + 'erc-open-tls-stream + 'open-network-stream)) + (ssl-port (nth 1 (assoc-string server erc-ssl-servers t)))) + + (if (and (numberp port) (numberp ssl-port) use-ssl) + (setq port ssl-port) + (setq port (erc-compute-port))) + (erc-open server port nick full-name t password))) ;;;###autoload (defalias 'erc-select 'erc)