fluent-plugin-filter-geoip 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/README.md +0 -1
- data/fluent-plugin-filter-geoip.gemspec +2 -2
- data/lib/fluent/plugin/filter_geoip.rb +156 -82
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a30045e9413e42e901dbdce8d3eebb43edf707b
|
4
|
+
data.tar.gz: 867bfffcd725b3fd8fbc6f356e05b74aab8e6a8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ce752e3778a7533b8bfa4a150816ff6a3e0bcbb11fa2adfdc0238c53a8769a9c8e4e262837248f12241612bd8b3cfe12b5990ef060029d7cd7215e2c67841d2
|
7
|
+
data.tar.gz: 3bdf326c5c0e095787ac499f7e95f42a4f04c03990a58ad82a62c9188a6c03bb528b9c21909caf2a26e81348864c365823681fb1b7ebf3bd3b7f5b09b4f3f6b0
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "fluent-plugin-filter-geoip"
|
7
|
-
spec.version = "0.2.
|
7
|
+
spec.version = "0.2.8"
|
8
8
|
spec.authors = ["Minoru Osuka"]
|
9
9
|
spec.email = ["minoru.osuka@gmail.com"]
|
10
10
|
|
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_runtime_dependency 'maxminddb', '~> 0.1.8'
|
24
24
|
|
25
25
|
spec.add_development_dependency 'bundler', '~> 1.11.2'
|
26
|
-
spec.add_development_dependency 'rake', '~> 10.
|
26
|
+
spec.add_development_dependency 'rake', '~> 10.5.0'
|
27
27
|
spec.add_development_dependency 'test-unit', '~> 3.1.5'
|
28
28
|
spec.add_development_dependency 'minitest', '~> 5.8.3'
|
29
29
|
end
|
@@ -115,102 +115,166 @@ module Fluent
|
|
115
115
|
if @continent then
|
116
116
|
continent_hash = {}
|
117
117
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
118
|
+
unless geoip.continent.code.nil? then
|
119
|
+
continent_hash['code'] = geoip.continent.code
|
120
|
+
end
|
121
|
+
unless geoip.continent.geoname_id.nil? then
|
122
|
+
continent_hash['geoname_id'] = geoip.continent.geoname_id
|
123
|
+
end
|
124
|
+
unless geoip.continent.iso_code.nil? then
|
125
|
+
continent_hash['iso_code'] = geoip.continent.iso_code
|
126
|
+
end
|
127
|
+
unless geoip.continent.name(@locale).nil? then
|
128
|
+
continent_hash['name'] = geoip.continent.name(@locale)
|
129
|
+
end
|
122
130
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
131
|
+
unless continent_hash.empty? then
|
132
|
+
if @flatten then
|
133
|
+
record.merge!(to_flatten(continent_hash, [@output_field, 'continent'], @field_delimiter))
|
134
|
+
else
|
135
|
+
record[[@output_field, 'continent'].join(@field_delimiter)] = continent_hash.to_json
|
136
|
+
end
|
127
137
|
end
|
128
138
|
end
|
129
139
|
|
130
140
|
if @country then
|
131
141
|
country_hash = {}
|
132
142
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
143
|
+
unless geoip.country.code.nil? then
|
144
|
+
country_hash['code'] = geoip.country.code
|
145
|
+
end
|
146
|
+
unless geoip.country.geoname_id.nil? then
|
147
|
+
country_hash['geoname_id'] = geoip.country.geoname_id
|
148
|
+
end
|
149
|
+
unless geoip.country.iso_code.nil? then
|
150
|
+
country_hash['iso_code'] = geoip.country.iso_code
|
151
|
+
end
|
152
|
+
unless geoip.country.name(@locale).nil? then
|
153
|
+
country_hash['name'] = geoip.country.name(@locale)
|
154
|
+
end
|
137
155
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
156
|
+
unless country_hash.empty? then
|
157
|
+
if @flatten then
|
158
|
+
record.merge!(to_flatten(country_hash, [@output_field, 'country'], @field_delimiter))
|
159
|
+
else
|
160
|
+
record[[@output_field, 'country'].join(@field_delimiter)] = country_hash.to_json
|
161
|
+
end
|
142
162
|
end
|
143
163
|
end
|
144
164
|
|
145
165
|
if @city then
|
146
166
|
city_hash = {}
|
147
167
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
168
|
+
unless geoip.city.code.nil? then
|
169
|
+
city_hash['code'] = geoip.city.code
|
170
|
+
end
|
171
|
+
unless geoip.city.geoname_id.nil? then
|
172
|
+
city_hash['geoname_id'] = geoip.city.geoname_id
|
173
|
+
end
|
174
|
+
unless geoip.city.iso_code.nil? then
|
175
|
+
city_hash['iso_code'] = geoip.city.iso_code
|
176
|
+
end
|
177
|
+
unless geoip.city.name(@locale).nil? then
|
178
|
+
city_hash['name'] = geoip.city.name(@locale)
|
179
|
+
end
|
152
180
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
181
|
+
unless city_hash.empty? then
|
182
|
+
if @flatten then
|
183
|
+
record.merge!(to_flatten(city_hash, [@output_field, 'city'], @field_delimiter))
|
184
|
+
else
|
185
|
+
record[[@output_field, 'city'].join(@field_delimiter)] = city_hash.to_json
|
186
|
+
end
|
157
187
|
end
|
158
188
|
end
|
159
189
|
|
160
190
|
if @location then
|
161
191
|
location_hash = {}
|
162
192
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
193
|
+
unless geoip.location.latitude.nil? then
|
194
|
+
location_hash['latitude'] = geoip.location.latitude
|
195
|
+
end
|
196
|
+
unless geoip.location.longitude.nil? then
|
197
|
+
location_hash['longitude'] = geoip.location.longitude
|
198
|
+
end
|
199
|
+
unless geoip.location.metro_code.nil? then
|
200
|
+
location_hash['metro_code'] = geoip.location.metro_code
|
201
|
+
end
|
202
|
+
unless geoip.location.time_zone.nil? then
|
203
|
+
location_hash['time_zone'] = geoip.location.time_zone
|
204
|
+
end
|
167
205
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
206
|
+
unless location_hash.empty? then
|
207
|
+
if @flatten then
|
208
|
+
record.merge!(to_flatten(location_hash, [@output_field, 'location'], @field_delimiter))
|
209
|
+
else
|
210
|
+
record[[@output_field, 'location'].join(@field_delimiter)] = location_hash.to_json
|
211
|
+
end
|
172
212
|
end
|
173
213
|
end
|
174
214
|
|
175
215
|
if @postal then
|
176
216
|
postal_hash = {}
|
177
217
|
|
178
|
-
|
218
|
+
unless geoip.postal.code.nil? then
|
219
|
+
postal_hash['code'] = geoip.postal.code
|
220
|
+
end
|
179
221
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
222
|
+
unless postal_hash.empty? then
|
223
|
+
if @flatten then
|
224
|
+
record.merge!(to_flatten(postal_hash, [@output_field, 'postal'], @field_delimiter))
|
225
|
+
else
|
226
|
+
record[[@output_field, 'postal'].join(@field_delimiter)] = postal_hash.to_json
|
227
|
+
end
|
184
228
|
end
|
185
229
|
end
|
186
230
|
|
187
231
|
if @registered_country then
|
188
232
|
registered_country_hash = {}
|
189
233
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
234
|
+
unless geoip.registered_country.code.nil? then
|
235
|
+
registered_country_hash['code'] = geoip.registered_country.code
|
236
|
+
end
|
237
|
+
unless geoip.registered_country.geoname_id.nil? then
|
238
|
+
registered_country_hash['geoname_id'] = geoip.registered_country.geoname_id
|
239
|
+
end
|
240
|
+
unless geoip.registered_country.iso_code.nil? then
|
241
|
+
registered_country_hash['iso_code'] = geoip.registered_country.iso_code
|
242
|
+
end
|
243
|
+
unless geoip.registered_country.name(@locale).nil? then
|
244
|
+
registered_country_hash['name'] = geoip.registered_country.name(@locale)
|
245
|
+
end
|
194
246
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
247
|
+
unless registered_country_hash.empty? then
|
248
|
+
if @flatten then
|
249
|
+
record.merge!(to_flatten(registered_country_hash, [@output_field, 'registered_country'], @field_delimiter))
|
250
|
+
else
|
251
|
+
record[[@output_field, 'registered_country'].join(@field_delimiter)] = registered_country_hash.to_json
|
252
|
+
end
|
199
253
|
end
|
200
254
|
end
|
201
255
|
|
202
256
|
if @represented_country then
|
203
257
|
represented_country_hash = {}
|
204
258
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
259
|
+
unless geoip.represented_country.code.nil? then
|
260
|
+
represented_country_hash['code'] = geoip.represented_country.code
|
261
|
+
end
|
262
|
+
unless geoip.represented_country.geoname_id.nil? then
|
263
|
+
represented_country_hash['geoname_id'] = geoip.represented_country.geoname_id
|
264
|
+
end
|
265
|
+
unless geoip.represented_country.iso_code.nil? then
|
266
|
+
represented_country_hash['iso_code'] = geoip.represented_country.iso_code
|
267
|
+
end
|
268
|
+
unless geoip.represented_country.name(@locale).nil? then
|
269
|
+
represented_country_hash['name'] = geoip.represented_country.name(@locale)
|
270
|
+
end
|
209
271
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
272
|
+
unless represented_country_hash.empty? then
|
273
|
+
if @flatten then
|
274
|
+
record.merge!(to_flatten(represented_country_hash, [@output_field, 'represented_country'], @field_delimiter))
|
275
|
+
else
|
276
|
+
record[[@output_field, 'represented_country'].join(@field_delimiter)] = represented_country_hash.to_json
|
277
|
+
end
|
214
278
|
end
|
215
279
|
end
|
216
280
|
|
@@ -221,42 +285,62 @@ module Fluent
|
|
221
285
|
geoip.subdivisions.each do |subdivision|
|
222
286
|
subdivision_hash = {}
|
223
287
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
288
|
+
unless subdivision.code.nil? then
|
289
|
+
subdivision_hash['code'] = subdivision.code
|
290
|
+
end
|
291
|
+
unless subdivision.geoname_id.nil? then
|
292
|
+
subdivision_hash['geoname_id'] = subdivision.geoname_id
|
293
|
+
end
|
294
|
+
unless subdivision.iso_code.nil? then
|
295
|
+
subdivision_hash['iso_code'] = subdivision.iso_code
|
296
|
+
end
|
297
|
+
unless subdivision.name(@locale).nil? then
|
298
|
+
subdivision_hash['name'] = subdivision.name(@locale)
|
299
|
+
end
|
228
300
|
|
229
|
-
|
301
|
+
unless subdivision_hash.empty? then
|
302
|
+
subdivision_arry.push(subdivision_hash)
|
303
|
+
end
|
230
304
|
|
231
305
|
i = i + 1
|
232
306
|
end
|
233
307
|
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
308
|
+
unless subdivision_arry.empty? then
|
309
|
+
if @flatten then
|
310
|
+
i = 0
|
311
|
+
subdivision_arry.each do |subdivision|
|
312
|
+
record.merge!(to_flatten(subdivision, [@output_field, 'subdivisions', i.to_s], @field_delimiter))
|
313
|
+
i = i + 1
|
314
|
+
end
|
315
|
+
else
|
316
|
+
record[[@output_field, 'subdivisions'].join(@field_delimiter)] = subdivision_arry.to_json
|
239
317
|
end
|
240
|
-
else
|
241
|
-
record[[@output_field, 'subdivisions'].join(@field_delimiter)] = subdivision_arry.to_json
|
242
318
|
end
|
243
319
|
end
|
244
320
|
|
245
321
|
if @traits then
|
246
322
|
traits_hash = {}
|
247
323
|
|
248
|
-
|
249
|
-
|
324
|
+
unless geoip.traits.is_anonymous_proxy.nil? then
|
325
|
+
traits_hash['is_anonymous_proxy'] = geoip.traits.is_anonymous_proxy
|
326
|
+
end
|
327
|
+
unless geoip.traits.is_satellite_provider.nil? then
|
328
|
+
traits_hash['is_satellite_provider'] = geoip.traits.is_satellite_provider
|
329
|
+
end
|
250
330
|
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
331
|
+
unless traits_hash.empty? then
|
332
|
+
if @flatten then
|
333
|
+
record.merge!(to_flatten(traits_hash, [@output_field, 'traits'], @field_delimiter))
|
334
|
+
else
|
335
|
+
record[[@output_field, 'traits'].join(@field_delimiter)] = traits_hash.to_json
|
336
|
+
end
|
255
337
|
end
|
256
338
|
end
|
257
339
|
|
258
340
|
if @connection_type then
|
259
|
-
|
341
|
+
unless geoip.connection_type.nil? then
|
342
|
+
record[[@output_field, 'connection_type'].join(@field_delimiter)] = geoip.connection_type
|
343
|
+
end
|
260
344
|
end
|
261
345
|
|
262
346
|
log.info "Record: %s" % record.inspect
|
@@ -286,16 +370,6 @@ module Fluent
|
|
286
370
|
return output
|
287
371
|
end
|
288
372
|
|
289
|
-
def to_boolean(string)
|
290
|
-
if string== true || string =~ (/(true|t|yes|y|1)$/i) then
|
291
|
-
return true
|
292
|
-
elsif string== false || string.nil? || string =~ (/(false|f|no|n|0)$/i)
|
293
|
-
return false
|
294
|
-
else
|
295
|
-
return false
|
296
|
-
end
|
297
|
-
end
|
298
|
-
|
299
373
|
def download_database(download_url, md5_url, database_path, md5_path)
|
300
374
|
# database directory
|
301
375
|
database_dir = File.dirname database_path
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-filter-geoip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Minoru Osuka
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01
|
11
|
+
date: 2016-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 10.
|
61
|
+
version: 10.5.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 10.
|
68
|
+
version: 10.5.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: test-unit
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|