branch: externals/crdt
commit df8954b9c378ac0d76564f61e9266ca66c4bce4d
Author: Jonathan Ming <[email protected]>
Commit: Qiantan Hong <[email protected]>
feat: Option to put tuntox password in copied URL
---
crdt.el | 56 ++++++++++++++++++++++++++++++++++++--------------------
1 file changed, 36 insertions(+), 20 deletions(-)
diff --git a/crdt.el b/crdt.el
index 001f517713..8838b16091 100644
--- a/crdt.el
+++ b/crdt.el
@@ -83,6 +83,13 @@
"Start tuntox proxy for CRDT servers."
:type '(choice boolean (const confirm)))
+(defcustom crdt-tuntox-password-in-url nil
+ "Whether or not to include the session password in the tuntox connection URL.
+Useful if you plan to share your session URL over a trusted secure channel.
Your
+password will be in plaintext in the URL, so take care when sharing URLs with
+this option enabled."
+ :type 'boolean)
+
;;; Pseudo cursor/region utils
(defvar crdt-cursor-region-colors
@@ -1887,15 +1894,18 @@ Setup up the server with PASSWORD and assign this Emacs
DISPLAY-NAME."
(when crdt-ask-for-password
(read-from-minibuffer "Set password (empty for no
authentication): "))))
(if tuntox-p
- (let ((proxy-process
- (make-process :name "Tuntox Proxy"
- :buffer (generate-new-buffer "*Tuntox Proxy*")
- :command
- `(,crdt-tuntox-executable
- "-C" ,(expand-file-name crdt-tuntox-key-path)
- "-f" "/dev/stdin" ; do the filtering for safety
sake
- ,@ (when (and password (> (length password) 0))
- `("-s" ,password))))))
+ (let* ((password-p (and password (> (length password) 0)))
+ (proxy-process
+ (make-process :name "Tuntox Proxy"
+ :buffer (generate-new-buffer "*Tuntox Proxy*")
+ :command
+ `(,crdt-tuntox-executable
+ "-C" ,(expand-file-name crdt-tuntox-key-path)
+ "-f" "/dev/stdin" ; do the filtering for
safety sake
+ ,@ (when password-p
+ `("-s" ,password))))))
+ (when password-p
+ (process-put proxy-process 'password password))
(process-put network-process 'tuntox-process proxy-process)
(process-send-string proxy-process (format "127.0.0.1:%s\n" port)) ;
only allow connection to our port
(process-send-eof proxy-process)
@@ -1958,16 +1968,20 @@ Currently this only work if a tuntox proxy is used."
(network-process (crdt--session-network-process session))
(tuntox-process (process-get network-process 'tuntox-process)))
(if tuntox-process
- (progn
- (kill-new (format "tuntox://%s:%s"
- (with-current-buffer (process-buffer
tuntox-process)
- (save-excursion
- (goto-char (point-min))
- (search-forward "Using Tox ID: ")
- (let ((start (point)))
- (end-of-line)
- (buffer-substring-no-properties start
(point)))))
- (process-contact network-process :service)))
+ (let ((url-base (format "tuntox://%s:%s"
+ (with-current-buffer (process-buffer
tuntox-process)
+ (save-excursion
+ (goto-char (point-min))
+ (search-forward "Using Tox ID: ")
+ (let ((start (point)))
+ (end-of-line)
+ (buffer-substring-no-properties start
(point)))))
+ (process-contact network-process :service))))
+ (kill-new (if (and crdt-tuntox-password-in-url (process-get
tuntox-process 'password))
+ (format "%s?pwd=%s"
+ url-base
+ (process-get tuntox-process 'password))
+ url-base))
(message "URL copied."))
(message "No known URL to copy, find out your public IP address
yourself!"))))
@@ -2036,7 +2050,9 @@ Join with DISPLAY-NAME."
(setq port (read-from-minibuffer (format "tuntox proxy port
(default %s): "
(1+ (url-portspec url)))
nil nil t nil (format "%s" (1+
(url-portspec url)))))
- (let ((password (read-passwd "tuntox password (empty for no
password): ")))
+ (let ((password (or (when (url-filename url)
+ (cadr (split-string (url-filename url)
"?pwd=")))
+ (read-passwd "tuntox password (empty for no
password): "))))
(switch-to-buffer-other-window
(process-buffer
(make-process