embulk-plugin-input-pcapng-files 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a831f929119e0209c353052fe5bf6e049dbafe36
4
- data.tar.gz: 6c5d1a06ae6c8921c21a5577c03ad460eec672ea
3
+ metadata.gz: ab515e74e913cd88b9e420a88929afae017a0ff8
4
+ data.tar.gz: 5a0bfce47d4bee325a287c53320b3f610ceae806
5
5
  SHA512:
6
- metadata.gz: c3a1b45cfd90162d1670a0f57ac2a78c10713feb26e9a44c09dffa72b6a2c1d615a253fda80ff4aaf082400daf6cea7a06d0e70d4d0ca69e85fd9aee7e868b85
7
- data.tar.gz: fa8833f4b3d290e80ec1f9a1257890ce17edfb653e8ce60e1af956e4ca8798c382bc892b905643509f630bf4f542c3a342c5c9e59a15e8eb526534055b6e34d2
6
+ metadata.gz: 94c0c28cdf4b98c08449e71216d3a9d1f0fe561d557f7dc24c26d2e4fbbab0aed4964e8029574d1cb731d6520d5af7903b5326018d4b47256361378e02abb0be
7
+ data.tar.gz: 1da8e55c47aea4e2b60654d3b6ca3da67db66b02d790f8698fe2b9111cabbf5c14fdf8624b4161b8290f5cc9a10cffd99380f503047124d41861dce9dd8f0ea5
data/README.md CHANGED
@@ -9,3 +9,12 @@ To extract specific field from pcapng files
9
9
  1. check sample\_config.yml, modify "paths" to where ever pcapng files are.
10
10
  2. specify fields to collect in "schema", name should correspond to tshark's field name
11
11
 
12
+
13
+ ## BUGs
14
+
15
+ - "done" list is not properly handled
16
+
17
+ ### ToDo
18
+
19
+ - Obviously, most part duplicates to file input.
20
+ - rewrite this as decoder or parser plugin?
@@ -6,11 +6,9 @@ module Embulk
6
6
  Plugin.register_input('pcapng_files', self)
7
7
 
8
8
  def self.transaction(config, &control)
9
- threads = config.param('threads', :integer, default: 2)
10
9
  task = {
11
10
  'paths' => [],
12
11
  'done' => config.param('done', :array, default: []),
13
- 'paths_per_thread' => [],
14
12
  }
15
13
 
16
14
  task['paths'] = config.param('paths', :array, default: []).map {|path|
@@ -20,9 +18,8 @@ module Embulk
20
18
  }
21
19
  }.flatten
22
20
  task['paths'] = task['paths'] - task['done']
23
- task['paths_per_thread'] = task['paths'].each_slice(task['paths'].length / threads + 1).to_a
24
21
 
25
- if task['paths'] == []
22
+ if task['paths'].empty?
26
23
  raise "no valid pcapng file found"
27
24
  end
28
25
 
@@ -35,10 +32,10 @@ module Embulk
35
32
  Column.new(idx, "#{c['name']}", c['type'].to_sym)
36
33
  }
37
34
 
38
- commit_reports = yield(task, columns, threads)
35
+ commit_reports = yield(task, columns, task['paths'].length)
39
36
  done = commit_reports.map{|hash| hash["done"]}.flatten.compact
40
37
 
41
- return config.merge({ "done" => done })
38
+ return {"done" => done}
42
39
  end
43
40
 
44
41
  def initialize(task, schema, index, page_builder)
@@ -50,22 +47,16 @@ module Embulk
50
47
  attr_reader :page_builder
51
48
 
52
49
  def run
53
- paths = task['paths_per_thread'][@index]
54
- if paths == nil or paths == []
55
- return {} # no task, no fail
56
- end
57
-
58
- paths.each do |path|
59
- each_packet(path, schema[1..-1].map{|elm| elm.name}) do |hash|
60
- entry = [ path ] + schema[1..-1].map {|c|
61
- convert(hash[c.name], c.type)
62
- }
63
- @page_builder.add(entry)
64
- end
50
+ path = task['paths'][@index]
51
+ each_packet(path, schema[1..-1].map{|elm| elm.name}) do |hash|
52
+ entry = [ path ] + schema[1..-1].map {|c|
53
+ convert(hash[c.name], c.type)
54
+ }
55
+ @page_builder.add(entry)
65
56
  end
66
57
  @page_builder.finish # must call finish they say
67
58
 
68
- return {"done" => paths}
59
+ return {"done" => path}
69
60
  end
70
61
 
71
62
  private
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-plugin-input-pcapng-files
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naoya Kaneko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-28 00:00:00.000000000 Z
11
+ date: 2015-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler