Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions ssh-tunnels.el
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)))))

Expand Down