common

package
v0.0.0-...-24c9e8f Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindGatewayMAC

func FindGatewayMAC(interfaceName string) (net.HardwareAddr, error)

func GetMACAddressByInterfaceName

func GetMACAddressByInterfaceName(interfaceName string) (string, error)

func IpToUint32

func IpToUint32(ipStr string) uint32

IpToUint32 converts IP to uint32

func IsSameSubnet

func IsSameSubnet(ip1, ip2 string, subnetMask string) (bool, error)

func MacStringToInt8Array

func MacStringToInt8Array(macStr string) [6]int8

func Uint32ToIp

func Uint32ToIp(ipInt uint32) string

Types

type AtomicCounter

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

func NewAtomicCounter

func NewAtomicCounter() *AtomicCounter

func (*AtomicCounter) Next

func (ac *AtomicCounter) Next() uint16

type BroadcastTargets

type BroadcastTargets struct {
	Ip   uint32
	Port uint16
	Mac  [6]int8
}

func (BroadcastTargets) GetIp

func (t BroadcastTargets) GetIp() uint32

func (BroadcastTargets) GetMac

func (t BroadcastTargets) GetMac() [6]int8

func (BroadcastTargets) GetPort

func (t BroadcastTargets) GetPort() uint16

type Metadata

type Metadata struct {
	Size   int    // Metadata size
	Update int64  // Metadata version (update timestamp)
	Data   []byte // Metadata content
}

Metadata information

type Node

type Node struct {
	Addr        string `json:"Addr"`        // Node IP address (fill in public IP in public network environment)
	Port        int    `json:"Port"`        // Port number
	Mac         string `json:"Mac"`         // Node MAC address
	Name        string `json:"Name"`        // Node name (customizable)
	PrivateData string `json:"PrivateData"` // Node private data (customizable)
	LinkName    string // bind xdp to this interface
}

Node represents a node

type Packet

type Packet struct {
	Type   uint8  // 0 not used 1: heartbeat packet, 2: initiator sends an exchange request to the recipient, 3: recipient responds to the initiator, data exchange completed
	Count  uint16 // Broadcast packet count (0-64)
	Mapkey uint16 // Map key
	// Metadata information
	Metadata Metadata // New metadata information, if the packet is a metadata update packet (isUpdate=true), then replace the original cluster metadata with newData

	// Node information
	Node     Node            // Node information in the heartbeat packet
	Infected map[string]bool // List of nodes already infected by this packet, the key is a string concatenated by Addr:Port, and the value determines whether the node has been infected (true: yes, false: no)
	IsUpdate bool            // Whether it is a metadata update packet (0: no, 1: yes)

	SecretKey string // Cluster key, if it doesn't match, reject processing this packet
	CountStr  string
}

Packet data

Jump to

Keyboard shortcuts

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