proxes 0.8.6 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +34 -19
- data/config.ru +1 -6
- data/deploy_docker.sh +5 -0
- data/lib/proxes/forwarder.rb +30 -31
- data/lib/proxes/services/es.rb +15 -1
- data/lib/proxes/version.rb +1 -1
- data/proxes.gemspec +4 -2
- metadata +46 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fb51bef1ecbc4b21795b35ab7e832650c7c59be31a53be6d785f3139787b4599
|
4
|
+
data.tar.gz: c0ad7a29e63e7527461857e5319c08e6f3f8f0f0bcdcba04c9b3a973778e7484
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7fdfb074cef3a2eb221b56b272cb1e480eb3578fa52c81d662c151bf7f6aea88b173c5ef620ad4ae4fd66c09629bc2a33dac6e68175d92fda157a638ebda28b
|
7
|
+
data.tar.gz: 99b16d1c4c585dc7260561bea22ee41fcd60cbf62556cdb5f9f23233b3c1bd5d57066cde3e234fa1cc4c37ebc1e9390474c51e36f3bdd18aa5350d137a39be95
|
data/.travis.yml
CHANGED
@@ -1,29 +1,44 @@
|
|
1
1
|
sudo: false
|
2
2
|
language: ruby
|
3
3
|
rvm:
|
4
|
-
- 2.5.0
|
5
|
-
- 2.4.3
|
6
|
-
- 2.3.6
|
7
|
-
- 2.2.9
|
4
|
+
- 2.5.0
|
5
|
+
- 2.4.3
|
6
|
+
- 2.3.6
|
7
|
+
- 2.2.9
|
8
8
|
gemfile: Gemfile.ci
|
9
9
|
env:
|
10
|
-
|
10
|
+
global:
|
11
|
+
- CC_TEST_REPORTER_ID=1f562305f75e169f5f5eca3b738fee879550c98e50099c2b9cd6ae71478007a0
|
12
|
+
- secure: wTIBP3ZtltfLyIFS6p4XgzPff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nWGoVSf+fidR7NIyJH7MGhr4VC8esGFGazzOXBnqVAX+z1tEse6n7llFcy0dREW0FNMpKMSP6TqN4LRiKXtRdSbeSvHXP3UiH6vPjAE/lHhf7qXSNOLkZDtCWrD0us4kT1ACeL2AV2SArJf7pmGdEL9pUyp4jSuStwxtRPhYJj2kuS6op9MYoU6Q8eyXhIw8Uju4SitGtkTnb8t5L50Xw7vUQT9faEah9ewJwB2kxa2RZxCdIzylwuYssCON4xkdXI1fY=
|
14
|
+
- secure: lUfjVwbIxUBQTGkDTOSMNvSYONBwI5yObn8fCByzGkfleddWPjLEeMPjGBZboOu2CVZ/q/FG3xbn63Hmss7CU83FmWRoV5dMP9Yc7X7cHaGmi31mZcaY2Yah+jgx7PcNIdK8LOAB3/zhxDNOcr8U4O9gqxGZWnV2NLR8SB+KiNTg5Hou3nOeVw7l1Iz+h1hXvZfxkMv7aX/3TLMT8j2JMkfgCN8moMlNRAYnvm/B68FPcVs6UFcaZIwg2mBnq3FrARo127jG1Ozms2SOPTqkPY9y8yoGyo3TYH2iQOKdRxCCECBnkSO8HYRYTL9CUoMk/D4ZTp7TGNRIKxjHtlt+9O1WtfmZB2aevZX5c7ChCZ0wNhQpzlsyPDz0GoIOkms5Bfv7nsvbloejr+vsRxe8YsNaVAVG+9RVZziKxGCWsxTopfnFMfFBK7KIoJ4N60ijhtBr3qcYQbSeoZWviwSd/GCjl9I2d2mTPVI0DsiFVt8lP92ZZitPJEhPRcxHdHu47Wu7oftndcVqzhhgdGnOxMchYKgzccR17VWlactGxffJP+ZIUkHaWCkxVR4etcrE753uaUX9x+M1fMoKKrwvycstX/YWLncgsYM1YensRUN7oW87wk216anlKfHubO2aVeDNnXn+wszK87M12o9gFu1khTBowqZpXsVDaUaa+oc=
|
15
|
+
matrix:
|
16
|
+
- DATABASE_URL="sqlite::memory:" ELASTICSEARCH_URL="http://localhost:9200" RACK_ENV=test
|
11
17
|
services:
|
12
|
-
- elasticsearch
|
18
|
+
- elasticsearch
|
19
|
+
before_install:
|
20
|
+
- gem install bundler -v 1.12.5
|
13
21
|
before_script:
|
14
|
-
-
|
15
|
-
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
22
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64
|
23
|
+
> ./cc-test-reporter
|
24
|
+
- chmod +x ./cc-test-reporter
|
25
|
+
- "./cc-test-reporter before-build"
|
26
|
+
- sleep 10
|
27
|
+
- bundle exec rake ditty:prep
|
28
|
+
after_script:
|
29
|
+
- "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
|
20
30
|
deploy:
|
21
|
-
provider: rubygems
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
31
|
+
- provider: rubygems
|
32
|
+
api_key:
|
33
|
+
secure: WDO/FSVmUxyz8U6LJyoEEA/Gorw90VbQ8Q4rAu9+L6Lru/PftaVUlcW3ZMATjASHcVX/1KjVJlZNilgMYrV0eayudkeNjWglBozw5FxnhJntgzZAH2Fo/aepF9NHSU29A4SGtl1W0kj8zez9prYn+qcdX/8ei9YMfnP8KkQCKEUeO3/jScHqSZlYZIFI7Ft+QQbJeUTlKc1sJRC5XHG9Oz4lFfSZY0XgZMd5IJsBmwNCGisqgKxBuDEG/9KWwhqops6K6XGPvuhxd8+DFFrDSrI3HR1NsP9RrQxwFc9TnIc+Rzu/FjSF44NJgaiFKKPdZ116w5ChnpY0B59tzOyh/aCwvAl2w7usIqNkhXey0eJ/MZm4S+7l1AoVlxYVujBBl/tRt8PeqlRqjJWAnr1mu/p74cS/jyXhZbHJpNvmv5M7YJzzFIYI12el4Wm05fPo2L605g0c7+pFCW3F+HPAp5qItrjlNx3HoMNNoGDQO+057g3OeVjOivV5Vxjp9IYwZmNCD35IaLFXk+umYD4Jw047rUSGoboc0i/5k6ZYHSBrvIivvRCZNAXSbGi1nLR/lv42Chu2wRCWzMjyPgQQ4I0xGlVwu8kfIQsvPVAM3szNczl9xY8S311eBJforo5prPr6wLaEile0KLmMOai+1n0sr+exy056Z7ttBjwIwoQ=
|
34
|
+
gem: proxes
|
35
|
+
on:
|
36
|
+
tags: true
|
37
|
+
repo: EagerELK/proxes
|
38
|
+
- provider: script
|
39
|
+
script: deploy_docker.sh
|
40
|
+
on:
|
41
|
+
tags: true
|
42
|
+
|
28
43
|
after_success:
|
29
44
|
- bundle exec codeclimate-test-reporter
|
data/config.ru
CHANGED
@@ -51,11 +51,6 @@ map '/_proxes' do
|
|
51
51
|
run Rack::URLMap.new Ditty::Components.routes
|
52
52
|
end
|
53
53
|
|
54
|
-
require 'sidekiq/web'
|
55
|
-
map '/_sidekiq' do
|
56
|
-
run Sidekiq::Web
|
57
|
-
end
|
58
|
-
|
59
54
|
map '/' do
|
60
55
|
# Proxy all Elasticsearch requests
|
61
56
|
require 'proxes/security'
|
@@ -66,5 +61,5 @@ map '/' do
|
|
66
61
|
use Rack::ContentLength
|
67
62
|
|
68
63
|
# Forward requests to ES
|
69
|
-
run ProxES::Forwarder.
|
64
|
+
run ProxES::Forwarder.instance
|
70
65
|
end
|
data/deploy_docker.sh
ADDED
data/lib/proxes/forwarder.rb
CHANGED
@@ -1,54 +1,53 @@
|
|
1
|
-
require '
|
1
|
+
require 'proxes/services/es'
|
2
|
+
require 'net/http/persistent'
|
3
|
+
require 'singleton'
|
2
4
|
require 'rack'
|
3
5
|
|
4
6
|
module ProxES
|
5
7
|
# A lot of code in this comes from Rack::Proxy
|
6
8
|
class Forwarder
|
7
|
-
|
9
|
+
include Singleton
|
10
|
+
include ProxES::Services::ES
|
8
11
|
|
9
|
-
|
10
|
-
|
12
|
+
attr_reader :streaming
|
13
|
+
|
14
|
+
def backend
|
15
|
+
@backend ||= URI(ENV['ELASTICSEARCH_URL'])
|
16
|
+
end
|
17
|
+
|
18
|
+
def backend=(var)
|
19
|
+
@backend = URI(var)
|
11
20
|
end
|
12
21
|
|
13
22
|
def call(env)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
store.set_default_paths
|
20
|
-
http.cert_store = store
|
21
|
-
end
|
23
|
+
forward(env)
|
24
|
+
rescue SocketError
|
25
|
+
headers = { 'Content-Type' => 'application/json' }
|
26
|
+
[500, headers, ['{"error":"Could not connect to Elasticsearch"}']]
|
27
|
+
end
|
22
28
|
|
23
|
-
|
24
|
-
|
25
|
-
|
29
|
+
def forward(env)
|
30
|
+
source = Rack::Request.new(env)
|
31
|
+
conn.basic_auth backend.user, backend.password
|
32
|
+
response = conn.send(source.request_method.downcase) do |req|
|
33
|
+
source_body = body_from(source)
|
34
|
+
req.body = source_body if source_body
|
35
|
+
req.url source.fullpath == '' ? URI.parse(env['REQUEST_URI']).request_uri : source.fullpath
|
36
|
+
end
|
37
|
+
mangle response
|
38
|
+
end
|
26
39
|
|
40
|
+
def mangle(response)
|
27
41
|
headers = (response.respond_to?(:headers) && response.headers) || self.class.normalize_headers(response.to_hash)
|
28
42
|
body = response.body || ['']
|
29
43
|
body = [body] unless body.respond_to?(:each)
|
30
44
|
|
31
45
|
# Not sure where this is coming from, but it causes timeouts on the client
|
32
46
|
headers.delete('transfer-encoding')
|
33
|
-
|
34
47
|
# Ensure that the content length rack middleware kicks in
|
35
48
|
headers.delete('content-length')
|
36
49
|
|
37
|
-
[response.
|
38
|
-
end
|
39
|
-
|
40
|
-
def request_from(env)
|
41
|
-
source = Rack::Request.new(env)
|
42
|
-
fullpath = source.fullpath == '' ? URI.parse(env['REQUEST_URI']).request_uri : source.fullpath
|
43
|
-
target = Net::HTTP.const_get(source.request_method.capitalize).new(fullpath)
|
44
|
-
|
45
|
-
body = body_from(source)
|
46
|
-
if body
|
47
|
-
target.body = body
|
48
|
-
target.content_length = body.length
|
49
|
-
target.content_type = source.content_type if source.content_type
|
50
|
-
end
|
51
|
-
target
|
50
|
+
[response.status, headers, body]
|
52
51
|
end
|
53
52
|
|
54
53
|
def body_from(request)
|
data/lib/proxes/services/es.rb
CHANGED
@@ -9,13 +9,27 @@ module ProxES
|
|
9
9
|
def client
|
10
10
|
@client ||= Elasticsearch::Client.new(
|
11
11
|
url: ENV['ELASTICSEARCH_URL'],
|
12
|
+
adapter: :net_http_persistent,
|
12
13
|
transport_options: {
|
13
|
-
ssl: {
|
14
|
+
ssl: {
|
15
|
+
verify: ENV['SSL_VERIFY_NONE'].to_i != 1,
|
16
|
+
cert_store: ssl_store
|
17
|
+
}
|
14
18
|
},
|
15
19
|
logger: Ditty::Services::Logger.instance
|
16
20
|
)
|
17
21
|
end
|
18
22
|
|
23
|
+
def ssl_store
|
24
|
+
store = OpenSSL::X509::Store.new
|
25
|
+
store.set_default_paths
|
26
|
+
store
|
27
|
+
end
|
28
|
+
|
29
|
+
def conn
|
30
|
+
client.transport.connections.first.connection
|
31
|
+
end
|
32
|
+
|
19
33
|
def cluster_health(level = 'cluster')
|
20
34
|
client.cluster.health level: level
|
21
35
|
end
|
data/lib/proxes/version.rb
CHANGED
data/proxes.gemspec
CHANGED
@@ -25,17 +25,19 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency 'racksh'
|
26
26
|
spec.add_development_dependency 'rack-test'
|
27
27
|
spec.add_development_dependency 'database_cleaner'
|
28
|
-
spec.add_development_dependency '
|
28
|
+
spec.add_development_dependency 'factory_bot'
|
29
29
|
spec.add_development_dependency 'timecop'
|
30
30
|
spec.add_development_dependency 'webmock'
|
31
31
|
|
32
|
-
spec.add_dependency 'ditty', '>= 0.2'
|
33
32
|
spec.add_dependency 'activesupport', '>= 3'
|
34
33
|
spec.add_dependency 'bcrypt', '~> 3.1'
|
34
|
+
spec.add_dependency 'ditty', '>= 0.2'
|
35
35
|
spec.add_dependency 'elasticsearch', '>= 2'
|
36
|
+
spec.add_dependency 'faraday'
|
36
37
|
spec.add_dependency 'haml', '~> 5.0'
|
37
38
|
spec.add_dependency 'highline', '~> 1.7'
|
38
39
|
spec.add_dependency 'logger', '~> 1.0'
|
40
|
+
spec.add_dependency 'net-http-persistent'
|
39
41
|
spec.add_dependency 'omniauth', '~> 1.0'
|
40
42
|
spec.add_dependency 'omniauth-http-basic', '~> 1.0'
|
41
43
|
spec.add_dependency 'omniauth-identity', '~> 1.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: proxes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jurgens du Toit
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: factory_bot
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
@@ -123,47 +123,47 @@ dependencies:
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
126
|
+
name: activesupport
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - ">="
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: '
|
131
|
+
version: '3'
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: '
|
138
|
+
version: '3'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
140
|
+
name: bcrypt
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- - "
|
143
|
+
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: '3'
|
145
|
+
version: '3.1'
|
146
146
|
type: :runtime
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- - "
|
150
|
+
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: '3'
|
152
|
+
version: '3.1'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
154
|
+
name: ditty
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- - "
|
157
|
+
- - ">="
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: '
|
159
|
+
version: '0.2'
|
160
160
|
type: :runtime
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- - "
|
164
|
+
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: '
|
166
|
+
version: '0.2'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: elasticsearch
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,6 +178,20 @@ dependencies:
|
|
178
178
|
- - ">="
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '2'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: faraday
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :runtime
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
181
195
|
- !ruby/object:Gem::Dependency
|
182
196
|
name: haml
|
183
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -220,6 +234,20 @@ dependencies:
|
|
220
234
|
- - "~>"
|
221
235
|
- !ruby/object:Gem::Version
|
222
236
|
version: '1.0'
|
237
|
+
- !ruby/object:Gem::Dependency
|
238
|
+
name: net-http-persistent
|
239
|
+
requirement: !ruby/object:Gem::Requirement
|
240
|
+
requirements:
|
241
|
+
- - ">="
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
version: '0'
|
244
|
+
type: :runtime
|
245
|
+
prerelease: false
|
246
|
+
version_requirements: !ruby/object:Gem::Requirement
|
247
|
+
requirements:
|
248
|
+
- - ">="
|
249
|
+
- !ruby/object:Gem::Version
|
250
|
+
version: '0'
|
223
251
|
- !ruby/object:Gem::Dependency
|
224
252
|
name: omniauth
|
225
253
|
requirement: !ruby/object:Gem::Requirement
|
@@ -419,6 +447,7 @@ files:
|
|
419
447
|
- config.ru
|
420
448
|
- config/logger.yml
|
421
449
|
- config/puma.rb
|
450
|
+
- deploy_docker.sh
|
422
451
|
- gulpfile.js
|
423
452
|
- lib/ditty/components/proxes.rb
|
424
453
|
- lib/proxes.rb
|
@@ -495,7 +524,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
495
524
|
version: '0'
|
496
525
|
requirements: []
|
497
526
|
rubyforge_project:
|
498
|
-
rubygems_version: 2.
|
527
|
+
rubygems_version: 2.7.4
|
499
528
|
signing_key:
|
500
529
|
specification_version: 4
|
501
530
|
summary: Rack wrapper around Elasticsearch to provide security and management features
|