Documentation ¶
Index ¶
- Variables
- func GetDefaultPhantomSubnets() *pb.PhantomSubnetsList
- func GetUnweightedSubnetList(subnetsList *pb.PhantomSubnetsList) ([]*phantomNet, error)
- func SelectAddrFromSubnet(seed []byte, net1 *net.IPNet) (net.IP, error)
- func V4Only(obj []*phantomNet) ([]*phantomNet, error)
- func V6Only(obj []*phantomNet) ([]*phantomNet, error)
- type PhantomIP
- func IP(ip net.IP, supportRandomPort bool) *PhantomIP
- func SelectPhantom(seed []byte, subnetsList *pb.PhantomSubnetsList, transform SubnetFilter, ...) (*PhantomIP, error)
- func SelectPhantomUnweighted(seed []byte, subnets *pb.PhantomSubnetsList, transform SubnetFilter) (*PhantomIP, error)
- func SelectPhantomWeighted(seed []byte, subnets *pb.PhantomSubnetsList, transform SubnetFilter) (*PhantomIP, error)
- type PhantomIPSelector
- func (p *PhantomIPSelector) AddGeneration(gen int, subnets *SubnetConfig) uint
- func (p *PhantomIPSelector) GetSubnetsByGeneration(generation uint) *SubnetConfig
- func (p *PhantomIPSelector) IsTakenGeneration(gen uint) bool
- func (p *PhantomIPSelector) RemoveGeneration(generation uint) bool
- func (p *PhantomIPSelector) Select(seed []byte, generation uint, clientLibVer uint, v6Support bool) (*PhantomIP, error)
- func (p *PhantomIPSelector) UpdateGeneration(generation uint, subnets *SubnetConfig) bool
- type SubnetConfig
- type SubnetFilter
Constants ¶
This section is empty.
Variables ¶
var ( // ErrLegacyAddrSelectBug indicates that we have hit a corner case in a legacy address selection // algorithm that causes phantom address selection to fail. ErrLegacyAddrSelectBug = errors.New("no valid addresses specified") ErrLegacyMissingAddrs = errors.New("No valid addresses specified") ErrLegacyV0SelectionBug = errors.New("let's rewrite the phantom address selector") // ErrMissingAddrs indicates that no subnets were provided with addresses to select from. This // is only valid for phantomHkdfMinVersion and newer. ErrMissingAddrs = errors.New("no valid addresses specified to select") )
Functions ¶
func GetDefaultPhantomSubnets ¶
func GetDefaultPhantomSubnets() *pb.PhantomSubnetsList
GetDefaultPhantomSubnets implements the
func GetUnweightedSubnetList ¶
func GetUnweightedSubnetList(subnetsList *pb.PhantomSubnetsList) ([]*phantomNet, error)
GetUnweightedSubnetList returns the list of subnets provided by the protobuf. Convenience function to not have to export getSubnets() or parseSubnets()
func SelectAddrFromSubnet ¶ added in v0.7.5
SelectAddrFromSubnet - given a seed and a CIDR block choose an address.
This is done by generating a seeded random bytes up to the length of the full address then using the net mask to zero out any bytes that are already specified by the CIDR block. Tde masked random value is then added to the cidr block base giving the final randomly selected address.
Types ¶
type PhantomIP ¶ added in v0.6.5
type PhantomIP struct {
// contains filtered or unexported fields
}
func SelectPhantom ¶
func SelectPhantom(seed []byte, subnetsList *pb.PhantomSubnetsList, transform SubnetFilter, weighted bool) (*PhantomIP, error)
SelectPhantom - select one phantom IP address based on shared secret
func SelectPhantomUnweighted ¶
func SelectPhantomUnweighted(seed []byte, subnets *pb.PhantomSubnetsList, transform SubnetFilter) (*PhantomIP, error)
SelectPhantomUnweighted - select one phantom IP address based on shared secret
func SelectPhantomWeighted ¶
func SelectPhantomWeighted(seed []byte, subnets *pb.PhantomSubnetsList, transform SubnetFilter) (*PhantomIP, error)
SelectPhantomWeighted - select one phantom IP address based on shared secret
func (*PhantomIP) SupportRandomPort ¶ added in v0.6.5
type PhantomIPSelector ¶ added in v0.7.5
type PhantomIPSelector struct {
Networks map[uint]*SubnetConfig
}
PhantomIPSelector - Object for tracking current generation to SubnetConfig Mapping.
func GetPhantomSubnetSelector ¶ added in v0.7.5
func GetPhantomSubnetSelector() (*PhantomIPSelector, error)
GetPhantomSubnetSelector gets the location of the configuration file from an environment variable and returns the parsed configuration.
func NewPhantomIPSelector ¶ added in v0.7.5
func NewPhantomIPSelector() (*PhantomIPSelector, error)
NewPhantomIPSelector - create object currently populated with a static map of generation number to SubnetConfig, but this may be loaded dynamically in the future.
func SubnetsFromTomlFile ¶ added in v0.7.5
func SubnetsFromTomlFile(path string) (*PhantomIPSelector, error)
SubnetsFromTomlFile takes a path and parses the toml config file
func (*PhantomIPSelector) AddGeneration ¶ added in v0.7.5
func (p *PhantomIPSelector) AddGeneration(gen int, subnets *SubnetConfig) uint
AddGeneration - add a subnet config as a new new generation, if the requested generation index is taken then it uses (and returns) the next available number.
func (*PhantomIPSelector) GetSubnetsByGeneration ¶ added in v0.7.5
func (p *PhantomIPSelector) GetSubnetsByGeneration(generation uint) *SubnetConfig
GetSubnetsByGeneration - provide a generation index. If the generation exists the associated SubnetConfig is returned. If it is not defined the default subnets are returned.
func (*PhantomIPSelector) IsTakenGeneration ¶ added in v0.7.5
func (p *PhantomIPSelector) IsTakenGeneration(gen uint) bool
IsTakenGeneration - check if the generation index is already in use.
func (*PhantomIPSelector) RemoveGeneration ¶ added in v0.7.5
func (p *PhantomIPSelector) RemoveGeneration(generation uint) bool
RemoveGeneration - remove a generation from the mapping
func (*PhantomIPSelector) Select ¶ added in v0.7.5
func (p *PhantomIPSelector) Select(seed []byte, generation uint, clientLibVer uint, v6Support bool) (*PhantomIP, error)
Select - select an ip address from the list of subnets associated with the specified generation
func (*PhantomIPSelector) UpdateGeneration ¶ added in v0.7.5
func (p *PhantomIPSelector) UpdateGeneration(generation uint, subnets *SubnetConfig) bool
UpdateGeneration - Update the subnet list associated with a specific generation
type SubnetConfig ¶ added in v0.7.5
type SubnetConfig struct {
WeightedSubnets []*pb.PhantomSubnets
}
SubnetConfig - Configuration of subnets for Conjure to choose a Phantom out of.
func (*SubnetConfig) GetWeightedSubnets ¶ added in v0.7.5
func (sc *SubnetConfig) GetWeightedSubnets() []*pb.PhantomSubnets
type SubnetFilter ¶
type SubnetFilter func([]*phantomNet) ([]*phantomNet, error)
SubnetFilter - Filter IP subnets based on whatever to prevent specific subnets from
inclusion in choice. See v4Only and v6Only for reference.