geo

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_internal_geo_geo_proto protoreflect.FileDescriptor

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 AtomicDomainSetConfig

type AtomicDomainSetConfig struct {
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// either one of the following two fields should be set
	Domains []*geo.Domain  `protobuf:"bytes,2,rep,name=domains,proto3" json:"domains,omitempty"`
	Geosite *GeositeConfig `protobuf:"bytes,3,opt,name=geosite,proto3" json:"geosite,omitempty"`
	// contains filtered or unexported fields
}

func (*AtomicDomainSetConfig) Descriptor deprecated

func (*AtomicDomainSetConfig) Descriptor() ([]byte, []int)

Deprecated: Use AtomicDomainSetConfig.ProtoReflect.Descriptor instead.

func (*AtomicDomainSetConfig) GetDomains

func (x *AtomicDomainSetConfig) GetDomains() []*geo.Domain

func (*AtomicDomainSetConfig) GetGeosite

func (x *AtomicDomainSetConfig) GetGeosite() *GeositeConfig

func (*AtomicDomainSetConfig) GetName

func (x *AtomicDomainSetConfig) GetName() string

func (*AtomicDomainSetConfig) ProtoMessage

func (*AtomicDomainSetConfig) ProtoMessage()

func (*AtomicDomainSetConfig) ProtoReflect

func (x *AtomicDomainSetConfig) ProtoReflect() protoreflect.Message

func (*AtomicDomainSetConfig) Reset

func (x *AtomicDomainSetConfig) Reset()

func (*AtomicDomainSetConfig) String

func (x *AtomicDomainSetConfig) String() string

type AtomicIPSetConfig

type AtomicIPSetConfig struct {
	Name  string       `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
	Cidrs []*geo.CIDR  `protobuf:"bytes,2,rep,name=cidrs,proto3" json:"cidrs,omitempty"`
	Geoip *GeoIPConfig `protobuf:"bytes,1,opt,name=geoip,proto3" json:"geoip,omitempty"`
	// contains filtered or unexported fields
}

func (*AtomicIPSetConfig) Descriptor deprecated

func (*AtomicIPSetConfig) Descriptor() ([]byte, []int)

Deprecated: Use AtomicIPSetConfig.ProtoReflect.Descriptor instead.

func (*AtomicIPSetConfig) GetCidrs

func (x *AtomicIPSetConfig) GetCidrs() []*geo.CIDR

func (*AtomicIPSetConfig) GetGeoip

func (x *AtomicIPSetConfig) GetGeoip() *GeoIPConfig

func (*AtomicIPSetConfig) GetName

func (x *AtomicIPSetConfig) GetName() string

func (*AtomicIPSetConfig) ProtoMessage

func (*AtomicIPSetConfig) ProtoMessage()

func (*AtomicIPSetConfig) ProtoReflect

func (x *AtomicIPSetConfig) ProtoReflect() protoreflect.Message

func (*AtomicIPSetConfig) Reset

func (x *AtomicIPSetConfig) Reset()

func (*AtomicIPSetConfig) String

func (x *AtomicIPSetConfig) String() string

type Config

type Config struct {
	GreatDomainSets  []*GreatDomainSetConfig  `protobuf:"bytes,3,rep,name=great_domain_sets,json=greatDomainSets,proto3" json:"great_domain_sets,omitempty"`
	GreatIpSets      []*GreatIPSetConfig      `protobuf:"bytes,4,rep,name=great_ip_sets,json=greatIpSets,proto3" json:"great_ip_sets,omitempty"`
	AtomicDomainSets []*AtomicDomainSetConfig `protobuf:"bytes,5,rep,name=atomic_domain_sets,json=atomicDomainSets,proto3" json:"atomic_domain_sets,omitempty"`
	AtomicIpSets     []*AtomicIPSetConfig     `protobuf:"bytes,6,rep,name=atomic_ip_sets,json=atomicIpSets,proto3" json:"atomic_ip_sets,omitempty"`
	// contains filtered or unexported fields
}

func (*Config) Descriptor deprecated

func (*Config) Descriptor() ([]byte, []int)

Deprecated: Use Config.ProtoReflect.Descriptor instead.

func (*Config) GetAtomicDomainSets

func (x *Config) GetAtomicDomainSets() []*AtomicDomainSetConfig

func (*Config) GetAtomicIpSets

func (x *Config) GetAtomicIpSets() []*AtomicIPSetConfig

func (*Config) GetGreatDomainSets

func (x *Config) GetGreatDomainSets() []*GreatDomainSetConfig

func (*Config) GetGreatIpSets

func (x *Config) GetGreatIpSets() []*GreatIPSetConfig

func (*Config) ProtoMessage

func (*Config) ProtoMessage()

func (*Config) ProtoReflect

func (x *Config) ProtoReflect() protoreflect.Message

func (*Config) Reset

func (x *Config) Reset()

func (*Config) String

func (x *Config) String() string

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 *cgeo.Domain) error

if the domain set is not found, do nothing

func (*Geo) MatchAppId

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

func (*Geo) MatchDomain

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

func (*Geo) MatchIP

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

func (*Geo) RemoveDomain

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

type GeoIPConfig

type GeoIPConfig struct {
	Filepath string   `protobuf:"bytes,1,opt,name=filepath,proto3" json:"filepath,omitempty"`
	Codes    []string `protobuf:"bytes,2,rep,name=codes,proto3" json:"codes,omitempty"`
	Inverse  bool     `protobuf:"varint,3,opt,name=inverse,proto3" json:"inverse,omitempty"`
	// contains filtered or unexported fields
}

func (*GeoIPConfig) Descriptor deprecated

func (*GeoIPConfig) Descriptor() ([]byte, []int)

Deprecated: Use GeoIPConfig.ProtoReflect.Descriptor instead.

func (*GeoIPConfig) GetCodes

func (x *GeoIPConfig) GetCodes() []string

func (*GeoIPConfig) GetFilepath

func (x *GeoIPConfig) GetFilepath() string

func (*GeoIPConfig) GetInverse

func (x *GeoIPConfig) GetInverse() bool

func (*GeoIPConfig) ProtoMessage

func (*GeoIPConfig) ProtoMessage()

func (*GeoIPConfig) ProtoReflect

func (x *GeoIPConfig) ProtoReflect() protoreflect.Message

func (*GeoIPConfig) Reset

func (x *GeoIPConfig) Reset()

func (*GeoIPConfig) String

func (x *GeoIPConfig) String() string

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

func (*GeoWrapper) MatchDomain

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

func (*GeoWrapper) MatchIP

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

func (*GeoWrapper) UpdateGeo

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

type GeositeConfig

type GeositeConfig struct {
	Codes      []string `protobuf:"bytes,1,rep,name=codes,proto3" json:"codes,omitempty"`
	Attributes []string `protobuf:"bytes,2,rep,name=attributes,proto3" json:"attributes,omitempty"`
	Filepath   string   `protobuf:"bytes,3,opt,name=filepath,proto3" json:"filepath,omitempty"`
	// contains filtered or unexported fields
}

func (*GeositeConfig) Descriptor deprecated

func (*GeositeConfig) Descriptor() ([]byte, []int)

Deprecated: Use GeositeConfig.ProtoReflect.Descriptor instead.

func (*GeositeConfig) GetAttributes

func (x *GeositeConfig) GetAttributes() []string

func (*GeositeConfig) GetCodes

func (x *GeositeConfig) GetCodes() []string

func (*GeositeConfig) GetFilepath

func (x *GeositeConfig) GetFilepath() string

func (*GeositeConfig) ProtoMessage

func (*GeositeConfig) ProtoMessage()

func (*GeositeConfig) ProtoReflect

func (x *GeositeConfig) ProtoReflect() protoreflect.Message

func (*GeositeConfig) Reset

func (x *GeositeConfig) Reset()

func (*GeositeConfig) String

func (x *GeositeConfig) String() string

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 GreatDomainSetConfig

type GreatDomainSetConfig struct {
	Name         string   `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
	OppositeName string   `protobuf:"bytes,4,opt,name=opposite_name,json=oppositeName,proto3" json:"opposite_name,omitempty"`
	ExNames      []string `protobuf:"bytes,5,rep,name=ex_names,json=exNames,proto3" json:"ex_names,omitempty"`
	InNames      []string `protobuf:"bytes,6,rep,name=in_names,json=inNames,proto3" json:"in_names,omitempty"`
	// contains filtered or unexported fields
}

