ec2-api-proxy 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -1
- data/bin/eapctl +20 -5
- data/bin/ec2-api-proxy +2 -0
- data/lib/ec2-api-proxy/constants.rb +1 -1
- data/lib/ec2-api-proxy/proxy.rb +7 -1
- data/lib/ec2-api-proxy/server.rb +2 -2
- metadata +1 -1
data/README
CHANGED
@@ -31,7 +31,7 @@ gem install ec2-api-proxy
|
|
31
31
|
expires: 60
|
32
32
|
compress: false
|
33
33
|
debug: false
|
34
|
-
shell> eapctl
|
34
|
+
shell> eapctl debug true
|
35
35
|
|
36
36
|
shell> export HTTP_PROXY=localhost:8080
|
37
37
|
shell> aws ec2 describe-instances --endpoint-url=http://ec2.ap-northeast-1.amazonaws.com # It does not support HTTPS still
|
data/bin/eapctl
CHANGED
@@ -11,14 +11,29 @@ COMMAND_NAME = File.basename(__FILE__)
|
|
11
11
|
COMMANDS = {
|
12
12
|
'status' => lambda {|server_options|
|
13
13
|
h = {}
|
14
|
-
server_options.to_hash.each {|k, v| h[k.to_s] = v }
|
14
|
+
server_options.to_hash.each {|k, v| h[k.to_s.gsub('_', '-')] = v }
|
15
15
|
puts YAML.dump(h)
|
16
16
|
},
|
17
|
-
'
|
18
|
-
|
17
|
+
'expires' => lambda {|server_options, v|
|
18
|
+
if v
|
19
|
+
server_options[:expires] = v.to_i
|
20
|
+
else
|
21
|
+
puts server_options.to_hash[:expires]
|
22
|
+
end
|
19
23
|
},
|
20
|
-
'
|
21
|
-
|
24
|
+
'use-https' => lambda {|server_options, v|
|
25
|
+
if v
|
26
|
+
server_options[:use_https] = !!(/#{Regexp.escape(v)}/i =~ 'true')
|
27
|
+
else
|
28
|
+
puts server_options.to_hash[:use_https]
|
29
|
+
end
|
30
|
+
},
|
31
|
+
'debug' => lambda {|server_options, v|
|
32
|
+
if v
|
33
|
+
server_options[:debug] = !!(/#{Regexp.escape(v)}/i =~ 'true')
|
34
|
+
else
|
35
|
+
puts server_options.to_hash[:debug]
|
36
|
+
end
|
22
37
|
},
|
23
38
|
}
|
24
39
|
|
data/bin/ec2-api-proxy
CHANGED
@@ -18,6 +18,7 @@ ARGV.options do |parser|
|
|
18
18
|
:compress => false,
|
19
19
|
:working_dir => '/var',
|
20
20
|
:socket => "/var/tmp/#{APP_NAME}.sock",
|
21
|
+
:use_https => false,
|
21
22
|
:debug => false,
|
22
23
|
}
|
23
24
|
|
@@ -29,6 +30,7 @@ ARGV.options do |parser|
|
|
29
30
|
parser.on('-n', '--threads=SIZE' ) {|v| options[:threads] = v.to_i }
|
30
31
|
parser.on('-W', '--working-dir=DIR' ) {|v| options[:working_dir] = v }
|
31
32
|
parser.on('-S', '--socket=SOCK_FILE' ) {|v| options[:socket] = v }
|
33
|
+
parser.on('', '--use-https' ) { options[:use_https] = true }
|
32
34
|
parser.on('', '--debug' ) { options[:debug] = true }
|
33
35
|
|
34
36
|
help_and_exit = lambda do |v|
|
@@ -1,2 +1,2 @@
|
|
1
1
|
APP_NAME = 'ec2-api-proxy'
|
2
|
-
Version = '0.1.
|
2
|
+
Version = '0.1.2'
|
data/lib/ec2-api-proxy/proxy.rb
CHANGED
@@ -52,7 +52,13 @@ module EC2APIProxy
|
|
52
52
|
close_connection_after_writing
|
53
53
|
else
|
54
54
|
@logger.debug("proxy: cache miss") if @options[:debug]
|
55
|
-
@backend = EM.connect(
|
55
|
+
@backend = EM.connect(
|
56
|
+
endpoint.host,
|
57
|
+
@options[:use_https] ? 443 : endpoint.port,
|
58
|
+
EC2APIProxy::Backend,
|
59
|
+
self,
|
60
|
+
allow_cache ? key : nil
|
61
|
+
)
|
56
62
|
|
57
63
|
if @backend.error?
|
58
64
|
@logger.error("proxy: backend connection error: #{data.inspect}")
|
data/lib/ec2-api-proxy/server.rb
CHANGED
@@ -25,6 +25,7 @@ module EC2APIProxy
|
|
25
25
|
:memcached => @@options[:memcached],
|
26
26
|
:expires => @@options[:expires],
|
27
27
|
:compress => @@options[:compress],
|
28
|
+
:use_https => @@options[:use_https],
|
28
29
|
:debug => @@options[:debug],
|
29
30
|
}
|
30
31
|
|
@@ -38,8 +39,7 @@ module EC2APIProxy
|
|
38
39
|
EM.threadpool_size = @@options[:threads] if @@options[:threads]
|
39
40
|
|
40
41
|
EM.run {
|
41
|
-
EM.start_server(@@options[:addr], @@options[:port], EC2APIProxy::Proxy,
|
42
|
-
@@control_options)
|
42
|
+
EM.start_server(@@options[:addr], @@options[:port], EC2APIProxy::Proxy, @@control_options)
|
43
43
|
}
|
44
44
|
end
|
45
45
|
end # self
|