mdnsforwarder

package module
v0.0.0-...-778bce9 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2021 License: MIT Imports: 8 Imported by: 0

README

MDNSForwarder

This is an app which allows to forward MDNS messages between different networks. The primary intend is to forward MDNS queries through unicast addresses (like a VPN network).

It has been succesfully tested to run on an OpenWRT router using the mips processor connecting to a docker container network in Kubernetes.

Usage

mdnsforwarder --log-level DEBUG --config config.json

If no config path is specified the default (/etc/config/mdnsforwarder) is used.

Refer to the config.json for an example. The configuration options are:

  • mdnsInterfaces: list of interfaces which should route mdnstraffic between each other
  • listeners: Host/Port combination where unicast messages including mdns messages via UDP is expected
  • targets: The list of targets where MDNS traffic from the local interfaces should be forwarded to.
  • skip_own_ip: Defaults to true. If set to false, this will handle all messages which are also send by the own list and should only be used in special environments.

Availability

  • The program is pulished as a self running go-executable for various platforms in the releases tab.
  • To run it in a docker container, the image is published in Docker Hub with the image cbrand/mdnsforwarder.

Caveats

The remote MDNS traffic forwarding doesn't have any security. It doesn't encrypt any traffic and relies on protection from a lower layer (for example by utilizing a VPN). DO NOT USE THIS DIRECTLY OVER THE OPEN INTERNET.

License

The application is published via the MIT license.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Forwarder

type Forwarder interface {
	MDNSNetworkInterfaces() []*net.Interface
	ListenerIps() []*net.UDPAddr
	GetTargets() []*net.UDPAddr
	SkipOwnIP() bool
	Run() error
}

Forwarder is the main interface which is used to store information for the mdns forwarder to handle network multicasting.

func New

func New(interfaces []*net.Interface, listenerIps []*net.UDPAddr, targets []*net.UDPAddr, skipOwnIP bool) Forwarder

type ForwarderImpl

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

func (*ForwarderImpl) GetTargets

func (forwarder *ForwarderImpl) GetTargets() []*net.UDPAddr

func (*ForwarderImpl) ListenerIps

func (forwarder *ForwarderImpl) ListenerIps() []*net.UDPAddr

func (*ForwarderImpl) MDNSNetworkInterfaces

func (forwarder *ForwarderImpl) MDNSNetworkInterfaces() []*net.Interface

func (*ForwarderImpl) Run

func (forwarder *ForwarderImpl) Run() error

func (*ForwarderImpl) SkipOwnIP

func (forwarder *ForwarderImpl) SkipOwnIP() bool

type Handler

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

Handler includes the logic for forwarding and handling mdns messages.

func NewHandler

func NewHandler(forwarder Forwarder) *Handler

func (*Handler) Run

func (handler *Handler) Run() error

func (*Handler) Start

func (handler *Handler) Start() error

type InterfaceCache

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

func (*InterfaceCache) IsInNetwork

func (interfaceCache *InterfaceCache) IsInNetwork(networkInterface *net.Interface, address net.IP) bool

type InterfaceHandler

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

func NewInterfaceHandler

func NewInterfaceHandler(networkInterface *net.Interface) (*InterfaceHandler, error)

func NewInterfaceHandlerWithAddress

func NewInterfaceHandlerWithAddress(networkInterface *net.Interface, multicastAddress string) (*InterfaceHandler, error)

func (*InterfaceHandler) Run

func (interfaceHandler *InterfaceHandler) Run(channel chan *UDPMessage) error

func (*InterfaceHandler) Send

func (interfaceHandler *InterfaceHandler) Send(message []byte) error

func (*InterfaceHandler) Start

func (interfaceHandler *InterfaceHandler) Start() error

func (*InterfaceHandler) Stop

func (interfaceHandler *InterfaceHandler) Stop() error

type ListenerHandler

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

func NewListenerHandler

func NewListenerHandler(addr *net.UDPAddr) (*ListenerHandler, error)

func (*ListenerHandler) Close

func (handler *ListenerHandler) Close() error

func (*ListenerHandler) Run

func (handler *ListenerHandler) Run(channel chan *RemoteUDPMessage) error

func (*ListenerHandler) Start

func (handler *ListenerHandler) Start() error

type RemoteUDPMessage

type RemoteUDPMessage struct {
	Address  *net.UDPAddr
	NumBytes int
	Data     []byte
}

RemoteUDPMessage represents a data being sent to a unicast listener for forwarding the message to all local networks.

type TargetHandler

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

func NewTargetHandler

func NewTargetHandler(target *net.UDPAddr) *TargetHandler

func (*TargetHandler) Send

func (handler *TargetHandler) Send(data []byte) error

type TimedInterfaceCache

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

func NewTimedInterfaceCache

func NewTimedInterfaceCache() *TimedInterfaceCache

func NewTimedInterfaceCacheExpiresAt

func NewTimedInterfaceCacheExpiresAt(expires time.Time) *TimedInterfaceCache

func (*TimedInterfaceCache) Expired

func (interfaceCache *TimedInterfaceCache) Expired() bool

func (*TimedInterfaceCache) IsInNetwork

func (interfaceCache *TimedInterfaceCache) IsInNetwork(networkInterface *net.Interface, address net.IP) bool

type UDPMessage

type UDPMessage struct {
	Interface *net.Interface
	Address   *net.UDPAddr
	NumBytes  int
	Data      []byte
}

UDPMessage is a message structure which represents one sent datagram from a listened message.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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