func (*GreatDomainSetConfig) Descriptor deprecated

func (*GreatDomainSetConfig) Descriptor() ([]byte, []int)

Deprecated: Use GreatDomainSetConfig.ProtoReflect.Descriptor instead.

func (*GreatDomainSetConfig) GetExNames

func (x *GreatDomainSetConfig) GetExNames() []string

func (*GreatDomainSetConfig) GetInNames

func (x *GreatDomainSetConfig) GetInNames() []string

func (*GreatDomainSetConfig) GetName

func (x *GreatDomainSetConfig) GetName() string

func (*GreatDomainSetConfig) GetOppositeName

func (x *GreatDomainSetConfig) GetOppositeName() string

func (*GreatDomainSetConfig) ProtoMessage

func (*GreatDomainSetConfig) ProtoMessage()

func (*GreatDomainSetConfig) ProtoReflect

func (x *GreatDomainSetConfig) ProtoReflect() protoreflect.Message

func (*GreatDomainSetConfig) Reset

func (x *GreatDomainSetConfig) Reset()

func (*GreatDomainSetConfig) String

func (x *GreatDomainSetConfig) String() string

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 GreatIPSetConfig

type GreatIPSetConfig struct {
	Name         string   `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
	OppositeName string   `protobuf:"bytes,4,opt,name=opposite_name,json=oppositeName,proto3" json:"opposite_name,omitempty"`
	ExNames      []string `protobuf:"bytes,5,rep,name=ex_names,json=exNames,proto3" json:"ex_names,omitempty"`
	InNames      []string `protobuf:"bytes,6,rep,name=in_names,json=inNames,proto3" json:"in_names,omitempty"`
	// contains filtered or unexported fields
}

func (*GreatIPSetConfig) Descriptor deprecated

func (*GreatIPSetConfig) Descriptor() ([]byte, []int)

Deprecated: Use GreatIPSetConfig.ProtoReflect.Descriptor instead.

func (*GreatIPSetConfig) GetExNames

func (x *GreatIPSetConfig) GetExNames() []string

func (*GreatIPSetConfig) GetInNames

func (x *GreatIPSetConfig) GetInNames() []string

func (*GreatIPSetConfig) GetName

func (x *GreatIPSetConfig) GetName() string

func (*GreatIPSetConfig) GetOppositeName

func (x *GreatIPSetConfig) GetOppositeName() string

func (*GreatIPSetConfig) ProtoMessage

func (*GreatIPSetConfig) ProtoMessage()

func (*GreatIPSetConfig) ProtoReflect

func (x *GreatIPSetConfig) ProtoReflect() protoreflect.Message

func (*GreatIPSetConfig) Reset

func (x *GreatIPSetConfig) Reset()

func (*GreatIPSetConfig) String

func (x *GreatIPSetConfig) String() string

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 ...*geo.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