ping2

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2020 License: GPL-3.0 Imports: 10 Imported by: 1

README

ping-go-v2

refactor of ping-go for JobProtocol, using a better packet capturing library

highly recommend not to use this for most purposes, instead use https://github.com/bachittle/ping-go until this library is better implemented

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateIPs

func GenerateIPs(IPs []CustomIP) chan net.IP

GenerateIPs generates all the IP addresses given the subnet prefix (if there is one) and destination IP in CustomIP

Types

type Capturer

type Capturer struct {
	Iface pcap.Interface

	IPs []CustomIP
	// contains filtered or unexported fields
}

Capturer contains a set of IPs to capture from (or a subnet), otherwise it captures from everything on the wire

func (Capturer) CaptureIPs

func (c Capturer) CaptureIPs(stopChan *chan int, id uint16) chan net.IP

CaptureIPs captures from the specified IP addresses in IPs it does this asynchronously, and returns captured echo replies to a returned channel you can close the channel with the optional parameter channel. Just pass it a number.

func (Capturer) GetDevs

func (c Capturer) GetDevs() (str string)

GetDevs prints the devices, so you can pick which one to set the index to.

func (*Capturer) Init

func (c *Capturer) Init(index int) error

Init sets the capturers interface to read off of, and reads it. For simplicity, you can specify the index of the interfaces given from FindAllDevs. it is different for every system, to see all devices and associated index, run GetDevs()

type Controller

type Controller struct {
	SrcIP  net.IP
	DstIPs []CustomIP
	// contains filtered or unexported fields
}

Controller is the intermediary between capturer and sender

it sends data with the sender and captures packets and gets specific IP packets with the capturer

func (*Controller) Init

func (c *Controller) Init()

Init initiallizes the controller.

func (Controller) SendAndRecv

func (c Controller) SendAndRecv(timeout time.Duration) map[string]bool

SendAndRecv sends data with the sender and receives data with the capturer

type CustomIP

type CustomIP struct {
	IP     net.IP
	Subnet *int
}

CustomIP contains an IP and (optionally) a subnet. If optional, is nil.

type Sender

type Sender struct {
	SrcIP  net.IP
	DstIPs []CustomIP
}

Sender sends an echo request to the specified IP address

func (Sender) SendOne

func (s Sender) SendOne(id int) (int, error)

SendOne sends one packet to the specified SrcIP and DstIPs returns the amount of successful IPs it sent to, and the random ID generated for checking

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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