pingscanner

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2016 License: Apache-2.0 Imports: 4 Imported by: 18

README

pingscanner

Scanning alive hosts of the given CIDR range in parallel.

Usage

package main

import (
	"fmt"

	ps "github.com/kotakanbe/go-pingscanner"
)

func main() {
	scanner := ps.PingScanner{
		CIDR: "192.168.11.0/24",
		PingOptions: []string{
			"-c1",
			"-t1",
		},
		NumOfConcurrency: 100,
	}
	if aliveIPs, err := scanner.Scan(); err != nil {
		fmt.Println(err)
	} else {
		if len(aliveIPs) < 1 {
			fmt.Println("no alive hosts")
		}
		for _, ip := range aliveIPs {
			fmt.Println(ip)
		}
	}
}

Author

kotakanbe

License

Please see LICENSE.

Documentation

Overview

Package pingscanner scan alive IPs of the given CIDR range in parallel.

Example usage:

package main

import (

"fmt"

ps "github.com/kotakanbe/go-pingscanner"

)

func main() {
	scanner := ps.PingScanner{
		CIDR: "192.168.11.0/24",
		PingOptions: []string{
			"-c1",
			"-t1",
		},
		NumOfConcurrency: 100,
	}
	if aliveIPs, err := scanner.Scan(); err != nil {
		fmt.Println(err)
	} else {
		if len(aliveIPs) < 1 {
			fmt.Println("no alive hosts")
		}
		for _, ip := range aliveIPs {
			fmt.Println(ip)
		}
	}
}

Index

Constants

View Source
const Name string = "go-pingscanner"

Name ... Name

View Source
const Version string = "0.1.0"

Version ... Version

Variables

This section is empty.

Functions

This section is empty.

Types

type PingScanner

type PingScanner struct {
	// CIDR (ex. 192.168.0.0/24)
	CIDR string

	// Number of concurrency ping process. (ex. 100)
	NumOfConcurrency int

	// ping command options. (ex. []string{"-c1", "-t1"})
	PingOptions []string
}

PingScanner has information of Scanning.

func (PingScanner) Scan

func (d PingScanner) Scan() (aliveIPs []string, err error)

Scan ping to hosts in CIDR range.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL