processor

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package processor contains processor to get CIDRs network's relation.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotIPv4 = errors.New("not an IPv4 IP")

ErrNotIPv4 when given IP is not an IPv4.

Functions

This section is empty.

Types

type NetworkRelation

type NetworkRelation string

NetworkRelation for network relations.

const (
	SubsetRelation    NetworkRelation = "subset"
	SupersetRelation  NetworkRelation = "superset"
	DifferentRelation NetworkRelation = "different"
	SameRelation      NetworkRelation = "same"
)

Network possible relations.

type Processor

type Processor struct{}

Processor check the relation between two CIDRs.

func NewProcessor

func NewProcessor() *Processor

NewProcessor returns a new instance of Processor.

func (*Processor) GetOverlapRelation

func (p *Processor) GetOverlapRelation(cidrA, cidrB string) (NetworkRelation, error)

GetOverlapRelation check the relation between two CIDRs The relation can be: subset: if the network of the second address is included in the first one superset: if the network of the second address includes the first one different: if the two networks are not overlapping same: if both address are in the same network Returns relation or an error if given IP is not an IPv4.

Jump to

Keyboard shortcuts

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