mesh

package
v0.0.0-...-2d7d249 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2024 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrIfaceNotUp Ugly, but gopacket folks are not exporting pcap errors, so ...
	// ref. https://github.com/gopacket/gopacket/blob/96986c90e3e5c7e01deed713ff8058e357c0c047/pcap/pcap.go#L281
	ErrIfaceNotUp = "Interface Not Up"
)

Variables

View Source
var (
	SnapLength  = 65536
	ReadTimeout = 100
)
View Source
var (
	Workers = 0
	PeerTTL = 1800
	Peers   = sync.Map{}
)
View Source
var (
	SignalingPeriod = 300
)

Functions

func ActivateInterface

func ActivateInterface(name string) error

func ChannelHopping

func ChannelHopping(iface string, chanList string, allChannels []int, hopPeriod int)

func SetChannel

func SetChannel(iface string, channel int) (error, string)

func SupportedChannels

func SupportedChannels(iface string) ([]int, error)

Types

type Memory

type Memory struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func MemoryFromPath

func MemoryFromPath(path string) (err error, mem *Memory)

func (*Memory) List

func (mem *Memory) List() []*Peer

func (*Memory) Of

func (mem *Memory) Of(fingerprint string) *Peer

func (*Memory) Size

func (mem *Memory) Size() int

func (*Memory) Track

func (mem *Memory) Track(fingerprint string, peer *Peer) error

type PacketCallback

type PacketCallback func(pkt gopacket.Packet)

type PacketMuxer

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

func NewPacketMuxer

func NewPacketMuxer(iface, filter string, workers int) (mux *PacketMuxer, err error)

func (*PacketMuxer) OnPacket

func (mux *PacketMuxer) OnPacket(cb PacketCallback)

func (*PacketMuxer) Start

func (mux *PacketMuxer) Start()

func (*PacketMuxer) Stop

func (mux *PacketMuxer) Stop()

func (*PacketMuxer) Write

func (mux *PacketMuxer) Write(data []byte) error

type Peer

type Peer struct {
	sync.Mutex

	MetAt        time.Time // first time met
	DetectedAt   time.Time // first time detected on this session
	SeenAt       time.Time // last time detected on this session
	PrevSeenAt   time.Time // if we met this unit before, this is the last time it's been seen
	Encounters   uint64
	Channel      int
	RSSI         int
	SessionID    SessionID
	SessionIDStr string
	Keys         *crypto.KeyPair
	AdvData      sync.Map
	AdvPeriod    int

	ForceDisabled bool
	// contains filtered or unexported fields
}

func MakeLocalPeer

func MakeLocalPeer(name string, keys *crypto.KeyPair, advertise bool) *Peer

func NewPeer

func NewPeer(radiotap *layers.RadioTap, dot11 *layers.Dot11, adv map[string]interface{}) (peer *Peer, err error)

func (*Peer) Advertise

func (peer *Peer) Advertise(enabled bool)

func (*Peer) Data

func (peer *Peer) Data() map[string]interface{}

func (*Peer) ID

func (peer *Peer) ID() string

func (*Peer) InactiveFor

func (peer *Peer) InactiveFor() float64

func (*Peer) MarshalJSON

func (peer *Peer) MarshalJSON() ([]byte, error)

func (*Peer) SetData

func (peer *Peer) SetData(adv map[string]interface{})

func (*Peer) StartAdvertising

func (peer *Peer) StartAdvertising(iface string) (err error)

func (*Peer) StopAdvertising

func (peer *Peer) StopAdvertising()

func (*Peer) Update

func (peer *Peer) Update(radio *layers.RadioTap, dot11 *layers.Dot11, adv map[string]interface{}) (err error)

type PeerActivityCallback

type PeerActivityCallback func(ident string, peer *Peer)

type Router

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

func StartRouting

func StartRouting(iface string, peersPath string, local *Peer) (*Router, error)

func (*Router) Memory

func (router *Router) Memory() []*Peer

func (*Router) MemoryOf

func (router *Router) MemoryOf(fingerprint string) *Peer

func (*Router) OnNewPeer

func (router *Router) OnNewPeer(cb PeerActivityCallback)

func (*Router) OnPeerLost

func (router *Router) OnPeerLost(cb PeerActivityCallback)

type SessionID

type SessionID []byte

Jump to

Keyboard shortcuts

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