<commit_before>/*!
 * node-libnmap
 * Copyright(c) 2013-2015 <NAME> <<EMAIL>>
 * License: MIT
 */

var nmap = require('../')
  , fs = require('fs')
  , path = './scans/'
  , opts = {
      timeout: 100,
      //range: ['scanme.nmap.org', 'localhost', '172.17.190.0/17'],
      range: ['scanme.nmap.org', 'localhost', '172.17.190.0/27'],
      ports: '21,22,80,443'
    };

nmap.scan(opts, function(err, report) {
  if (err) throw new Error(err);

  for (var item in report) {
    console.log(JSON.stringify(report[item]));
/*
    for (var host in report[item].host) {

      var data = JSON.stringify(report[item].host[host])
        , filename = report[item].host[host].address.addr;

      fs.writeFile(path+filename+'.json', data, function(error) {
        if (error) throw error;
        console.log('Wrote report for '+filename);
      });
    }
*/<commit_msg>Updated example to handly typical cidr range & how to handle reports<commit_after>/*!
 * node-libnmap
 * Copyright(c) 2013-2015 <NAME> <<EMAIL>>
 * License: MIT
 */

var nmap = require('../')
  , fs = require('fs')
  , path = './scans/'
  , opts = {
      timeout: 100,
      range: ['scanme.nmap.org', 'localhost', '172.17.190.0/24'],
      ports: '21,22,80,443'
    };

nmap.scan(opts, function(err, report) {
  if (err) throw new Error(err);

  for (var item in report) {
    for (var host in report[item].host) {

      var data = JSON.stringify(report[item].host[host])
        , filename = report[item].host[host].address.addr;

      fs.writeFile(path+filename+'.json', data, function(error) {
        if (error) throw error;
        console.log('Wrote report for '+filename);
      });
    }
{'fraction_non_alphanumeric': 0.18870192307692307, 'fraction_numerical': 0.043870192307692304, 'mean_word_length': 2.8452655889145495, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 3, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5127084', 'n_tokens_mistral': 631, 'n_tokens_neox': 574, 'n_words': 131}