dns

package
v0.0.0-...-7893bb9 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DNSTypeStatic = "static"
	DNSTypeDirect = "direct"
	DNSTypeRemote = "remote"
	DNSTypeCache  = "cache"

	MatchTypeDomainSuffix  = "DOMAIN-SUFFIX"
	MatchTypeDomain        = "DOMAIN"
	MatchTypeDomainKeyword = "DOMAIN-KEYWORD"
	MatchNone              = "NONE"
)
View Source
const CacheTTL = 10 * time.Minute

Variables

This section is empty.

Functions

func ApplyConfig

func ApplyConfig(config IDNSConfig) error

func ClearDNSCache

func ClearDNSCache()

func CloseGeoDB

func CloseGeoDB() error

func GeoLookUp

func GeoLookUp(ip string) (countryCode string)

func InitDNSCache

func InitDNSCache()

func InitGeoIP

func InitGeoIP(dbFile string) error

func Pop

func Pop(h heap.Interface) interface{}

Pop removes the minimum element (according to Less) from the heap and returns it. The complexity is O(log(n)) where n = h.Len(). It is equivalent to Remove(h, 0).

func Push

func Push(h heap.Interface, x interface{})

Push pushes the element x onto the heap. The complexity is O(log(n)) where n = h.Len().

Types

type Answer

type Answer struct {
	MatchType string
	Domain    string
	IPs       []string
	Server    string
	Port      string
	Type      string
	Country   string
	Duration  time.Duration
}

func DNSCacheList

func DNSCacheList() []*Answer

func ResolveDomain

func ResolveDomain(domain string) (answer *Answer, err error)

resolve domain

func ResolveDomainByCache

func ResolveDomainByCache(domain string) (*Answer, error)

resolve domain and through the DNS-Cache

func ResolveIP

func ResolveIP(ip string) (*Answer, error)

resolve ip

func (*Answer) GetIP

func (a *Answer) GetIP() string

type CacheEntity

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

type CacheManager

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

func NewCacheManager

func NewCacheManager() *CacheManager

func (*CacheManager) Clear

func (c *CacheManager) Clear()

func (*CacheManager) Push

func (c *CacheManager) Push(data interface{}, ttl time.Duration)

func (*CacheManager) Range

func (c *CacheManager) Range(f func(data interface{}) (breaked bool)) interface{}

func (*CacheManager) Run

func (c *CacheManager) Run()

func (*CacheManager) Stop

func (c *CacheManager) Stop()

type CachePool

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

func NewCachePool

func NewCachePool() *CachePool

func (*CachePool) Clear

func (c *CachePool) Clear()

func (*CachePool) Head

func (c *CachePool) Head() *CacheEntity

func (*CachePool) Len

func (c *CachePool) Len() int

func (*CachePool) Less

func (c *CachePool) Less(i, j int) bool

func (*CachePool) Pop

func (c *CachePool) Pop() interface{}

func (*CachePool) Push

func (c *CachePool) Push(x interface{})

func (*CachePool) Range

func (c *CachePool) Range(f func(data interface{}) (breaked bool)) interface{}

func (*CachePool) Swap

func (c *CachePool) Swap(i, j int)

type DNS

type DNS struct {
	MatchType string
	Domain    string
	IPs       []string
	DNSs      []string
	Port      string
	Type      string
	Country   string
}

func (*DNS) String

func (d *DNS) String() string

type DNSConfig

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

type IDNSConfig

type IDNSConfig interface {
	GetDNSServers() []string
	SetDNSServers([]string)
	GetLocalDNS() [][]string
	SetLocalDNS([][]string)

	GetControllerDomain() string
	GetControllerPort() string

	GetGeoIPDBFile() string
}

Jump to

Keyboard shortcuts

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