Documentation

Overview

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

    Index

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    func IsReservedIP

    func IsReservedIP(ip net.IP) bool

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

      Types

      type Listener

      type Listener struct {
      	// One of these will be populated during the start hook, depending on the
      	// protocol configured.
      	net.Listener
      	net.PacketConn
      	// 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