connection

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2023 License: Apache-2.0 Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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