dronebl.rb 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/dronebl-add +9 -6
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 379138ce46c0c464447e92e60fa002cdc580db63
4
- data.tar.gz: 1213dc5cebb786b9565ee7961b57f36d763589ba
3
+ metadata.gz: 16aacfdd77793ba2bae1402a73575a2db7912a7e
4
+ data.tar.gz: 527db5ba7211b2749e9cd2ae3f67f21e84cd1d8f
5
5
  SHA512:
6
- metadata.gz: ff35d03b19a0cf1bfdcdd1153ffe823ecc62d1549d791be3ef1a437790ba9f29c2f30a3e96f5f5a6318207a0402bbc1e07622d1281a3cdc5ef0d95f2361a2964
7
- data.tar.gz: 32bbd489797d86c413099ecae2d739d580cab1b66d1f464e3ef98d0b34bbe741d1c5439b4fb87852b17cd1a4f1b2a56221eb99979adcad2a592bbfa6bb247e22
6
+ metadata.gz: e2b93b28351acfd7cf7a852e91391c5181bba903bc3e999d53283d0988b44a0a7bd2bd82c9e362d6a46c62b9dc20ef14ac1874f77801162657ec47502fc73fa3
7
+ data.tar.gz: 7d75a555e29fb494abac771e65cd1c47156289a39d9111eb498592b4d3da4c9a81b7a401100e13b4ac6af6aede924e755809d0ea3c3c56b063defbb95aca02f3
@@ -6,11 +6,12 @@ require 'resolv'
6
6
  require 'optparse'
7
7
  class Options
8
8
  attr_reader :read_from_stdin, :key_str, :key_file, :type, :comment, :dry_run,
9
- :use_key_file, :no_check
9
+ :use_key_file, :no_check, :max_ips_per_chunk
10
10
  attr_accessor :ips
11
11
  def initialize
12
12
  @key_file = File.expand_path "~/.droneblkey"
13
13
  @ips = []
14
+ @max_ips_per_chunk = 100
14
15
  @opt_parser = OptionParser.new do |opts|
15
16
  opts.banner = "Usage: #{$0} [options]"
16
17
  opts.separator ""
@@ -35,6 +36,9 @@ class Options
35
36
  puts DroneBL::TYPES.map { |k, v| "#{k} : #{v}"}.join("\n")
36
37
  exit
37
38
  end
39
+ opts.on('-M', '--max-ips-per-chunk NUM', Integer, 'The maximum number of IPs to send in a single submission chunk. Default 100.') do |max|
40
+ @max_ips_per_chunk = max
41
+ end
38
42
  opts.on('-c', '--comment COMMENT', String, 'Attach the given comment to the listings.') do |comment|
39
43
  @comment = comment
40
44
  end
@@ -93,12 +97,11 @@ opts.ips.uniq!
93
97
  prevalid, ipv6 = opts.ips.partition { |ip| (ip.match(Resolv::IPv6::Regex).nil?) }
94
98
  valid, invalid = prevalid.partition { |ip| !(ip.match(Resolv::IPv4::Regex).nil?) }
95
99
  invalid += ipv6
96
- if @dry_run
97
- puts DroneBL::gen_add_query valid
98
- puts "#{valid.count} IPs will be added as type #{opts.type}#{" with comment 'opts.comment if opts.comment}'"}."
100
+ if opts.dry_run
101
+ valid.each_slice(opts.max_ips_per_chunk) { |submit| puts DroneBL::gen_add_query(submit, opts.type, opts.comment) }
102
+ puts "#{valid.count} IPs will be added as type #{opts.type}#{" with comment '#{opts.comment if opts.comment}'"}."
99
103
  else
100
- response = DroneBL::add(valid, opts.type, opts.comment)
101
- puts response
104
+ valid.each_slice(opts.max_ips_per_chunk) { |submit| DroneBL::add(submit, opts.type, opts.comment) }
102
105
  puts "#{valid.count} IPs added as type #{opts.type}#{" with comment '#{opts.comment}'" if opts.comment}"
103
106
  end
104
107
  unless invalid.empty?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dronebl.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rylee Fowler