connection

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrHandshakeFailed           = errors.New("esphome_api: handshake failed")
	ErrHandshakeNotDone          = errors.New("esphome_api: handshake not done")
	ErrInvalidEncryptionPreamble = errors.New("esphome_api: invalid preamble. encrypted message should starts with 0x01")
)

Functions

This section is empty.

Types

type ApiConnection

type ApiConnection interface {
	Write(message proto.Message) error
	Read(reader *bufio.Reader) (proto.Message, error)
	Handshake() error
}

func GetConnection

func GetConnection(conn net.Conn, communicationTimeout time.Duration, encryptionKey string) (ApiConnection, error)

func NewEncryptedConnection

func NewEncryptedConnection(conn net.Conn, communicationTimeout time.Duration, encryptionKey string) (ApiConnection, error)

func NewPlaintextConnection

func NewPlaintextConnection(conn net.Conn, communicationTimeout time.Duration) (ApiConnection, error)

type EncryptedConnection

type EncryptedConnection struct {
	CommunicationTimeout time.Duration
	// contains filtered or unexported fields
}

encryption is based on noise protocol reference: https://noiseprotocol.org

func (*EncryptedConnection) Handshake

func (ec *EncryptedConnection) Handshake() error

handshake implemented based on python implementation reference: https://github.com/esphome/aioesphomeapi/blob/main/aioesphomeapi/_frame_helper.py#L250

func (*EncryptedConnection) Read

func (ec *EncryptedConnection) Read(reader *bufio.Reader) (proto.Message, error)

func (*EncryptedConnection) Write

func (ec *EncryptedConnection) Write(message proto.Message) error

type PlaintextConnection

type PlaintextConnection struct {
	CommunicationTimeout time.Duration
	// contains filtered or unexported fields
}

func (*PlaintextConnection) Handshake

func (ptc *PlaintextConnection) Handshake() error

func (*PlaintextConnection) Read

func (ptc *PlaintextConnection) Read(reader *bufio.Reader) (proto.Message, error)

func (*PlaintextConnection) Write

func (ptc *PlaintextConnection) Write(message proto.Message) error

Jump to

Keyboard shortcuts

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