Skip to content

ugjka/mdns

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MDNS

GoDoc Go Report Card Donate

Introduction

This package allows Go processes to publish multicast DNS style records onto their local network segment. For more information about mDNS, and it's closely related cousin, Zeroconf, please visit http://www.multicastdns.org/.

Installation

This package can be installed using:

go get github.com/ugjka/mdns

Usage

Publishing mDNS records is simple

package main

import (
    "log"
    "os"
    "os/signal"
    "syscall"

    "github.com/ugjka/mdns"
)

func main(){
                        //ipv4  ipv6
    zone, err := mdns.New(true, false)
    if err != nil {
        log.Fatal(err)
    }

    zone.Publish("yourhost.local. 60 IN A 192.168.1.2")
    zone.Publish("2.1.168.192.in-addr.arpa. 60 IN PTR yourhost.local.")
    defer zone.Shutdown()

    sig := make(chan os.Signal, 1)
    signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP)
    <-sig
    log.Println("Shutting down.")
}

Warning

Do not mix mDNS stacks, e.g. if you have Avahi daemon running don't use this then

About

Multicast DNS library for Go

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%