ippool

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateIPRange

func CreateIPRange(iprange string) ([]netip.Addr, error)

create array of IP addresses from IP range for example "192.168.0-1.1-5" will converted to [192.168.0.1 192.168.0.2 192.168.0.3 192.168.0.4 192.168.0.5 192.168.1.1 192.168.1.2 192.168.1.3 192.168.1.4 192.168.1.5]

Types

type BalancingMethod

type BalancingMethod interface {
	Find(ip string, p *ServerPool) (string, error)
}

Find - return the server that should handle request

type Pool

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

the struct that keep clients addresses caontain IP addresses "192.168.0.1" and IP networks "192.168.0.0/24"

func NewPool

func NewPool(ip ...string) (*Pool, error)

create and return new Pool

func (*Pool) Add

func (p *Pool) Add(ip string) error

add IP or IP range or network to the pool

func (*Pool) AddArr

func (ar *Pool) AddArr(arr []string) error

add IP or IP range or network to the pool from range of strings

func (*Pool) Conatains

func (p *Pool) Conatains(searchIP string) (bool, error)

check the IP addresse in pool or not return true if pool contain IP or pool contain networm what contain ip

func (*Pool) String

func (ar *Pool) String() string

display all IP addresses and networks

type ServerPool

type ServerPool struct {
	Servers []netip.Addr
}

the struct that keep servers addresses contain only IP addresses

func NewServerPool

func NewServerPool(ip ...string) (*ServerPool, error)

create and return new ServerPool

func (*ServerPool) Add

func (p *ServerPool) Add(a string) error

add IP address in servers pool

func (*ServerPool) AddArr

func (p *ServerPool) AddArr(arr []string) error

add IP address in servers pool from array

func (*ServerPool) Contains

func (p *ServerPool) Contains(searchIP string) (bool, error)

check the server IP in pool or not return true if pool contain IP

func (*ServerPool) String

func (p *ServerPool) String() string

display all servers IP

func (*ServerPool) WhatServer

func (p *ServerPool) WhatServer(ip string, bm BalancingMethod) (string, error)

check that server should handle request

Jump to

Keyboard shortcuts

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