shared

package
v0.0.0-...-a6714d8 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BroadcastMessage

func BroadcastMessage(msgType int, data []byte, skip *Socket)

BroadcastMessage sends the given data over all sockets.

func MACIsUnicast

func MACIsUnicast(mac MacAddr) bool

MACIsUnicast returns true if the MAC address is a unicast address.

Types

type CommandHandler

type CommandHandler func(args []string) error

CommandHandler is the signature of a function which can be triggered via a command over our websocket connection. We use if for `init`.

type MacAddr

type MacAddr [6]byte

MacAddr stores a MAC address.

func GetDestMAC

func GetDestMAC(packet []byte) MacAddr

GetDestMAC retreives the destination MAC address of a TCP/IP packet.

func GetSrcMAC

func GetSrcMAC(packet []byte) MacAddr

GetSrcMAC retrieves the source MAC address of a TCP/IP packet.

type Socket

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

Socket holds state about our connection.

func FindSocketByMAC

func FindSocketByMAC(mac MacAddr) *Socket

FindSocketByMAC finds the correct socket, by looking for the specified MAC address.

func MakeSocket

func MakeSocket(clientIP string, conn *websocket.Conn, iface *water.Interface, fn reap) *Socket

MakeSocket is our constructor. It ties a websocket connection to an interface connection.

func (*Socket) AddCommandHandler

func (s *Socket) AddCommandHandler(command string, handler CommandHandler)

AddCommandHandler binds a function-name to a handler, which is used in our websocket connection.

func (*Socket) BroadcastCommand

func (s *Socket) BroadcastCommand(command string, args []string) error

BroadcastCommand sends the given data over all sockets.

func (*Socket) Close

func (s *Socket) Close()

Close closes our interface and websocket.

func (*Socket) SendCommand

func (s *Socket) SendCommand(command string, args ...string) error

SendCommand sends a "command" over our websocket link

func (*Socket) Serve

func (s *Socket) Serve(ipv6 bool)

Serve is the main-driver which never returns Handle proxying data back and forth..

func (*Socket) SetInterface

func (s *Socket) SetInterface(iface *water.Interface) error

SetInterface sets the given network-interface to be associated with us.

func (*Socket) Wait

func (s *Socket) Wait()

Wait waits for our socket to be done.

func (*Socket) WriteMessage

func (s *Socket) WriteMessage(msgType int, data []byte) error

WriteMessage sends data over our socket.

Jump to

Keyboard shortcuts

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