Version: v0.0.0-...-c20f884 Latest Latest

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

Go to latest
Published: Jul 30, 2019 License: MIT Imports: 9 Imported by: 0



Package mnet extends the standard package with extra functionality which is commonly useful



This section is empty.


This section is empty.


func IsReservedIP

func IsReservedIP(ip net.IP) bool

IsReservedIP returns true if the given valid IP is part of a reserved IP range.


type Listener

type Listener struct {
	// One of these will be populated during the start hook, depending on the
	// protocol configured.
	// contains filtered or unexported fields

Listener is returned by InstListener and simply wraps a net.Listener.

func InstListener

func InstListener(cmp *mcmp.Component, opts ...ListenerOpt) *Listener

InstListener instantiates a Listener which will be initialized when the Init event is triggered on the given Component, and closed when the Shutdown event is triggered on the returned Component.

func (*Listener) Accept

func (l *Listener) Accept() (net.Conn, error)

Accept wraps a call to Accept on the underlying net.Listener, providing debug logging.

func (*Listener) Close

func (l *Listener) Close() error

Close wraps a call to Close on the underlying net.Listener, providing debug logging.

type ListenerOpt

type ListenerOpt func(*listenerOpts)

ListenerOpt is a value which adjusts the behavior of InstListener.

func ListenerCloseOnShutdown

func ListenerCloseOnShutdown(closeOnShutdown bool) ListenerOpt

ListenerCloseOnShutdown sets the Listener's behavior when mrun's Shutdown event is triggered on its Component. If true the Listener will call Close on itself, if false it will do nothing.

Defaults to true.

func ListenerDefaultAddr

func ListenerDefaultAddr(defaultAddr string) ListenerOpt

ListenerDefaultAddr adjusts the defaultAddr which the Listener will use. The addr will still be configurable via mcfg regardless of what this is set to. The default is ":0".

func ListenerProtocol

func ListenerProtocol(proto string) ListenerOpt

ListenerProtocol adjusts the protocol which the Listener uses. The default is "tcp".

Source Files

Jump to

Keyboard shortcuts

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