mdns

package
v0.6.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Listen

func Listen(entries chan<- *ServiceEntry, exit chan struct{}) error

func Lookup

func Lookup(service string, entries chan<- *ServiceEntry) error

func Query

func Query(params *QueryParam) error

Query 在一个域中查找一个给定的服务,最多等待指定的秒数 结果是流式的 一个通道。发送不会阻塞,所以客户应该确保 读取或缓存。

Types

type Config

type Config struct {
	Zone              Zone
	IFace             *net.Interface
	Port              int
	GetMachineIP      GetMachineIP
	LocalhostChecking bool
}

type DNSSDService

type DNSSDService struct {
	ServiceMDNS *ServiceMDNS
}

func (*DNSSDService) Records

func (that *DNSSDService) Records(q dns.Question) []dns.RR

type GetMachineIP

type GetMachineIP func() net.IP

type QueryParam

type QueryParam struct {
	Service             string
	Domain              string
	Type                uint16
	Context             context.Context
	Timeout             time.Duration
	Interface           *net.Interface
	Entries             chan<- *ServiceEntry
	WantUniCastResponse bool
}

func DefaultParams

func DefaultParams(service string) *QueryParam

DefaultParams 获取查询默认参数

type Server

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

func NewServer

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

func (*Server) SendMulticast

func (that *Server) SendMulticast(msg *dns.Msg) error

SendMulticast 发送组播消息

func (*Server) Shutdown

func (that *Server) Shutdown() error

type ServiceEntry

type ServiceEntry struct {
	Name       string // 服务名
	Host       string //
	AddrV4     net.IP
	AddrV6     net.IP
	Port       int
	Info       string
	InfoFields []string
	TTL        int
	Type       uint16
	Addr       net.IP
	// contains filtered or unexported fields
}

type ServiceMDNS

type ServiceMDNS struct {
	Instance string
	Service  string
	Domain   string
	HostName string
	Port     int
	IPs      []net.IP
	TXT      []string
	TTL      uint32
	// contains filtered or unexported fields
}

func NewServiceMDNS

func NewServiceMDNS(instance, service, domain, hostName string, port int, ips []net.IP, txt []string) (*ServiceMDNS, error)

func (*ServiceMDNS) Records

func (that *ServiceMDNS) Records(q dns.Question) []dns.RR

type Zone

type Zone interface {
	// Records 根据dns查询请求,返回一个dns记录。
	Records(q dns.Question) []dns.RR
}

Jump to

Keyboard shortcuts

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