summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtyom V. Poptsov <poptsov.artyom@gmail.com>2017-05-03 01:19:01 +0300
committerArtyom V. Poptsov <poptsov.artyom@gmail.com>2017-05-03 01:19:01 +0300
commitdf61952afef8bce48c79baf1cd3f33221dcc19a2 (patch)
tree7f3b4d6859c3a815bfc820a99764af777a04972d
parentnode.scm (rrepl-get-result): Fix code formatting (diff)
downloadguile-ssh-df61952afef8bce48c79baf1cd3f33221dcc19a2.tar.gz
tunnel.scm (main-loop/reverse) <tunnel-connect>: New procedure.
* modules/ssh/tunnel.scm (main-loop/reverse) <tunnel-connect>: New procedure. Use it to make a connection for a reverse tunnel.
-rw-r--r--modules/ssh/tunnel.scm12
1 files changed, 9 insertions, 3 deletions
diff --git a/modules/ssh/tunnel.scm b/modules/ssh/tunnel.scm
index 8693c46..d12ad12 100644
--- a/modules/ssh/tunnel.scm
+++ b/modules/ssh/tunnel.scm
@@ -212,6 +212,14 @@ when no data is available."
(define (main-loop/reverse tunnel idle-proc)
+
+ (define (tunnel-connect tunnel sock)
+ "Make a connection for a reverse TUNNEL. The return value is
+unspecified."
+ (connect sock AF_INET
+ (inet-aton (tunnel-host tunnel))
+ (tunnel-host-port tunnel)))
+
(let* ((timeout (tunnel-timeout tunnel))
(timeout-s (and timeout (quotient timeout 1000000)))
(timeout-us (and timeout (remainder timeout 1000000))))
@@ -220,9 +228,7 @@ when no data is available."
(channel-accept-forward (tunnel-session tunnel) 1000)
(and channel
(let* ((sock (socket PF_INET SOCK_STREAM 0)))
- (connect sock AF_INET
- (inet-aton (tunnel-host tunnel))
- (tunnel-host-port tunnel))
+ (tunnel-connect tunnel sock)
(while (channel-open? channel)
(cond-io
(channel -> sock => transfer)