scan

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2022 License: MIT Imports: 17 Imported by: 18

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPortRange = errors.New("invalid port range")
	ErrSubnet    = errors.New("invalid subnet")
	ErrIP        = errors.New("invalid ip")
	ErrPort      = errors.New("invalid port")
	ErrJSON      = errors.New("invalid json")
)

Functions

func MergeBufferDataChan

func MergeBufferDataChan(ctx context.Context, channels ...<-chan *packet.BufferData) <-chan *packet.BufferData

generics would be helpful :)

Types

type Engine

type Engine interface {
	Start(ctx context.Context, r *Range) (done <-chan interface{}, errc <-chan error)
}

type EngineResulter

type EngineResulter interface {
	Engine
	Resulter
}

func NewEngineResulter

func NewEngineResulter(e Engine, r Resulter) EngineResulter

func SetupPacketEngine

func SetupPacketEngine(rw packet.ReadWriter, m PacketMethod) EngineResulter

type GenericEngine

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

func NewScanEngine

func NewScanEngine(reqgen RequestGenerator,
	scanner Scanner, results ResultChan, opts ...GenericEngineOption) *GenericEngine

func (*GenericEngine) Results

func (e *GenericEngine) Results() <-chan Result

func (*GenericEngine) Start

func (e *GenericEngine) Start(ctx context.Context, r *Range) (<-chan interface{}, <-chan error)

type GenericEngineOption

type GenericEngineOption func(s *GenericEngine)

func WithScanWorkerCount

func WithScanWorkerCount(workerCount int) GenericEngineOption

type IPContainer added in v0.2.0

type IPContainer interface {
	Contains(ip net.IP) (bool, error)
}

type IPGenerator

type IPGenerator interface {
	IPs(ctx context.Context, r *Range) (<-chan IPGetter, error)
}

func NewFileIPGenerator

func NewFileIPGenerator(openFile OpenFileFunc) IPGenerator

func NewIPGenerator

func NewIPGenerator() IPGenerator

type IPGetter

type IPGetter interface {
	GetIP() (net.IP, error)
}

type IPPort

type IPPort struct {
	IP   string `json:"ip"`
	Port int    `json:"port"`
}

func (IPPort) MarshalEasyJSON

func (v IPPort) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (IPPort) MarshalJSON

func (v IPPort) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*IPPort) UnmarshalEasyJSON

func (v *IPPort) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*IPPort) UnmarshalJSON

func (v *IPPort) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type OpenFileFunc

type OpenFileFunc func() (io.ReadCloser, error)

type PacketEngine

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

func NewPacketEngine

func NewPacketEngine(ps PacketSource, s packet.Sender, r packet.Receiver) *PacketEngine

func (*PacketEngine) Start

func (e *PacketEngine) Start(ctx context.Context, r *Range) (<-chan interface{}, <-chan error)

type PacketFiller

type PacketFiller interface {
	Fill(packet gopacket.SerializeBuffer, r *Request) error
}

type PacketGenerator

type PacketGenerator interface {
	Packets(ctx context.Context, in <-chan *Request) <-chan *packet.BufferData
}

func NewPacketGenerator

func NewPacketGenerator(filler PacketFiller) PacketGenerator

func NewPacketMultiGenerator

func NewPacketMultiGenerator(filler PacketFiller, numWorkers int) PacketGenerator

type PacketMethod

type PacketMethod interface {
	PacketSource
	packet.Processor
	Resulter
}

type PacketSource

type PacketSource interface {
	Packets(ctx context.Context, r *Range) <-chan *packet.BufferData
}

func NewPacketSource

func NewPacketSource(reqgen RequestGenerator, pktgen PacketGenerator) PacketSource

type PortGenerator

type PortGenerator interface {
	Ports(ctx context.Context, r *Range) (<-chan PortGetter, error)
}

func NewPortGenerator

func NewPortGenerator() PortGenerator

type PortGetter added in v0.3.0

type PortGetter interface {
	GetPort() (uint16, error)
}

type PortRange

type PortRange struct {
	StartPort uint16
	EndPort   uint16
}

type Range

type Range struct {
	Interface *net.Interface
	DstSubnet *net.IPNet
	SrcIP     net.IP
	SrcMAC    net.HardwareAddr
	Ports     []*PortRange
}

type RateLimiter added in v0.2.0

type RateLimiter interface {
	// Take should block to make sure that the RPS is met.
	Take() time.Time
}

type Request

type Request struct {
	Meta    map[string]interface{}
	SrcIP   net.IP
	DstIP   net.IP
	SrcMAC  []byte
	DstMAC  []byte
	DstPort uint16
	Err     error
}

type RequestGenerator

type RequestGenerator interface {
	GenerateRequests(ctx context.Context, r *Range) (<-chan *Request, error)
}

func NewFileIPPortGenerator

func NewFileIPPortGenerator(openFile OpenFileFunc) RequestGenerator

func NewFilterIPRequestGenerator added in v0.2.0

func NewFilterIPRequestGenerator(delegate RequestGenerator, excludeIPs IPContainer) RequestGenerator

func NewIPPortGenerator

func NewIPPortGenerator(ipgen IPGenerator, portgen PortGenerator) RequestGenerator

func NewIPRequestGenerator

func NewIPRequestGenerator(ipgen IPGenerator) RequestGenerator

func NewLiveRequestGenerator

func NewLiveRequestGenerator(rg RequestGenerator, rescanTimeout time.Duration) RequestGenerator

type Result

type Result interface {
	fmt.Stringer
	json.Marshaler
	ID() string
}

type ResultChan

type ResultChan interface {
	Put(r Result)
	Chan() <-chan Result
}

func NewResultChan

func NewResultChan(ctx context.Context, capacity int) ResultChan

type Resulter

type Resulter interface {
	Results() <-chan Result
}

type Scanner

type Scanner interface {
	Scan(ctx context.Context, r *Request) (Result, error)
}

func NewRateLimitScanner added in v0.2.0

func NewRateLimitScanner(delegate Scanner, limiter RateLimiter) Scanner

type WrapIP

type WrapIP net.IP

func (WrapIP) GetIP

func (i WrapIP) GetIP() (net.IP, error)

type WrapPort added in v0.3.0

type WrapPort uint16

func (WrapPort) GetPort added in v0.3.0

func (p WrapPort) GetPort() (uint16, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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