Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Listen ¶
func Listen(entries chan<- *ServiceEntry, exit chan struct{}) error
Listen 无限期的监听多播的更新
func Query ¶
func Query(params *QueryParam) error
Query 在一个域中查找一个给定的服务,最多等待指定的秒数 结果是流式的 一个通道。发送不会阻塞,所以客户应该确保 读取或缓存。
Types ¶
type DNSSDService ¶
type DNSSDService struct {
ServiceMDNS *ServiceMDNS
}
type GetMachineIP ¶
type QueryParam ¶
type QueryParam struct {
Service string // 要查找的服务
Domain string // 要查找的域。默认是 local
Type uint16 // dns查询类型,默认是 dns.TypePTR
Context context.Context // 上下文
Timeout time.Duration // 查询超时时间,默认1s,如果通过context提供了超时,则忽略该参数
Interface *net.Interface // 使用组播的网卡
Entries chan<- *ServiceEntry // 收到的响应包,以channel形式提供
WantUniCastResponse bool // 是否需要单播响应,参考 per 5.4 in RFC
}
QueryParam 自定义查询参数
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) SendMulticast ¶
SendMulticast 发送组播消息
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
}
ServiceEntry 查询后的条目
type ServiceMDNS ¶
type ServiceMDNS struct {
Instance string // 实例的名称 (e.g. "hostService name")
Service string // 服务的名字 (e.g. "_http._tcp.")
Domain string // 域 默认为“local”
HostName string // 主机的dns名称 (e.g. "mymachine.net.")
Port int // 端口
IPs []net.IP // 当前服务使用的ip地址
TXT []string
TTL uint32
// contains filtered or unexported fields
}
ServiceMDNS mdns服务
func NewServiceMDNS ¶
func NewServiceMDNS(instance, service, domain, hostName string, port int, ips []net.IP, txt []string) (*ServiceMDNS, error)
NewServiceMDNS 创建MDNS服务 instance
Click to show internal directories.
Click to hide internal directories.