geo

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSetNotFound = errors.New("set not found")

Functions

func AppSetConfigToAppSet

func AppSetConfigToAppSet(c *configs.AppSetConfig, l loader) (i.AppSet, error)

func AtomicDomainSetToIndexMatcher

func AtomicDomainSetToIndexMatcher(atomicSet *configs.AtomicDomainSetConfig, l loader) (strmatcher.IndexMatcher, error)

func AtomicIpSetToIPMatcher

func AtomicIpSetToIPMatcher(c *configs.AtomicIPSetConfig, l loader) (*cgeo.IPMatcher, error)

func GeoIpConfigToCidrs

func GeoIpConfigToCidrs(config *configs.GeoIPConfig, l loader) ([]*cgeo.CIDR, error)

func GeositeConfigToGeoDomains

func GeositeConfigToGeoDomains(c *configs.GeositeConfig, l loader) ([]*cgeo.Domain, error)

func ToStrMatcher

func ToStrMatcher(d *configs.AppId) (strmatcher.Matcher, error)

Types

type AppSet

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

func NewAppSet

func NewAppSet(tags []string, h i.GeoHelper, appIds ...*configs.AppId) (*AppSet, error)

func (*AppSet) Match

func (a *AppSet) Match(appId string) bool

type DomainSet

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

func NewDomainSet

func NewDomainSet(tags []string, h i.GeoHelper, domains ...*geo.Domain) (*DomainSet, error)

func (*DomainSet) Match

func (d *DomainSet) Match(domain string) bool

type Geo

type Geo struct {
	// domain
	OppositeDomainTags map[string]string
	DomainSets         map[string]i.DomainSet
	// ip
	OppositeIpTags map[string]string
	IpSets         map[string]i.IPSet
	// app
	AppSets map[string]i.AppSet
}

func NewGeo

func NewGeo(config *configs.GeoConfig) (*Geo, error)

func (*Geo) AddDomain

func (g *Geo) AddDomain(name string, domain *commongeo.Domain) error

if the domain set is not found, do nothing

func (*Geo) MatchAppId

func (g *Geo) MatchAppId(appId string, tag string) (bool, error)

func (*Geo) MatchDomain

func (g *Geo) MatchDomain(domain string, tag string) (bool, error)

func (*Geo) MatchIP

func (g *Geo) MatchIP(ip net.IP, tag string) (bool, error)

func (*Geo) RemoveDomain

func (g *Geo) RemoveDomain(name string, domain *commongeo.Domain) error

type GeoWrapper

type GeoWrapper struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*GeoWrapper) AddDomainSet

func (g *GeoWrapper) AddDomainSet(name string, set i.DomainSet)

func (*GeoWrapper) AddIPSet

func (g *GeoWrapper) AddIPSet(name string, set i.IPSet)

func (*GeoWrapper) GetGeo

func (g *GeoWrapper) GetGeo() *Geo

func (*GeoWrapper) MatchAppId

func (g *GeoWrapper) MatchAppId(appId string, tag string) (bool, error)

func (*GeoWrapper) MatchDomain

func (g *GeoWrapper) MatchDomain(domain string, tag string) (bool, error)

func (*GeoWrapper) MatchIP

func (g *GeoWrapper) MatchIP(ip net.IP, tag string) (bool, error)

func (*GeoWrapper) UpdateGeo

func (g *GeoWrapper) UpdateGeo(geoConfig *configs.GeoConfig) error

type GreatDomainSet

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

func NewGreatDomainSet

func NewGreatDomainSet(im []string, es []string, geo i.GeoHelper) *GreatDomainSet

func (*GreatDomainSet) Match

func (d *GreatDomainSet) Match(domain string) bool

type GreatIPSet

type GreatIPSet struct {
	InMatchers ipSets
	ExMatcher  ipSets
}

func NewGreatIPSet

func NewGreatIPSet(im []i.IPSet, es []i.IPSet) *GreatIPSet

func (*GreatIPSet) Match

func (l *GreatIPSet) Match(ip net.IP) bool

type IndexMatcherToDomainSet

type IndexMatcherToDomainSet struct {
	strmatcher.IndexMatcher
	// contains filtered or unexported fields
}

func (*IndexMatcherToDomainSet) Match

func (i *IndexMatcherToDomainSet) Match(domain string) bool

type IpSet

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

func NewIPSet

func NewIPSet(tags []string, h i.GeoHelper, cidrs ...*commongeo.CIDR) (*IpSet, error)

func (*IpSet) Match

func (i *IpSet) Match(ip net.IP) bool

type NullDomainSet

type NullDomainSet struct{}

func (*NullDomainSet) Match

func (d *NullDomainSet) Match(domain string) bool

type StrmatcherToAppSet

type StrmatcherToAppSet struct {
	strmatcher.IndexMatcher
}

func (*StrmatcherToAppSet) Match

func (m *StrmatcherToAppSet) Match(appId string) bool

Jump to

Keyboard shortcuts

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