iqeo-hostspec 0.1.0.pre2 → 0.1.0

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: 4b3e2f1c15026a95d95666c9eaee3de460ccf92d
4
- data.tar.gz: 263459817766d46b9b32d4bfee19f546134817b0
3
+ metadata.gz: 0d4927a6cd57e8cf6848b59c3c7d18f0de6f5fac
4
+ data.tar.gz: 4e438effc15e09931ba828e12938a6f95eda2a2d
5
5
  SHA512:
6
- metadata.gz: 0be30e4d2da2a60e74561d4a224e8cf85c4f3d5477ede05859aa6a62f58983122d907489920071acd200bd19dfd53bef9ecd3594b576354ac102b61b70436404
7
- data.tar.gz: a07aabde5df2381c9d2f4b379a16e8c758c422c773e16d665b3d2af1ff84ef2b85876cd0c54fb55a72d2e87512782d5212847735fd216f4b2bac1c64acc66904
6
+ metadata.gz: 84c07de0278d65a68499252defad60515dc0ee090435b3c5b8b617577f1e50bfdd7dbc8c7587d4c23ab7f12bc93e4ee43e4330549e897f221dd0ed091110ee3a
7
+ data.tar.gz: 5e79448a4c50ec6b9df738ed7f1ee402f40f87b7a25525c9fc121727510d9fa5100462ae01028cad1cc54c52d517d4feeb1c5ca4a55acf494d679dbc694e1650
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format doc
data/README.md CHANGED
@@ -3,23 +3,103 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/iqeo-hostspec.png)](http://badge.fury.io/rb/iqeo-hostspec)
4
4
  [![Build Status](https://travis-ci.org/iqeo/iqeo-hostspec.png?branch=master)](https://travis-ci.org/iqeo/iqeo-hostspec)
5
5
 
6
- TODO: Write a gem description
6
+ A program and Ruby library to generate lists of IP addresses from Nmap-style IP host specifications.
7
+
8
+ For example:
9
+ ```
10
+ hostspec 1.0.0.1-3
11
+ ```
12
+ Produces:
13
+ ```
14
+ 10.0.0.1
15
+ 10.0.0.2
16
+ 10.0.0.3
17
+ ```
18
+
19
+ In addition to expanding host specs to a list, a command may be executed for each IP address. This enables execution of commands for all hosts on a network. See Program Usage below.
7
20
 
8
21
  ## Installation
9
22
 
10
- Add this line to your application's Gemfile:
23
+ Install a current version of Ruby from [https://www.ruby-lang.org/en/installation/](https://www.ruby-lang.org/en/installation/)
24
+
25
+ Iqeo::Hostspec is packaged as a Ruby gem. To install, execute:
26
+
27
+ ```
28
+ gem install iqeo-hostspec
29
+ ```
30
+
31
+ To use the library in your own applications:
32
+
33
+ ```ruby
34
+ require 'iqeo/hostspec'
35
+ ```
36
+
37
+ ## Program Usage
38
+
39
+ For help with usage, execute:
40
+
41
+ ```
42
+ hostspec --help
43
+ ```
11
44
 
12
- gem 'iqeo-hostspec'
45
+ ```
46
+ Usage: hostspec [ options ] specs... [ [ -c / --cmd ] command ]
13
47
 
14
- And then execute:
48
+ Prints all IP addresses for IP host specifications (see Specs:).
49
+ If specified, a command is executed for each IP address, with related values in environment variables (see Command:).
15
50
 
16
- $ bundle
51
+ Specs:
52
+ Nmap-style IP host specifications, multiple specs separated by spaces.
53
+ Single host : x.x.x.x or hostname
54
+ Multiple hosts:
55
+ - by mask length : x.x.x.x/m or hostname/m
56
+ - by octet values : x.x.x.a,b,c
57
+ - by octet ranges : x.x.x.d-e
58
+ Octet values and ranges may be combined or applied to any/multiple octets.
59
+ Examples:
60
+ hostname : localhost => 127.0.0.1
61
+ hostname w/mask : localhost/24 => 127.0.0.0 127.0.0.1 ... 127.0.0.254 127.0.0.255
62
+ address : 1.0.0.1 => 1.0.0.1
63
+ address w/mask : 2.0.0.1/24 => 2.0.0.0 2.0.0.1 ... 2.0.0.254 2.0.0.255
64
+ address w/values : 3.0.0.10,20,30 => 3.0.0.10 3.0.0.20 3.0.0.30
65
+ address w/ranges : 4.0.0.40-50 => 4.0.0.40 4.0.0.41 ... 4.0.0.49 4.0.0.50
66
+ address w/combo : 5.0.0.2,4-6,8 => 5.0.0.2 5.0.0.4 5.0.0.5 5.0.0.6 5.0.0.8
67
+ multiple octets : 6.1-2,3.4-5.6 => 6.1.4.6 6.1.5.6 6.2.4.6 6.2.5.6 6.3.4.6 6.3.5.6
17
68
 
18
- Or install it yourself as:
69
+ Command:
70
+ A command to execute for each IP address may be specified following the command switch ( -c / --cmd ).
71
+ The command is executed in a separate shell for each IP address.
72
+ Environment variables are provided with values for each IP address command execution.
73
+ Quote these variables in the command to prevent substitution by the current shell.
74
+ $HOSTSPEC_IP : IP address
75
+ $HOSTSPEC_MASK : Mask (255.255.255.255 if a mask length was not specified)
76
+ $HOSTSPEC_MASKLEN : Mask length (32 if a mask length was not specified)
77
+ $HOSTSPEC_COUNT : Count of IP addresses
78
+ $HOSTSPEC_INDEX : Index of IP address (from 1 to Count)
79
+ Examples:
80
+ Print IP addresses and mask length with index and count:
81
+ hostspec 1.1.1.0/30 --cmd echo '$HOSTSPEC_INDEX' of '$HOSTSPECT_COUNT' : '$HOSTSPEC_IP/$HOSTSPEC_MASKLEN'
82
+ ...
83
+ 1 of 4 : 1.1.1.0/255.255.255.252
84
+ 2 of 4 : 1.1.1.1/255.255.255.252
85
+ 3 of 4 : 1.1.1.2/255.255.255.252
86
+ 4 of 4 : 1.1.1.3/255.255.255.252
87
+ Collect routing tables of all hosts on a network via ssh:
88
+ hostspec 1.1.1.1-254 --cmd 'ssh me@$HOSTSPEC_IP route -n'
89
+ Collect default web pages from all servers on a network via curl:
90
+ hostspec 1.1.1.1-254 --cmd curl -o '$HOSTSPEC_IP.html' 'http://$HOSTSPEC_IP'
91
+ Collect IP configuration info from multiple windows systems (run from a windows system):
92
+ hostspec 1.1.1.1-254 --cmd psexec '\\%HOSTSPEC_IP%' ipconfig /all
93
+ Collect IP configuration info from multiple windows systems (run from a linux system with kerberos):
94
+ hostspec 1.1.1.1-254 --cmd winexe --kerberos yes //$(dig -x '$HOSTSPEC_IP' +short) ipconfig /all
95
+ ...or any task that you would have to execute individually on multiple systems.
19
96
 
20
- $ gem install iqeo-hostspec
97
+ Options:
98
+ -h / --help : Display this helpful information
99
+ -v / --version : Display program version
100
+ ```
21
101
 
22
- ## Usage
102
+ ## License
23
103
 
24
- TODO: Write usage instructions here
104
+ Licensed under GPLv3, see LICENSE.txt.
25
105
 
@@ -78,13 +78,13 @@ module Iqeo
78
78
  io.puts " Octet values and ranges may be combined or applied to any/multiple octets."
79
79
  io.puts " Examples:"
80
80
  io.puts " hostname : localhost => 127.0.0.1"
81
- io.puts " hostname w/mask : localhost/24 => 127.0.0.0 127.0.0.1 ... 127.0.0.254 127.0.0.255"
82
- io.puts " address : 1.1.1.1 => 1.1.1.1"
83
- io.puts " address w/mask : 2.2.2.1/24 => 2.2.2.0 2.2.2.1 ... 2.2.2.254 2.2.2.255"
84
- io.puts " address w/values : 3.3.3.10,20,30 => 3.3.3.10 3.3.3.20 3.3.3.30"
85
- io.puts " address w/ranges : 4.4.4.40-50 => 4.4.4.40 4.4.4.41 ... 4.4.4.49 4.4.4.50"
86
- io.puts " address w/combo : 5.5.5.2,4-6,8 => 5.5.5.2 5.5.5.4 5.5.5.5 5.5.5.6 5.5.5.8"
87
- io.puts " complex : 6.1-2,3.4-5.6 => 6.1.4.6 6.1.5.6 6.2.4.6 6.2.5.6 6.3.4.6 6.3.5.6"
81
+ io.puts " hostname w/mask : localhost/24 => 127.0.0.0 127.0.0.1 ... 127.0.0.254 127.0.0.255"
82
+ io.puts " address : 1.0.0.1 => 1.0.0.1"
83
+ io.puts " address w/mask : 2.0.0.1/24 => 2.0.0.0 2.0.0.1 ... 2.0.0.254 2.0.0.255"
84
+ io.puts " address w/values : 3.0.0.10,20,30 => 3.0.0.10 3.0.0.20 3.0.0.30"
85
+ io.puts " address w/ranges : 4.0.0.40-50 => 4.0.0.40 4.0.0.41 ... 4.0.0.49 4.0.0.50"
86
+ io.puts " address w/combo : 5.0.0.2,4-6,8 => 5.0.0.2 5.0.0.4 5.0.0.5 5.0.0.6 5.0.0.8"
87
+ io.puts " multiple octets : 6.1-2,3.4-5.6 => 6.1.4.6 6.1.5.6 6.2.4.6 6.2.5.6 6.3.4.6 6.3.5.6"
88
88
  io.puts
89
89
  io.puts "Command:"
90
90
  io.puts " A command to execute for each IP address may be specified following the command switch ( -c / --cmd )."
@@ -1,7 +1,7 @@
1
1
 
2
2
  module Iqeo
3
3
  module Hostspec
4
- VERSION = '0.1.0.pre2'
4
+ VERSION = '0.1.0'
5
5
  end
6
6
  end
7
7
 
@@ -1,3 +1,4 @@
1
+ require 'spec_helper'
1
2
  require 'iqeo/hostspec'
2
3
  include Iqeo::Hostspec
3
4
 
@@ -436,8 +437,8 @@ describe Hostspec do
436
437
 
437
438
  it 'responds to Enumerable methods' do
438
439
  hs = Hostspec.new '10.20.30.40/24'
439
- hs.all? { |i| i.start_with? '10' }.should be_true
440
- hs.any? { |i| i.end_with? '255' }.should be_true
440
+ hs.all? { |i| i.start_with? '10' }.should eq true
441
+ hs.any? { |i| i.end_with? '255' }.should eq true
441
442
  end
442
443
 
443
444
  it 'can calculate size for simple specs' do
@@ -1,4 +1,5 @@
1
- load './bin/hostspec'
1
+ require 'spec_helper'
2
+ require 'iqeo/hostspec'
2
3
  include Iqeo::Hostspec
3
4
 
4
5
  require 'stringio'
@@ -0,0 +1,5 @@
1
+ RSpec.configure do |config|
2
+ config.expect_with :rspec do |c|
3
+ c.syntax = [:should, :expect]
4
+ end
5
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iqeo-hostspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerard Fowley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-13 00:00:00.000000000 Z
11
+ date: 2014-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -33,6 +33,7 @@ extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
35
  - ".gitignore"
36
+ - ".rspec"
36
37
  - ".travis.yml"
37
38
  - Gemfile
38
39
  - Guardfile
@@ -47,6 +48,7 @@ files:
47
48
  - lib/iqeo/hostspec/version.rb
48
49
  - spec/iqeo/hostspec_spec.rb
49
50
  - spec/iqeo/runner_spec.rb
51
+ - spec/spec_helper.rb
50
52
  - tmux
51
53
  homepage: ''
52
54
  licenses:
@@ -63,9 +65,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
63
65
  version: '0'
64
66
  required_rubygems_version: !ruby/object:Gem::Requirement
65
67
  requirements:
66
- - - ">"
68
+ - - ">="
67
69
  - !ruby/object:Gem::Version
68
- version: 1.3.1
70
+ version: '0'
69
71
  requirements: []
70
72
  rubyforge_project:
71
73
  rubygems_version: 2.2.1
@@ -75,3 +77,4 @@ summary: Write a gem summary
75
77
  test_files:
76
78
  - spec/iqeo/hostspec_spec.rb
77
79
  - spec/iqeo/runner_spec.rb
80
+ - spec/spec_helper.rb