mdns

package module
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: BSD-2-Clause Imports: 9 Imported by: 1

README

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

Documentation

Overview

Package mdns ... Advertise network services via multicast DNS

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Zone

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

Zone holds all published entries.

func New

func New(ipv4, ipv6 bool) (*Zone, error)

New initializes a new zone.

func (*Zone) Publish

func (z *Zone) Publish(r string) error

Publish adds a record, described in RFC XXX

func (*Zone) Shutdown

func (z *Zone) Shutdown()

Shutdown shuts down a zone

func (*Zone) Unpublish

func (z *Zone) Unpublish(r string) error

Unpublish removes a record, described in RFC XXX

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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