ippool

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: May 3, 2022 License: Apache-2.0 Imports: 6 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 Filter

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

the struct that contains array of filgerElements

func (*Filter) Add

func (f *Filter) Add(pool *Pool, srvpool *ServerPool)

i don't know that to say

func (*Filter) WhatPool

func (f *Filter) WhatPool(ip string) (*ServerPool, error)

search what pool 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 Server

type Server struct {
	Addr     netip.Addr
	Broken   bool
	Weight   int
	Priority int

	MaxFails                 int
	AvgDataExchangeTime      int64
	AvgConnectTime           int64
	ConnectionsNumber        int
	CurrentConnectionsNumber int
	// contains filtered or unexported fields
}

func NewServer

func NewServer(addr netip.Addr, weight, maxFails, breakTime int) *Server

func (*Server) Connect

func (s *Server) Connect(proto, port string) (net.Conn, int64, error)

func (*Server) Disconnect

func (s *Server) Disconnect(conn net.Conn) error

func (*Server) ExchangeData

func (s *Server) ExchangeData(client net.Conn, server net.Conn) (int64, int, int, error)

func (*Server) Fail

func (s *Server) Fail()

func (*Server) SetConfig

func (s *Server) SetConfig(weight, maxFails, breakTime string) error

type ServerPool

type ServerPool struct {
	Servers []Server
}

the struct that keep servers addresses contain only IP addresses

func NewServerPool

func NewServerPool(m map[string]interface{}) (*ServerPool, error)

create and return new ServerPool

func (*ServerPool) Add

func (p *ServerPool) Add(addresses string, config map[string]interface{}) error

add IP address in servers pool

func (*ServerPool) AddFromMap

func (p *ServerPool) AddFromMap(m map[string]interface{}) 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) SetConfig

func (p *ServerPool) SetConfig(weight, maxFails, breakTime string) error

Jump to

Keyboard shortcuts

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