// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT

// This example program showcases the use of the mDNS client by querying a previously published address
package main

import (
	"context"
	"fmt"
	"net"

	"golang.org/x/net/ipv4"
	"golib/v2/pkg/mdns"
)

func main() {
	l, err := net.ListenUDP(mdns.NetType, mdns.Address)
	if err != nil {
		panic(err)
	}

	server, err := mdns.Server(ipv4.NewPacketConn(l), &mdns.Config{})
	if err != nil {
		panic(err)
	}
	answer, src, err := server.Query(context.TODO(), "pion-test.local")
	fmt.Println(answer)
	fmt.Println(src)
	fmt.Println(err)
}
