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.
- checksums.yaml +4 -4
- data/bin/dronebl-add +9 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16aacfdd77793ba2bae1402a73575a2db7912a7e
|
4
|
+
data.tar.gz: 527db5ba7211b2749e9cd2ae3f67f21e84cd1d8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2b93b28351acfd7cf7a852e91391c5181bba903bc3e999d53283d0988b44a0a7bd2bd82c9e362d6a46c62b9dc20ef14ac1874f77801162657ec47502fc73fa3
|
7
|
+
data.tar.gz: 7d75a555e29fb494abac771e65cd1c47156289a39d9111eb498592b4d3da4c9a81b7a401100e13b4ac6af6aede924e755809d0ea3c3c56b063defbb95aca02f3
|
data/bin/dronebl-add
CHANGED
@@ -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
|
97
|
-
puts DroneBL::gen_add_query
|
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
|
-
|
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?
|