netscan_calife 0.0.3 → 0.0.4
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 +4 -4
 - data/bin/netscan_calife +1 -1
 - data/lib/netscan_calife/ip_scan.rb +30 -14
 - data/lib/netscan_calife/version.rb +1 -1
 - 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: f19a1690cea13ba42dfce8c6c92d2eebaabd1dbc
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 6329be0195e66f73487860b32138b692a41d1f64
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 3f4138fc88476019a4a80c2ad7a283fcbc1d382ba3a5b0ec134f20178281b79434808b91daf3ec997bf8bd8bd17004e59adb572ab42df2fe42d00990f75acda7
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: d197b6925cee9219191af1fb2c0c1ed0198a78fa7e879552d192b90fb435c22f6daadc3f6644f31f59971fe38848cf37cee029d9a07d4dd4342ec728ab95ab5f
         
     | 
    
        data/bin/netscan_calife
    CHANGED
    
    
| 
         @@ -6,10 +6,11 @@ module NetscanCalife 
     | 
|
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
              class IpScan
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
      
 9 
     | 
    
         
            +
            =begin
         
     | 
| 
      
 10 
     | 
    
         
            +
                  Ping network scan 
         
     | 
| 
      
 11 
     | 
    
         
            +
            =end
         
     | 
| 
       9 
12 
     | 
    
         
             
                def self.scan(network,netmask)
         
     | 
| 
       10 
13 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
                  total_elapsed= Benchmark.measure {
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
14 
     | 
    
         
             
                    net1 = IPAddr.new(network).mask(netmask)
         
     | 
| 
       14 
15 
     | 
    
         | 
| 
       15 
16 
     | 
    
         
             
                    statuses=net1.to_range.map do |host|
         
     | 
| 
         @@ -22,21 +23,36 @@ module NetscanCalife 
     | 
|
| 
       22 
23 
     | 
    
         | 
| 
       23 
24 
     | 
    
         
             
                    end
         
     | 
| 
       24 
25 
     | 
    
         | 
| 
       25 
     | 
    
         
            -
                    statuses.each { |p,h|
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
                      printf("%s\n","Host found #{h}") if $?.exitstatus.zero?
         
     | 
| 
       30 
     | 
    
         
            -
                      
         
     | 
| 
       31 
     | 
    
         
            -
                    }  
         
     | 
| 
      
 26 
     | 
    
         
            +
                    # statuses.each { |p,h|          
         
     | 
| 
      
 27 
     | 
    
         
            +
                    #   Process.wait(p)
         
     | 
| 
      
 28 
     | 
    
         
            +
                    #   printf("%s\n","Host found #{h}") if $?.exitstatus.zero?          
         
     | 
| 
      
 29 
     | 
    
         
            +
                    # }
         
     | 
| 
       32 
30 
     | 
    
         | 
| 
       33 
     | 
    
         
            -
                     
     | 
| 
      
 31 
     | 
    
         
            +
                    statuses.map! { |p,h|
         
     | 
| 
      
 32 
     | 
    
         
            +
                      Process.wait(p)
         
     | 
| 
      
 33 
     | 
    
         
            +
                      [h,$?.exitstatus.zero?]
         
     | 
| 
      
 34 
     | 
    
         
            +
                    }
         
     | 
| 
      
 35 
     | 
    
         
            +
                     
         
     | 
| 
      
 36 
     | 
    
         
            +
                    return statuses
         
     | 
| 
       34 
37 
     | 
    
         | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
      
 38 
     | 
    
         
            +
                end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
            =begin
         
     | 
| 
      
 41 
     | 
    
         
            +
            Print scan result
         
     | 
| 
      
 42 
     | 
    
         
            +
            =end    
         
     | 
| 
      
 43 
     | 
    
         
            +
                def self.format_result(data,fmt='txt')
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                  case fmt
         
     | 
| 
      
 46 
     | 
    
         
            +
                  when 'txt'
         
     | 
| 
      
 47 
     | 
    
         
            +
                    printf "%s\n","-----------------------------------------"
         
     | 
| 
      
 48 
     | 
    
         
            +
                    printf "|\t%s\t\t|\t%s\t|\n","HOST","FOUND"      
         
     | 
| 
      
 49 
     | 
    
         
            +
                    printf "%s\n","-----------------------------------------"      
         
     | 
| 
      
 50 
     | 
    
         
            +
                    data.each { |host,found|
         
     | 
| 
      
 51 
     | 
    
         
            +
                      printf "|\t%s\t|\t%s\t|\n","#{host}","#{found}"
         
     | 
| 
      
 52 
     | 
    
         
            +
                    }
         
     | 
| 
      
 53 
     | 
    
         
            +
                    printf "%s\n","-----------------------------------------"        
         
     | 
| 
      
 54 
     | 
    
         
            +
                  end
         
     | 
| 
       36 
55 
     | 
    
         | 
| 
       37 
     | 
    
         
            -
                  puts "##############################"
         
     | 
| 
       38 
     | 
    
         
            -
                  puts "Total Elapsed " + "#{total_elapsed}"
         
     | 
| 
       39 
     | 
    
         
            -
                  puts "##############################"
         
     | 
| 
       40 
56 
     | 
    
         
             
                end
         
     | 
| 
       41 
57 
     | 
    
         | 
| 
       42 
58 
     | 
    
         
             
              end
         
     |