arpme

package module
v0.0.0-...-76044d9 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2018 License: MIT Imports: 11 Imported by: 0

README

arpme status godoc goreport

arpme is a simple arp scanning library for Go.

Contributing

Please review the CONTRIBUTING doc for submitting issues/a guide on submitting pull requests and helping out.

License

LICENSE: The MIT License (MIT)
Copyright (c) 2017 Liam Stanley <me@liamstanley.io>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Documentation

Overview

Package arpme is a simple arp scanning library.

An example:

scanner, err := New(Config{
	HandlerFunc: func(resp Response) {
		log.Printf("response: [%s] :: %s :: %s", resp.SourceHardwareAddr.String(), resp.SourceIP.String(), resp.Host)
	},
})
if err != nil {
	panic(err)
}

log.Println(scanner.Run())

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// DisallowInterfaceError will cause Start() to return an error if it can't
	// listen to an interface.
	DisallowInterfaceError bool

	// Delay is the time between each loop of arp requests.
	Delay time.Duration

	// Interfaces to send/listen for arp requests. If this is empty, it will
	// attempt to listen to all known interfaces.
	Interfaces []net.Interface

	// HandlerFunc is executed when we receive a valid arp response. It is
	// executed in its own goroutine.
	HandlerFunc func(Response)

	// Debug is an optional writer which will be used for debug output.
	Debug io.Writer
}

Config is the configuration struct you should pass to New().

type Response

type Response struct {
	// SourceIP is the IP of the source that responded to the arp request.
	SourceIP net.IP

	// SourceHardwareAddr is the MAC of the source that responded to the arp request.
	SourceHardwareAddr net.HardwareAddr

	// Host is the first rDNS entry returned for the source IP, if one exists.
	Host string

	// Timestamp is when the request was received.
	Timestamp time.Time
}

Response is the tailored response output from the arp packets we received.

type Scanner

type Scanner struct {
	// contains filtered or unexported fields
}

Scanner is a arp scanning client.

func New

func New(conf Config) (*Scanner, error)

New returns a new scanner.

func (*Scanner) Close

func (s *Scanner) Close()

Close sends a request to close all goroutines and listeners.

func (*Scanner) Run

func (s *Scanner) Run() error

Run calls Start(), and then Wait(). It blocks until there is an error, or nil if Close() is called.

func (*Scanner) Start

func (s *Scanner) Start() error

Start initiates a scan loop on each interface, and only returns an error if there was one when starting the interface scans.

func (*Scanner) Wait

func (s *Scanner) Wait() error

Wait waits for the scanner to finish running. It will only finish if Close() is called, or an error occurs on one of the interfaces.

Jump to

Keyboard shortcuts

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