stubby 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/stubby/extensions/http.rb +23 -24
- data/lib/stubby/extensions/smtp.rb +11 -7
- metadata +2 -2
@@ -41,7 +41,10 @@ module Extensions
|
|
41
41
|
set :static, false
|
42
42
|
|
43
43
|
adapter "http-redirect" do
|
44
|
-
|
44
|
+
r = URI.parse(instruction_params["to"])
|
45
|
+
r.path = request.path if r.path.blank?
|
46
|
+
|
47
|
+
redirect to(r.to_s)
|
45
48
|
end
|
46
49
|
|
47
50
|
adapter "file" do
|
@@ -68,14 +71,11 @@ module Extensions
|
|
68
71
|
end
|
69
72
|
|
70
73
|
adapter "http-proxy" do
|
71
|
-
|
72
|
-
run_proxy
|
73
|
-
|
74
|
+
run_proxy("http")
|
74
75
|
end
|
75
76
|
|
76
77
|
adapter "https-proxy" do
|
77
|
-
|
78
|
-
run_proxy
|
78
|
+
run_proxy("https")
|
79
79
|
end
|
80
80
|
|
81
81
|
%w(get post put patch delete options link unlink).each do |method|
|
@@ -95,23 +95,25 @@ module Extensions
|
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
-
def run_proxy
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
r = HTTPI::Request.new
|
104
|
-
r.url = out.to_s
|
105
|
-
else
|
106
|
-
# Proxy to the given path
|
107
|
-
r = HTTPI::Request.new
|
108
|
-
r.url = url.to_s
|
109
|
-
end
|
98
|
+
def run_proxy(scheme)
|
99
|
+
to = url.dup
|
100
|
+
to.scheme = scheme
|
101
|
+
to.path = request.path if to.path.empty?
|
102
|
+
to.query = request.query_string
|
110
103
|
|
104
|
+
puts "#{to.to_s} scheme: #{request.scheme}"
|
105
|
+
|
106
|
+
r = HTTPI::Request.new
|
107
|
+
r.url = to.to_s
|
108
|
+
|
109
|
+
r.headers["HOST"] = request.host
|
111
110
|
r.headers["STUBBY_ENV"] = settings.stubby_session.environment
|
112
111
|
r.headers["STUBBY_KEY"] = settings.stubby_session.key(instruction)
|
113
112
|
r.headers["STUBBY_USER"] = settings.stubby_session.user_key
|
114
|
-
|
113
|
+
r.headers["X_FORWARDED_PROTO"] = request.scheme
|
114
|
+
r.headers["X_FORWARDED_FOR"] = request.ip
|
115
|
+
r.headers.merge! Hash[(env.select { |k,v| v.is_a? String }.collect { |k,v| [k.gsub("HTTP_", ""), v] })]
|
116
|
+
r.headers["CONNECTION"] = "close"
|
115
117
|
request.body.rewind
|
116
118
|
r.body = request.body.read
|
117
119
|
|
@@ -120,6 +122,8 @@ module Extensions
|
|
120
122
|
response.headers.delete "connection"
|
121
123
|
|
122
124
|
status(response.code)
|
125
|
+
puts "response: #{response.headers}"
|
126
|
+
|
123
127
|
headers(response.headers)
|
124
128
|
body(response.body)
|
125
129
|
end
|
@@ -160,11 +164,6 @@ module Extensions
|
|
160
164
|
set :port, port
|
161
165
|
set :stubby_session, session
|
162
166
|
|
163
|
-
#super(session, {
|
164
|
-
# :SSLEnable => true,
|
165
|
-
# :SSLCertName => %w[CN localhost]
|
166
|
-
#})
|
167
|
-
|
168
167
|
Rack::Handler::Thin.run(self, {
|
169
168
|
:Host => STUBBY_MASTER,
|
170
169
|
:Port => 443
|
@@ -12,18 +12,22 @@ module Extensions
|
|
12
12
|
HTTPI.post("http://#{STUBBY_MASTER}:9000/stubs/transient/activate.json",
|
13
13
|
options: MultiJson.dump(smtp_stub), key: "_smtp")
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
while true
|
16
|
+
begin
|
17
|
+
MailCatcher.run! smtp_ip: STUBBY_MASTER,
|
18
|
+
smtp_port: 25,
|
19
|
+
http_ip: STUBBY_MASTER,
|
20
|
+
http_port: 9001,
|
21
|
+
daemon: false
|
22
|
+
rescue
|
23
|
+
puts $!
|
24
|
+
end
|
25
|
+
end
|
20
26
|
}
|
21
27
|
|
22
28
|
trap("INT", important: true){
|
23
29
|
stop!
|
24
30
|
}
|
25
|
-
|
26
|
-
sleep
|
27
31
|
end
|
28
32
|
|
29
33
|
def smtp_stub
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stubby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-03-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubydns
|