envoy-proxy 0.0.8 → 0.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/envoy/client/trunk.rb +7 -6
- data/lib/envoy/server/channel.rb +4 -1
- data/lib/envoy/server/trunk.rb +3 -2
- data/lib/envoy/server/web.rb +17 -7
- data/lib/envoy/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: 6d9b0f4972a7646dbf5c14d62a4dd6b22b38b916
|
4
|
+
data.tar.gz: d8d329bb6236ff90676eb4b3bd87049e76754d6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba994c1c737f4a6ec79b790bd899615e75a26da0322fe0189cb3ffeeaa46d0598617bfcab2f91df1cdd840ccd7fed06c17f89dddf63d9935260875def10a52ed
|
7
|
+
data.tar.gz: 906a1e74a93456b3c971b0c15bf398ad79b1213a01a8dd5066cd1d0f0adacdae94d6c4cd18ac52d7010faaf509200d4313d808e00906a51ee32c649263f366b0
|
data/lib/envoy/client/trunk.rb
CHANGED
@@ -43,7 +43,8 @@ module Envoy
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def receive_message message
|
46
|
-
|
46
|
+
t = Time.now.strftime("%F %T")
|
47
|
+
STDERR.puts t + " " + message.split("\n").join("\n#{t.gsub(/./, ' ')} ")
|
47
48
|
end
|
48
49
|
|
49
50
|
def receive_halt
|
@@ -51,10 +52,10 @@ module Envoy
|
|
51
52
|
end
|
52
53
|
|
53
54
|
def unbind
|
54
|
-
if @options[:reconnect]
|
55
|
-
STDERR.puts "
|
56
|
-
EM.add_timer
|
57
|
-
@options[:reconnect]
|
55
|
+
if r = @options[:reconnect]
|
56
|
+
STDERR.puts "Lost connection. Reconnecting in #{r[0]}s."
|
57
|
+
EM.add_timer r[0] do
|
58
|
+
@options[:reconnect] = [r[1], r[0] + r[1]]
|
58
59
|
Trunk.start @options
|
59
60
|
end
|
60
61
|
else
|
@@ -69,7 +70,7 @@ module Envoy
|
|
69
70
|
|
70
71
|
def ssl_handshake_completed
|
71
72
|
options[:did_connect] = true
|
72
|
-
options[:reconnect] = 1 if options[:hosts]
|
73
|
+
options[:reconnect] = [0, 1] if options[:hosts]
|
73
74
|
o = options.dup
|
74
75
|
o.delete(:local_host)
|
75
76
|
send_object :options, o
|
data/lib/envoy/server/channel.rb
CHANGED
data/lib/envoy/server/trunk.rb
CHANGED
@@ -46,11 +46,12 @@ module Envoy
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
hosts << SecureRandom.random_number(36 ** 4).to_s(36) if hosts.empty?
|
49
|
-
|
49
|
+
m = ["Local server on port #{options[:local_port]} is now publicly available via:"]
|
50
50
|
@hosts = hosts.each do |host|
|
51
51
|
Trunk.trunks[host] << self
|
52
|
-
|
52
|
+
m << "http://#{host}.#{$zone}/"
|
53
53
|
end
|
54
|
+
send_object :message, m.join("\n")
|
54
55
|
end
|
55
56
|
|
56
57
|
def unbind
|
data/lib/envoy/server/web.rb
CHANGED
@@ -8,6 +8,7 @@ module Envoy
|
|
8
8
|
|
9
9
|
def post_init
|
10
10
|
@header = ""
|
11
|
+
@connection = "close"
|
11
12
|
end
|
12
13
|
|
13
14
|
def unbind
|
@@ -15,17 +16,26 @@ module Envoy
|
|
15
16
|
end
|
16
17
|
|
17
18
|
def receive_line line
|
18
|
-
@
|
19
|
-
if line
|
20
|
-
|
21
|
-
|
22
|
-
host = host[0...-$zone.length]
|
23
|
-
host = host.split(".").last
|
24
|
-
trunk = Trunk.trunks[host].sample || raise("No trunk for #{host}.#{$zone}")
|
19
|
+
@first_line ||= line
|
20
|
+
if line == ""
|
21
|
+
trunk = Trunk.trunks[@host].sample || raise("No trunk for #{@host}.#{$zone}")
|
22
|
+
@header << "Connection: #{@connection}\r\n"
|
25
23
|
@channel = Channel.new(trunk, self, @header)
|
24
|
+
@channel.message "%s %s" % [Socket.unpack_sockaddr_in(get_peername)[1], @first_line]
|
26
25
|
set_text_mode
|
26
|
+
elsif line =~ /^connection:\s*upgrade$/i
|
27
|
+
@connection = "upgrade"
|
28
|
+
elsif line =~ /^keep-alive:/i
|
29
|
+
elsif line =~ /^host:\s*([^:]*)/i
|
30
|
+
@host = $1
|
31
|
+
@host = @host[0...-$zone.length]
|
32
|
+
@host = @host.split(".").last
|
33
|
+
raise "Request is not in #{$zone}" unless @host.end_with?($zone)
|
34
|
+
@header << line + "\r\n"
|
27
35
|
elsif @header.size > 4096
|
28
36
|
raise "Header's too long for my liking"
|
37
|
+
else
|
38
|
+
@header << line + "\r\n"
|
29
39
|
end
|
30
40
|
rescue RuntimeError => e
|
31
41
|
send_data "HTTP/1.0 500 Internal Server Error\r\n"
|
data/lib/envoy/version.rb
CHANGED