From 49afccd179d2e7ee0e1cf0f0d5453ebbbb3c920d Mon Sep 17 00:00:00 2001 From: "Mark A. Hershberger" Date: Mon, 13 Jul 2015 13:00:10 -0400 Subject: [PATCH] Make ssh-tunnel a bit more generic * Use :name for host (instead of localhost) if :host isn't provided * Use user-login-name@host for login if it isn't provided * Derive the remote login from :name and user-login-name if no :login * Don't use "-S" since it can cause ssh-tunnel to fail. --- ssh-tunnels.el | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/ssh-tunnels.el b/ssh-tunnels.el index df4c1a1..87ce774 100644 --- a/ssh-tunnels.el +++ b/ssh-tunnels.el @@ -246,17 +246,23 @@ become irrelevant if `ssh-tunnels-configurations' changes.") (ssh-tunnels-run arg)) (defun ssh-tunnels--property (tunnel key) - (cond ((eq key :host) - (or (cl-getf tunnel :host) "localhost")) - ((eq key :local-port) - (or (gethash (cl-getf tunnel :name) ssh-tunnels--state-table) - (cl-getf tunnel :local-port) - (cl-getf tunnel :remote-port))) - ((eq key :remote-port) - (or (cl-getf tunnel :remote-port) - (cl-getf tunnel :local-port))) - (t - (cl-getf tunnel key)))) + (let* ((host (or (cl-getf tunnel :host) (cl-getf tunnel :name))) + (login (or (cl-getf tunnel :login) (concat user-login-name "@" host))) + (local-port (or (gethash (cl-getf tunnel :name) ssh-tunnels--state-table) + (cl-getf tunnel :local-port) + (cl-getf tunnel :remote-port))) + (remote-port (or (cl-getf tunnel :remote-port) + (cl-getf tunnel :local-port)))) + (cond ((eq key :host) + host) + ((eq key :login) + login) + ((eq key :local-port) + local-port) + ((eq key :remote-port) + remote-port) + (t + (cl-getf tunnel key))))) (defun ssh-tunnels--command (tunnel command) (let* ((name (ssh-tunnels--property tunnel :name)) @@ -273,7 +279,6 @@ become irrelevant if `ssh-tunnels-configurations' changes.") (list "-O" "check")) (t (error "Unknown ssh-tunnels command '%s'" command))))) (apply 'call-process ssh-tunnels-program nil nil nil - "-S" (shell-quote-argument name) (append args (list login)))))