easy-serve 0.8 → 0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/easy-serve.rb +1 -1
- data/lib/easy-serve/accessible-services.rb +25 -8
- data/lib/easy-serve/service.rb +20 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d1ef7c230f25e932ca33c4acbf8836789aeba20
|
4
|
+
data.tar.gz: 6003abf5645a32b1aadee49e711fbed4cfe8a8f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0618e996740b75fefef23d2fda92fc2f39a1e13d8e6d66d6d18c61f613c44aefd7419e49587b909bbc2c1aa86e9e605588c4f4f59d6b1311dfe18a87da77c448
|
7
|
+
data.tar.gz: 579718d353ad19562bb10a0dfdd0e9574476eeba4116844328a04e53ee0b13bf454cafa94a8194419a29eab912342e42297b2c778edf3c542cc623f0fbfcf2df
|
data/lib/easy-serve.rb
CHANGED
@@ -16,17 +16,34 @@ class EasyServe
|
|
16
16
|
end
|
17
17
|
|
18
18
|
fwd = "0:#{service_host}:#{service.port}"
|
19
|
-
|
19
|
+
remote_port = nil
|
20
|
+
tries = 10
|
21
|
+
1.times do
|
22
|
+
out = `ssh -O forward -R #{fwd} #{host}`
|
23
|
+
begin
|
24
|
+
remote_port = Integer(out)
|
25
|
+
rescue
|
26
|
+
log.error "Unable to set up dynamic ssh port forwarding. " +
|
27
|
+
"Please check if ssh -v is at least 6.0."
|
28
|
+
raise
|
29
|
+
end
|
20
30
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
31
|
+
if remote_port == 0
|
32
|
+
log.warn "race condition in ssh selection of remote_port"
|
33
|
+
tries -= 1
|
34
|
+
if tries > 0
|
35
|
+
sleep 0.1
|
36
|
+
log.info "retrying ssh selection of remote_port"
|
37
|
+
redo
|
38
|
+
end
|
39
|
+
raise "ssh did not assign remote_port"
|
40
|
+
end
|
27
41
|
end
|
28
42
|
|
29
|
-
|
43
|
+
# This breaks with multiple forward requests, and it would be too hard
|
44
|
+
# to coordinate among all requesting processes, so let's leave the
|
45
|
+
# forwarding open:
|
46
|
+
#at_exit {system "ssh -O cancel -R #{fwd} #{host}"}
|
30
47
|
|
31
48
|
TCPService.new service.name, connect_host: "localhost", port: remote_port
|
32
49
|
end
|
data/lib/easy-serve/service.rb
CHANGED
@@ -2,7 +2,26 @@ class EasyServe
|
|
2
2
|
# Refers to a named service. Use the #serve method to start the service.
|
3
3
|
# Encapsulates current location and identity, including pid and address. A
|
4
4
|
# Service object can be serialized to a remote process so it can #connect to
|
5
|
-
# the service.
|
5
|
+
# the service.
|
6
|
+
#
|
7
|
+
# The scheme for referencing hosts is as follows:
|
8
|
+
#
|
9
|
+
# bind host | connect host
|
10
|
+
# +------------------------------------------------------
|
11
|
+
# | local remote TCP SSH tunnel
|
12
|
+
# -----------+------------------------------------------------------
|
13
|
+
#
|
14
|
+
# localhost 'localhost' X 'localhost'
|
15
|
+
#
|
16
|
+
# 0.0.0.0 'localhost' hostname(*) 'localhost'
|
17
|
+
#
|
18
|
+
# hostname hostname hostname 'localhost'(**)
|
19
|
+
#
|
20
|
+
# * use hostname as best guess, can override; append ".local" if
|
21
|
+
# hostname not qualified
|
22
|
+
#
|
23
|
+
# ** forwarding set up to hostname[.local] instead of localhost
|
24
|
+
#
|
6
25
|
class Service
|
7
26
|
attr_reader :name
|
8
27
|
attr_reader :pid
|