dns

package
v0.0.0-...-46ed21b Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

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

Handler 实现DNS请求处理器

func NewHandler

func NewHandler(server *Server) *Handler

NewHandler 创建一个新的DNS处理器

func (*Handler) ServeDNS

func (h *Handler) ServeDNS(w dns.ResponseWriter, r *dns.Msg)

ServeDNS 处理DNS请求

type Server

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

Server 表示DNS服务器

func NewServer

func NewServer(cfg *config.Config) (*Server, error)

NewServer 创建一个新的DNS服务器实例

func (*Server) GetRecordStore

func (s *Server) GetRecordStore() *remote.RecordStore

GetRecordStore 获取记录存储

func (*Server) Resolve

func (s *Server) Resolve(ctx context.Context, domain string, qtype uint16) ([]net.IP, error)

Resolve 解析DNS查询(只使用系统解析器)

func (*Server) ResolveWithSource

func (s *Server) ResolveWithSource(ctx context.Context, domain string, qtype uint16, sourceIP net.IP) ([]net.IP, error)

ResolveWithSource 根据源IP解析DNS查询

func (*Server) Start

func (s *Server) Start() error

Start 启动DNS服务器

func (*Server) Stop

func (s *Server) Stop() error

Stop 停止DNS服务器

type UpstreamCache

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

UpstreamCache 上游DNS查询缓存(独立于记录表)

func NewUpstreamCache

func NewUpstreamCache(maxSize int, defaultTTL time.Duration) *UpstreamCache

NewUpstreamCache 创建上游缓存

func (*UpstreamCache) Clear

func (c *UpstreamCache) Clear()

Clear 清空缓存

func (*UpstreamCache) Count

func (c *UpstreamCache) Count() int

Count 返回缓存数量

func (*UpstreamCache) Delete

func (c *UpstreamCache) Delete(domain string, qtype uint16)

Delete 删除缓存

func (*UpstreamCache) Get

func (c *UpstreamCache) Get(domain string, qtype uint16) ([]net.IP, bool)

Get 获取缓存

func (*UpstreamCache) Set

func (c *UpstreamCache) Set(domain string, qtype uint16, ips []net.IP, ttl time.Duration)

Set 设置缓存

func (*UpstreamCache) Stop

func (c *UpstreamCache) Stop()

Stop 停止缓存

Jump to

Keyboard shortcuts

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