ipam

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccessPolicyDefault = iota
	// AccessPolicyInternetOnly allows peer to access only
	// internet resources but not its network neighbours.
	AccessPolicyInternetOnly
	// AccessPolicyAllowAll allows peer to access internet resources
	// as well ass connecting to their network neighbours.
	// This is a trusted policy.
	AccessPolicyAllowAll
)
View Source
const (
	// Block ports from specified port range, allowing all others
	RestrictionModeBlockList = iota
	// Allow ports from specified port range, blocking all owhers
	RestrictionModeAllowList
)
View Source
const (
	Bitps  Rate = 1
	Kbitps      = Bitps * 1000
	Mbitps      = Kbitps * 1000
	Gbitps      = Mbitps * 1000
)

Variables

This section is empty.

Functions

func AliasAllowAll added in v0.2.5

func AliasAllowAll() accessPolicy

func AliasInternetOnly added in v0.2.5

func AliasInternetOnly() accessPolicy

Types

type Config added in v0.2.5

type Config struct {
	Subnet           *xnet.IPNet
	Interface        string
	AccessPolicy     NetworkAccess
	RateLimiter      *RateLimiterConfig
	PortRestrictions *PortRestrictionConfig
}

type IPAM added in v0.2.5

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

IPAM implements IP Address Manager and provides the following features:

  • assigns IP addresses for peers;
  • implements network policies using netfilter rules;
  • limits the available bandwidth using traffic control rules;

func New

func New(cfg Config) (*IPAM, error)

func (*IPAM) Alloc added in v0.2.5

func (m *IPAM) Alloc(pol Policy) (xnet.IP, error)

func (*IPAM) Available added in v0.2.5

func (m *IPAM) Available() (xnet.IP, error)

func (*IPAM) IsAvailable added in v0.2.5

func (m *IPAM) IsAvailable(addr xnet.IP) bool

func (*IPAM) Running added in v0.2.5

func (m *IPAM) Running() bool

func (*IPAM) Set added in v0.2.5

func (m *IPAM) Set(addr xnet.IP, pol Policy) error

func (*IPAM) Shutdown added in v0.2.5

func (m *IPAM) Shutdown() error

func (*IPAM) Unset added in v0.2.5

func (m *IPAM) Unset(addr xnet.IP) error

type ListMode added in v0.3.3

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

func (ListMode) AllowList added in v0.3.3

func (mode ListMode) AllowList() bool

func (ListMode) BlockList added in v0.3.3

func (mode ListMode) BlockList() bool

func (ListMode) Int added in v0.3.3

func (mode ListMode) Int() int

func (ListMode) MarshalText added in v0.3.3

func (mode ListMode) MarshalText() ([]byte, error)

func (ListMode) String added in v0.3.3

func (mode ListMode) String() string

func (*ListMode) UnmarshalText added in v0.3.3

func (mode *ListMode) UnmarshalText(raw []byte) error

type NetworkAccess added in v0.2.5

type NetworkAccess struct {
	DefaultPolicy accessPolicy `yaml:"default_policy,omitempty"`
}

type Policy added in v0.2.5

type Policy struct {
	Access    int
	RateLimit Rate
}

Policy define peer's network access rules. What peer it can talk to, and on what bandwidth.

type PortRange added in v0.3.3

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

func (PortRange) MarshalText added in v0.3.3

func (rng PortRange) MarshalText() ([]byte, error)

func (*PortRange) UnmarshalText added in v0.3.3

func (rng *PortRange) UnmarshalText(raw []byte) error

type PortRestrictionConfig added in v0.3.3

type PortRestrictionConfig struct {
	UDP ProtocolPortConfig `yaml:"udp,omitempty"`
	TCP ProtocolPortConfig `yaml:"tcp,omitempty"`
}

func DefaultPortRestrictions added in v0.3.3

func DefaultPortRestrictions() *PortRestrictionConfig

type ProtocolPortConfig added in v0.3.3

type ProtocolPortConfig struct {
	Mode  ListMode    `yaml:"mode"`
	Ports []PortRange `yaml:"range,omitempty"`
}

type Rate added in v0.2.5

type Rate uint64

Rate represents the desired bandwidth, keep in mind that values must follow SI, not IEC.

func (Rate) String added in v0.2.5

func (r Rate) String() string

func (*Rate) UnmarshalText added in v0.2.5

func (r *Rate) UnmarshalText(raw []byte) error

type RateLimiterConfig added in v0.2.5

type RateLimiterConfig struct {
	TotalBandwidth Rate `yaml:"total_bandwidth,omitempty"`
}

Jump to

Keyboard shortcuts

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