summaryrefslogtreecommitdiff
path: root/nrepl-client.el
diff options
context:
space:
mode:
authorBozhidar Batsov <bozhidar@batsov.com>2017-01-19 15:47:14 +0700
committerBozhidar Batsov <bozhidar@batsov.com>2017-01-19 15:47:14 +0700
commit79f8cc632ca525a97015eadc77eabcb662be12d4 (patch)
tree9e1178cb656209ee87063212c80d86bc646265b3 /nrepl-client.el
parent858b81d603f17bf87c5bb670ff49090cae1e92de (diff)
[#1544] Don't fallback to SSH by default for remote hosts in case of a failed
direct connection This behavior was confusing for some users and couldn't be manually configured. Now the behavior is configurable via the new defcustom `nrepl-use-ssh-fallback-for-remote-hosts` and is disabled by default.
Diffstat (limited to 'nrepl-client.el')
-rw-r--r--nrepl-client.el22
1 files changed, 16 insertions, 6 deletions
diff --git a/nrepl-client.el b/nrepl-client.el
index 5d1212ef..9588aa41 100644
--- a/nrepl-client.el
+++ b/nrepl-client.el
@@ -115,6 +115,11 @@ The `nrepl-buffer-name-separator' separates cider-repl from the project name."
:type 'boolean
:group 'nrepl)
+(defcustom nrepl-use-ssh-fallback-for-remote-hosts nil
+ "If non-nil, attempt to connect via ssh to remote hosts when unable to connect directly."
+ :type 'boolean
+ :group 'nrepl)
+
(defcustom nrepl-sync-request-timeout 10
"The number of seconds to wait for a sync response.
Setting this to nil disables the timeout functionality."
@@ -513,17 +518,22 @@ and kill the process buffer."
For local hosts use a direct connection. For remote hosts, if
`nrepl-force-ssh-for-remote-hosts' is nil, attempt a direct connection
first. If `nrepl-force-ssh-for-remote-hosts' is non-nil or the direct
-connection failed, try to start a SSH tunneled connection. Return a plist
-of the form (:proc PROC :host \"HOST\" :port PORT) that might contain
-additional key-values depending on the connection type."
+connection failed (and `nrepl-use-ssh-fallback-for-remote-hosts' is
+non-nil), try to start a SSH tunneled connection. Return a plist of the
+form (:proc PROC :host \"HOST\" :port PORT) that might contain additional
+key-values depending on the connection type."
(let ((localp (if host
(nrepl-local-host-p host)
(not (file-remote-p default-directory)))))
(if localp
(nrepl--direct-connect (or host "localhost") port)
- (or (and host (not nrepl-force-ssh-for-remote-hosts)
- (nrepl--direct-connect host port 'no-error))
- (nrepl--ssh-tunnel-connect host port)))))
+ ;; we're dealing with a remote host
+ (if (and host (not nrepl-force-ssh-for-remote-hosts))
+ (nrepl--direct-connect host port 'no-error)
+ ;; direct connection failed or `nrepl-force-ssh-for-remote-hosts' is non-nil
+ (when (or nrepl-use-ssh-fallback-for-remote-hosts
+ nrepl-force-ssh-for-remote-hosts)
+ (nrepl--ssh-tunnel-connect host port))))))
(defun nrepl--direct-connect (host port &optional no-error)
"If HOST and PORT are given, try to `open-network-stream'.