emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/crdt 1f1e309cd7 41/44: Merge branch 'tuntox-password-in


From: ELPA Syncer
Subject: [elpa] externals/crdt 1f1e309cd7 41/44: Merge branch 'tuntox-password-in-url' into 'master'
Date: Sat, 2 Jul 2022 22:57:35 -0400 (EDT)

branch: externals/crdt
commit 1f1e309cd7b67f1eaba6954395d19fbdfbed29e5
Merge: 81b55a27b8 df8954b9c3
Author: Qiantan Hong <qhong@alum.mit.edu>
Commit: Qiantan Hong <qhong@alum.mit.edu>

    Merge branch 'tuntox-password-in-url' into 'master'
    
    feat: Option to put tuntox password in copied URL
    
    See merge request qhong/crdt.el!2
---
 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]