fofa 0.3.7 → 0.3.8

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: d86dc3a20f95741a8017d70c145960ce2bfd447a
4
- data.tar.gz: a7d6c254a64791a34f5752eaa53d58de03eef102
3
+ metadata.gz: 51b78658d768160754f6f32ebd1eb38f9c9a1f90
4
+ data.tar.gz: 3b9634e71a8b0d1911e3febef7956ab384ccf6a3
5
5
  SHA512:
6
- metadata.gz: 24ab2152dc8fb32d66d7bf3f969c585cd575e895c47567bf80b2e371b0174fc203d4e7d1d0b27bde721c04e9daf84e09cbcaed5a80667a085a32acb866362b3d
7
- data.tar.gz: 9033da1b6c70978b1b91854f4ad669c7af408a3562680251e73e3b719a9f9d9d1edb09e857aed3a39786922d7bcf8f0e0fca082a396f299113aacc5f8c1a8e65
6
+ metadata.gz: edc85325d980675819fb60ae281d4286eaf39576c787fb96a8fc5f43093a14a9c1f6c2a2caa788f60d9da45252f7f1653e972b552e0aa626cf78ebb83ac13dee
7
+ data.tar.gz: 06e0b7ab86fcaa6bd7608d5039cc983baeda3bc7075bbc804deefe3fcf28400d20185ae23160b343a56b453d04be5f6cc6256ab0ac2705b57f0ef47acdf4a6a4
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  # Created by .ignore support plugin (hsz.mobi)
2
+ .idea
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fofa (0.3.6)
4
+ fofa (0.3.7)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -8,12 +8,13 @@ require "colorize"
8
8
  options = {
9
9
  email: ENV['FOFA_EMAIL'],
10
10
  apikey: ENV['FOFA_KEY'],
11
- page: 1,
11
+ page: nil,
12
12
  verbose: false,
13
13
  file: nil,
14
14
  mode: :search,
15
15
  split_size: 100,
16
- limit: 100,
16
+ size_per_page: 100,
17
+ limit: 1000,
17
18
  fields: 'host'
18
19
  }
19
20
 
@@ -45,10 +46,14 @@ ARGV.options do |opts|
45
46
 
46
47
  opts.on('-s', '--limit=SIZE', Integer, "Limit size to fetch, default to #{options[:limit]}") do |val|
47
48
  options[:limit] = val.to_i
48
- end
49
+ end
50
+
51
+ opts.on('-s', '--limit=SIZE', Integer, "Limit size to fetch, default to #{options[:limit]}") do |val|
52
+ options[:limit] = val.to_i
53
+ end
49
54
 
50
- opts.on('-l', '--split_size=SIZE', Integer, "Used at [import_service] mode, default to #{options[:split_size]}") do |val|
51
- options[:split_size] = val.to_i
55
+ opts.on(nil, '--size_per_page=SIZE', Integer, "API fetch size per page, default to #{options[:size_per_page]}") do |val|
56
+ options[:size_per_page] = val.to_i
52
57
  end
53
58
 
54
59
  opts.on('-d', '--fields=FIELDS', String, "Fields to return, split with ',', default to #{options[:fields]}") do |val|
@@ -99,7 +104,22 @@ when :search
99
104
  end
100
105
  query = ARGV.join(' ')
101
106
  puts "Query: '#{query}'"
102
- puts Fofa::API.new(options[:email], options[:apikey], {debug:options[:verbose]}).search(query, {page:options[:page], size:options[:limit], fields:options[:fields]})
107
+ if options[:page] #search one page
108
+ puts Fofa::API.new(options[:email], options[:apikey], {debug:options[:verbose]})
109
+ .search(query, {
110
+ page:options[:page],
111
+ size:options[:limit],
112
+ fields:options[:fields]
113
+ })
114
+ else
115
+ puts Fofa::API.new(options[:email], options[:apikey], {debug:options[:verbose]})
116
+ .search_all(query, {
117
+ size:options[:limit],
118
+ page_size:options[:size_per_page],
119
+ fields:options[:fields]
120
+ })
121
+ end
122
+
103
123
  when :import_service
104
124
  unless options[:file]
105
125
  puts "File not specified.".red
@@ -71,6 +71,8 @@ module Fofa
71
71
  all_res = all_res[0..all_size-1]
72
72
  break
73
73
  end
74
+
75
+ break if all_res.size >= res['size'].to_i
74
76
  else
75
77
  break
76
78
  end
@@ -1,8 +1,11 @@
1
+ # 0.3.8
2
+ # fix N+1 API request to N
3
+ #
1
4
  # 0.3.7
2
5
  # add page_size in search_all
3
6
  #
4
7
  # 0.3.6
5
8
  # add fields
6
9
  module Fofa
7
- VERSION = "0.3.7"
10
+ VERSION = "0.3.8"
8
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fofa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - fofa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-30 00:00:00.000000000 Z
11
+ date: 2017-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler