packet

package
v0.20.4 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NoisePublicKeySize - constant for noise public key size
	NoisePublicKeySize = 32

	// NoisePrivateKeySize - constant for noise private key size
	NoisePrivateKeySize = 32

	// NetworkNameSize - constant for netmaker network name
	NetworkNameSize = 12

	// PeerKeyHashSize - constant for peer key hash size
	PeerKeyHashSize = 16

	// MessageMetricSize - constant for metric message size
	MessageMetricSize = 148

	// MessageProxyUpdateSize - constant for proxy update message size
	MessageProxyUpdateSize = 148

	// MessageProxyTransportSize - constant for proxy transport message size
	MessageProxyTransportSize = 36

	// MessageTransportType - constant for wg message transport type
	MessageTransportType MessageType = 4

	// MessageInitiationType - constant for wg handshake intiation type
	MessageInitiationType MessageType = 1

	// MessageMetricsType - constant for proxy metrics message
	MessageMetricsType MessageType = 5

	// MessageProxyTransportType - constant for proxy transport message
	MessageProxyTransportType MessageType = 6

	// MessageProxyUpdateType - constant for proxy update message
	MessageProxyUpdateType MessageType = 7

	// UpdateListenPort - constant update listen port proxy action
	UpdateListenPort ProxyActionType = 1

	// constant for proxy server buffer size
	DefaultBodySize = 65000 + MessageProxyTransportSize
)

Variables

This section is empty.

Functions

func ConsumeHandshakeInitiationMsg

func ConsumeHandshakeInitiationMsg(initiator bool, buf []byte, devicePubKey NoisePublicKey, devicePrivKey NoisePrivateKey) (string, error)

ConsumeHandshakeInitiationMsg - decodes wg handshake intiation message

func CreateMetricPacket

func CreateMetricPacket(id uint32, sender, reciever wgtypes.Key) ([]byte, error)

CreateMetricPacket - creates metric packet

func CreateProxyUpdatePacket

func CreateProxyUpdatePacket(msg *ProxyUpdateMessage) ([]byte, error)

CreateProxyUpdatePacket - creates proxy update message

func EncodePacketMetricMsg

func EncodePacketMetricMsg(msg *MetricMessage) ([]byte, error)

EncodePacketMetricMsg - encodes metric message to buffer

func ExtractInfo

func ExtractInfo(buffer []byte, n int) (int, string, string, error)

ExtractInfo - extracts proxy transport message from the data buffer

func ProcessPacketBeforeSending

func ProcessPacketBeforeSending(buf []byte, n int, srckey, dstKey string) ([]byte, int, string, string)

ProcessPacketBeforeSending - encodes data required for proxy transport message

func TurnOffIpFowarding

func TurnOffIpFowarding()

TurnOffIpFowarding - turns off ip fowarding, runs only for linux systems

Types

type MessageInitiation

type MessageInitiation struct {
	Type      MessageType
	Sender    uint32
	Ephemeral NoisePublicKey
	Static    [NoisePublicKeySize + poly1305TagSize]byte
	Timestamp [tai64n.TimestampSize + poly1305TagSize]byte
	MAC1      [blake2s.Size128]byte
	MAC2      [blake2s.Size128]byte
}

MessageInitiation - struct for wg handshake initiation message

type MessageType

type MessageType uint32

MessageType - custom type for message type

type MetricMessage

type MetricMessage struct {
	Type       MessageType
	ID         uint32
	Reply      uint32
	Sender     wgtypes.Key
	Reciever   wgtypes.Key
	TimeStamp  int64
	ListenPort uint32
}

MetricMessage - struct for metric message

func ConsumeMetricPacket

func ConsumeMetricPacket(buf []byte) (*MetricMessage, error)

ConsumeMetricPacket - decodes metric packet

type NoisePrivateKey

type NoisePrivateKey [NoisePrivateKeySize]byte

NoisePrivateKey - custom type for noise private key

type NoisePublicKey

type NoisePublicKey [NoisePublicKeySize]byte

NoisePublicKey - custom type for noise public key

type ProxyActionType

type ProxyActionType uint32

ProxyActionType - custom type for proxy update action type

type ProxyMessage

type ProxyMessage struct {
	Type     MessageType
	Sender   [PeerKeyHashSize]byte
	Reciever [PeerKeyHashSize]byte
}

ProxyMessage - struct for proxy message

type ProxyUpdateMessage

type ProxyUpdateMessage struct {
	Type       MessageType
	Action     ProxyActionType
	Sender     wgtypes.Key
	Reciever   wgtypes.Key
	ListenPort uint32
}

ProxyUpdateMessage - struct for proxy update message

func ConsumeProxyUpdateMsg

func ConsumeProxyUpdateMsg(buf []byte) (*ProxyUpdateMessage, error)

ConsumeProxyUpdateMsg - decodes proxy update message

Jump to

Keyboard shortcuts

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