localtunnel 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/localtunnel/client.rb +10 -10
- data/lib/localtunnel/version.rb +1 -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: 38f2d1bbde7fd341eff4cdc738d6dbefbbbf3587
|
4
|
+
data.tar.gz: 586aabaee94ae8fe0541bc165063beff1a690317
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e139a5442b7f386ffb44581b2bac1888464efcfb0520d58ad60e97c148602f3917575ee663337449fd4c2593b0d6c93e2c8219ad3e56977e11709a28aafae29
|
7
|
+
data.tar.gz: 4f1f9e3e3808fe22de86dd8845c22e2585a99c09df460fe71a0b65a2a2a6138eb2fac9b5d27eafb023ac4e109e5c46b7a71a58bebed950201f2a0eb0c58e0bf0
|
data/lib/localtunnel/client.rb
CHANGED
@@ -12,20 +12,18 @@ module Localtunnel
|
|
12
12
|
|
13
13
|
log = Tempfile.new("localtunnel")
|
14
14
|
@@pid = Process.spawn(execution_string(log, options))
|
15
|
-
@@url = parse_url!(log)
|
16
15
|
|
17
16
|
at_exit { stop } # Ensure process is killed if Ruby exits.
|
18
17
|
|
19
|
-
|
18
|
+
@@url = parse_url!(log)
|
20
19
|
end
|
21
20
|
|
22
21
|
def self.stop
|
23
22
|
return unless running?
|
24
23
|
|
25
24
|
`kill -9 #{@@pid} 1>/dev/null 2>&1` # Can't use Process.kill, since JRuby on Raspbian doesn't support it.
|
26
|
-
@@pid = nil
|
27
25
|
|
28
|
-
|
26
|
+
@@pid = nil
|
29
27
|
end
|
30
28
|
|
31
29
|
def self.running?
|
@@ -48,22 +46,24 @@ module Localtunnel
|
|
48
46
|
s << " -s '#{options[:subdomain]}'" if options.key?(:subdomain)
|
49
47
|
s << " -h '#{options[:remote_host]}'" if options.key?(:remote_host)
|
50
48
|
s << " -l '#{options[:local_host]}'" if options.key?(:local_host)
|
51
|
-
s << " > #{log.path}"
|
49
|
+
s << " > #{log.path} 2>&1"
|
52
50
|
end
|
53
51
|
|
54
52
|
def self.parse_url!(log, max_seconds = 10)
|
55
53
|
max_seconds.times do
|
56
54
|
sleep 1
|
57
|
-
raise ClientConnectionFailedError unless running?
|
58
|
-
|
59
55
|
log.rewind
|
60
|
-
|
61
|
-
|
56
|
+
log_data = log.read
|
57
|
+
|
58
|
+
if match_data = log_data.match(/^your url is: (.*)$/)
|
59
|
+
return match_data.captures.first
|
60
|
+
elsif log_data.match(/^Error: (.*)$/)
|
61
|
+
raise ClientConnectionFailedError
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
65
|
stop
|
66
|
-
raise ClientConnectionFailedError
|
66
|
+
raise ClientConnectionFailedError # Timeout.
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
data/lib/localtunnel/version.rb
CHANGED