From: Tim Vaughan Date: Tue, 29 Jun 2021 13:53:57 +0000 (+0200) Subject: Allowed forcing of ipv4. X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=commitdiff_plain;h=ecc4dd4e33a620a6d365b1b433d92d66642ecf84;p=lurk.git Allowed forcing of ipv4. --- diff --git a/lirc.el b/lirc.el index 4a9054a..ad1a8fa 100644 --- a/lirc.el +++ b/lirc.el @@ -51,6 +51,9 @@ ("local" "localhost" 6697)) "IRC networks.") +(defcustom lirc-allow-ipv6 nil + "Set to non-nil to allow use of IPv6.") + ;;; Faces ;; @@ -120,25 +123,35 @@ (lirc-display-error "Disconnected from server.") (clrhash lirc-contexts) (setq lirc-current-context nil) - (lirc-render-prompt))) - + (lirc-render-prompt) + (cancel-timer lirc-ping-timer))) (defun lirc-start-process (network) (let* ((row (assoc network lirc-networks)) (host (elt row 1)) - (port (elt row 2))) + (port (elt row 2)) + (flags (seq-drop row 3))) (make-network-process :name "lirc" :host host :service port + :family (if lirc-allow-ipv6 nil 'ipv4) :filter #'lirc-filter :sentinel #'lirc-sentinel :nowait nil - :tls-parameters (cons 'gnutls-x509pki - (gnutls-boot-parameters - :type 'gnutls-x509pki - :hostname host)) + :tls-parameters (if (memq :notls flags) + nil + (cons 'gnutls-x509pki + (gnutls-boot-parameters + :type 'gnutls-x509pki + :hostname host))) :buffer "*lirc*"))) +(defvar lirc-ping-timer nil) +(defvar lirc-ping-period 60) + +(defun lirc-ping-function () + (lirc-send-msg (lirc-msg nil nil "PING" (car (process-contact (get-process "lirc"))))) + (setq lirc-ping-timer (run-with-timer lirc-ping-period nil #'lirc-ping-function))) (defun lirc-connect (network) (if (get-process "lirc") @@ -149,7 +162,9 @@ (setq lirc-current-context nil) (lirc-start-process network) (lirc-send-msg (lirc-msg nil nil "USER" lirc-user-name 0 "*" lirc-full-name)) - (lirc-send-msg (lirc-msg nil nil "NICK" lirc-nick))))) + (lirc-send-msg (lirc-msg nil nil "NICK" lirc-nick)) + (setq lirc-ping-timer (run-with-timer lirc-ping-period nil #'lirc-ping-function))))) + (defun lirc-send-msg (msg) (let ((proc (get-process "lirc"))) @@ -434,7 +449,7 @@ portion of the source component of the message, as LIRC doesn't use this.") ("366" ; ENDOFNAMES (lirc-display-notice - (lirc-as-string (length (lirc-get-context-users lirc-current-context))) + (lirc--as-string (length (lirc-get-context-users lirc-current-context))) " users in " lirc-current-context)) ((rx (= 3 (any digit)))