logstash-filter-handsetdetection 4.1.2 → 4.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8e2ff25a181df3eebd5b198b76c9ce6f07e28bb0
4
- data.tar.gz: 2891e457eb34311f425f068f205460b23dbb639d
3
+ metadata.gz: 24c67374749607214c60d923de19be1130a0cfa6
4
+ data.tar.gz: 580f87ef49a41de07e47a304ba44580e870d607c
5
5
  SHA512:
6
- metadata.gz: 3d4210f7e6658050e27411b7f2734a9f954b330b584f56b383abe6850177ad9ea77dce11ec30a9bd4c1979594f6b6a6f35453f7e69305307ac69dc40ccf7d7a6
7
- data.tar.gz: 08bd8d856ff0e62830adaba4da21652ed5a1bd3550b408b60c67e50b420b173cfd7ecce7e268b5f3546598f2cdd04faf4a68a2e0e2af1c82a6110cdf72db5799
6
+ metadata.gz: 47b3c2575b70403e03dd83766d77b5965bce7eea9efafcb356015c96018a02c5b0f2447a0b50209899887afbe25f2bb05fccd9b1018dfed0748b5012e1f2bc4d
7
+ data.tar.gz: 0844e175a6b48d6e6c13672a58f3abc5f704c9f5ec9ec2ac6c9b66c53b1ffb746d062f2ae3d9423fcba64627c1f5f93ba656e52178a23bb9a952959ac81899bb
@@ -27,6 +27,8 @@
27
27
  require 'logstash/filters/base'
28
28
  require 'logstash/namespace'
29
29
  require 'handset_detection'
30
+ require 'thread_safe'
31
+
30
32
 
31
33
  class LogStash::Filters::HandsetDetection < LogStash::Filters::Base
32
34
 
@@ -44,6 +46,7 @@ class LogStash::Filters::HandsetDetection < LogStash::Filters::Base
44
46
  config :proxy_port, :validate => :number, :default => 3128
45
47
  config :proxy_user, :validate => :string, :default => ''
46
48
  config :proxy_pass, :validate => :string, :default => ''
49
+ config :log_unknown, :validate => :boolean, :default => true
47
50
  config :local_archive_source, :validate => :string, :default => nil
48
51
 
49
52
  public
@@ -66,10 +69,10 @@ class LogStash::Filters::HandsetDetection < LogStash::Filters::Base
66
69
  @hd_config['proxy_user'] = @proxy_user
67
70
  @hd_config['proxy_pass'] = @proxy_pass
68
71
  @hd_config['retries'] = 3
69
- @hd_config['log_unknown'] = true
72
+ @hd_config['log_unknown'] = @log_unknown
70
73
  @hd_config['local_archive_source'] = @local_archive_source
71
74
 
72
- @@pool = []
75
+ @@pool = ThreadSafe::Array.new
73
76
  unless @online_api
74
77
  hd = HD4.new @hd_config
75
78
  hd.set_timeout 500
@@ -87,25 +90,34 @@ class LogStash::Filters::HandsetDetection < LogStash::Filters::Base
87
90
  data[dest] = event.get src
88
91
  end
89
92
  end
90
- hd = @@pool.pop
91
- hd = HD4.new @hd_config if hd.nil?
92
- hd.device_detect data
93
- r = hd.get_reply
94
- @@pool << hd
95
- if r.key? 'class'
96
- event.set 'handset_class', r['class']
97
- end
98
- if r.key? 'hd_specs'
99
- if @filter.empty?
100
- event.set 'handset_specs', r['hd_specs']
101
- else
102
- event.set 'handset_specs', {}
103
- @filter.each do |f|
104
- if r['hd_specs'].key? f
105
- event.set "[handset_specs][#{f}]", r['hd_specs'][f]
106
- end
107
- end
93
+ event.set 'handset_detection', {}
94
+ unless data.empty?
95
+ hd = @@pool.pop
96
+ hd = HD4.new @hd_config if hd.nil?
97
+ hd.device_detect data
98
+ r = hd.get_reply
99
+ @@pool << hd
100
+ if r.key? 'status'
101
+ event.set '[handset_detection][status]', r['status']
108
102
  end
103
+ if r.key? 'message'
104
+ event.set '[handset_detection][message]', r['message']
105
+ end
106
+ if r.key? 'hd_specs'
107
+ if @filter.empty?
108
+ event.set '[handset_detection][specs]', r['hd_specs']
109
+ else
110
+ event.set '[handset_detection][specs]', {}
111
+ @filter.each do |f|
112
+ if r['hd_specs'].key? f
113
+ event.set "[handset_detection][specs][#{f}]", r['hd_specs'][f]
114
+ end
115
+ end
116
+ end
117
+ end
118
+ else
119
+ event.set '[handset_detection][status]', 299
120
+ event.set '[handset_detection][message]', 'Error : Missing Data'
109
121
  end
110
122
  filter_matched event
111
123
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-filter-handsetdetection'
3
- s.version = '4.1.2'
3
+ s.version = '4.1.3'
4
4
  s.licenses = ['MIT']
5
5
  s.summary = "Handset Detection filter plugin for Logstash"
6
6
  s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-handsetdetection
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.2
4
+ version: 4.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Handset Detection