[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 77d6351d60 08/10: Default to TLS port when calling erc-tls from l
From: |
F. Jason Park |
Subject: |
master 77d6351d60 08/10: Default to TLS port when calling erc-tls from lisp |
Date: |
Thu, 17 Nov 2022 00:41:15 -0500 (EST) |
branch: master
commit 77d6351d60d3c741550d990fbf97184433b7b59a
Author: F. Jason Park <jp@neverwas.me>
Commit: F. Jason Park <jp@neverwas.me>
Default to TLS port when calling erc-tls from lisp
* lisp/erc/erc.el (erc-normalize-port): Add standard IANA port-name
mappings for 6667 and 6697.
(erc-open): Add note to doc string explaining that params `connect'
and `channel' are mutually exclusive.
(erc-tls): Call `erc-compute-port' with override.
(erc-compute-port): Call `erc-normalize-port' with result'.
* test/lisp/erc/erc-tests.el (erc-tls): Add simplistic test focusing
on default parameters. (Bug#56514.)
---
lisp/erc/erc.el | 17 +++++++++++++----
test/lisp/erc/erc-tests.el | 42 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+), 4 deletions(-)
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index badda3ab84..897357e16b 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -1542,6 +1542,11 @@ symbol, it may have these values:
* ircs -> 994
* ircd -> 6667
* ircd-dalnet -> 7000"
+ ;; These were updated somewhat in 2022 to reflect modern standards
+ ;; and practices. See also:
+ ;;
+ ;; https://datatracker.ietf.org/doc/html/rfc7194#section-1
+ ;; https://www.iana.org/assignments/service-names-port-numbers
(cond
((symbolp port)
(erc-normalize-port (symbol-name port)))
@@ -1554,8 +1559,10 @@ symbol, it may have these values:
194)
((string-equal port "ircs")
994)
- ((string-equal port "ircd")
+ ((string-equal port "ircu") 6667) ; 6665-6669
+ ((string-equal port "ircd") ; nonstandard (irc-serv is 529)
6667)
+ ((string-equal port "ircs-u") 6697)
((string-equal port "ircd-dalnet")
7000)
(t
@@ -1924,7 +1931,9 @@ removed from the list will be disabled."
If CONNECT is non-nil, connect to the server. Otherwise assume
already connected and just create a separate buffer for the new
-target CHANNEL.
+target given by CHANNEL, meaning these parameters are mutually
+exclusive. Note that CHANNEL may also be a query; its name has
+been retained for historical reasons.
Use PASSWD as user password on the server. If TGT-LIST is
non-nil, use it to initialize `erc-default-recipients'.
@@ -2183,7 +2192,7 @@ interactively."
;;;###autoload
(cl-defun erc-tls (&key (server (erc-compute-server))
- (port (erc-compute-port))
+ (port (erc-compute-port 'ircs-u))
(nick (erc-compute-nick))
(user (erc-compute-user))
password
@@ -6404,7 +6413,7 @@ non-nil value is found.
- PORT (the argument passed to this function)
- The `erc-port' option
- The `erc-default-port' variable"
- (or port erc-port erc-default-port))
+ (erc-normalize-port (or port erc-port erc-default-port)))
;; time routines
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el
index f72db816af..db54cb4889 100644
--- a/test/lisp/erc/erc-tests.el
+++ b/test/lisp/erc/erc-tests.el
@@ -1042,4 +1042,46 @@
:nick "nick"
:password nil)))))
+(ert-deftest erc-tls ()
+ (let (calls)
+ (cl-letf (((symbol-function 'user-login-name)
+ (lambda (&optional _) "tester"))
+ ((symbol-function 'erc-open)
+ (lambda (&rest r) (push r calls))))
+
+ (ert-info ("Defaults")
+ (erc-tls)
+ (should (equal (pop calls)
+ '("irc.libera.chat" 6697 "tester" "unknown" t
+ nil nil nil nil nil "user" nil))))
+
+ (ert-info ("Full")
+ (erc-tls :server "irc.gnu.org"
+ :port 7000
+ :user "bobo"
+ :nick "bob"
+ :full-name "Bob's Name"
+ :password "bob:changeme"
+ :client-certificate t
+ :id 'GNU.org)
+ (should (equal (pop calls)
+ '("irc.gnu.org" 7000 "bob" "Bob's Name" t
+ "bob:changeme" nil nil nil t "bobo" GNU.org))))
+
+ ;; Values are often nil when called by lisp code, which leads to
+ ;; null params. This is why `erc-open' recomputes almost
+ ;; everything.
+ (ert-info ("Fallback")
+ (let ((erc-nick "bob")
+ (erc-server "irc.gnu.org")
+ (erc-email-userid "bobo")
+ (erc-user-full-name "Bob's Name"))
+ (erc-tls :server nil
+ :port 7000
+ :nick nil
+ :password "bob:changeme"))
+ (should (equal (pop calls)
+ '(nil 7000 nil "Bob's Name" t
+ "bob:changeme" nil nil nil nil "bobo" nil)))))))
+
;;; erc-tests.el ends here
- master updated (0147e1ed83 -> ed5022b4ee), F. Jason Park, 2022/11/17
- master e7f2f6cd92 04/10: Improve auto-reconnect visibility in ERC, F. Jason Park, 2022/11/17
- master 4351fb7161 03/10: ; Make some ERC test fixtures a bit more courteous, F. Jason Park, 2022/11/17
- master c5d91358b5 02/10: Support auth-source-pass in ERC, F. Jason Park, 2022/11/17
- master d4028ead89 05/10: Warn of future breaking change to erc-response.tags, F. Jason Park, 2022/11/17
- master 535cc4c81a 09/10: Add optional server param to erc-networks--determine, F. Jason Park, 2022/11/17
- master ed5022b4ee 10/10: Improve new connections in erc-handle-irc-url, F. Jason Park, 2022/11/17
- master 5699e43f27 06/10: Accommodate ircs:// URLs in url-irc and browse-url, F. Jason Park, 2022/11/17
- master 2cf9e699ef 01/10: Make auth-source-pass behave more like other backends, F. Jason Park, 2022/11/17
- master 46c765ed09 07/10: Refactor erc-select-read-args, F. Jason Park, 2022/11/17
- master 77d6351d60 08/10: Default to TLS port when calling erc-tls from lisp,
F. Jason Park <=