device

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	AddressInfo peer.AddrInfo `json:"-"`

	OS        string       `json:"os"`
	Name      string       `json:"name"`
	PublicKey []byte       `json:"publicKey"`
	Status    DeviceStatus `json:"status"`

	Stream network.Stream `json:"-"`
	Writer *bufio.Writer  `json:"-"`
	Reader *bufio.Reader  `json:"-"`

	PgpEncrypter *crypto.PGPEncrypter `json:"-"`
}

Device struct for peer

func NewDevice

func NewDevice(
	addrInfo peer.AddrInfo,
	stream network.Stream,
) *Device

NewDevice initial new peer

func (*Device) Block

func (dv *Device) Block()

Block block this device

func (*Device) CreatePGPEncrypter

func (dv *Device) CreatePGPEncrypter() error

func (*Device) Trust

func (dv *Device) Trust() error

Trust trust this device and change status to connected

func (*Device) UpdateFromProtobuf

func (dv *Device) UpdateFromProtobuf(deviceData *protobuf.DeviceData)

UpdateFromProtobuf update device from protobuf device data

type DeviceStatus

type DeviceStatus string

DeviceStatus device status

const (
	// StatusPending the device waiting to handshake and trust the device, they send you the public key but you didn't
	StatusPending DeviceStatus = "pending"
	// StatusConnected the device is trusted and connected
	StatusConnected DeviceStatus = "connected"
	// StatusDisconnected the device is trusted but disconnected or offline
	StatusDisconnected DeviceStatus = "disconnected"
	// StatusError found a error in the device should disconnect and reconnect
	StatusError DeviceStatus = "error"
	// StatusBlocked the device is blocked by the user
	StatusBlocked DeviceStatus = "blocked"
)

Jump to

Keyboard shortcuts

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