server

package
v0.0.0-...-b87209e Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package server provides an MDNS server.

Index

Constants

This section is empty.

Variables

View Source
var (
	MDNSGroupIPv4 = net.ParseIP("224.0.0.251")
	MDNSGroupIPv6 = net.ParseIP("ff02::fb")
)

mDNS Groups.

View Source
var (
	MDNSWildcardAddrIPv4 = &net.UDPAddr{
		IP:   net.ParseIP("224.0.0.0"),
		Port: 5353,
	}
	MDNSWildcardAddrIPv6 = &net.UDPAddr{
		IP:   net.ParseIP("ff02::"),
		Port: 5353,
	}
)

mDNS wildcard addresses.

View Source
var (
	IPv4Addr = &net.UDPAddr{
		IP:   MDNSGroupIPv4,
		Port: 5353,
	}
	IPv6Addr = &net.UDPAddr{
		IP:   MDNSGroupIPv6,
		Port: 5353,
	}
)

mDNS endpoint addresses.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Zone must be provided to support responding to queries
	Zone zone.Zone

	// Iface if provided binds the multicast listener to the given
	// interface. If not provided, the system default multicase interface
	// is used.
	Iface *net.Interface

	// Port If it is not 0, replace the port 5353 with this port number.
	Port int

	// GetMachineIP is a function to return the IP of the local machine
	GetMachineIP GetMachineIP

	// LocalhostChecking if enabled asks the server to also send responses to
	// 0.0.0.0 if the target IP
	// is this host (as defined by GetMachineIP).
	// Useful in case machine is on a VPN which blocks comms on non standard ports
	LocalhostChecking bool
}

Config is used to configure the mDNS server.

type GetMachineIP

type GetMachineIP func() net.IP

GetMachineIP is a func which returns the outbound IP of this machine. Used by the server to determine whether to attempt send the response on a local address.

type Server

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

Server is an mDNS server used to listen for mDNS queries and respond if we have a matching local record.

func NewServer

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

NewServer is used to create a new mDNS server from a config.

func (*Server) SendMulticast

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

SendMulticast us used to send a multicast response packet.

func (*Server) Shutdown

func (s *Server) Shutdown() error

Shutdown is used to shutdown the listener.

Jump to

Keyboard shortcuts

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