discover

package
v0.10.20 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2015 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package discover implements the device discovery protocol.

Index

Constants

View Source
const (
	AnnouncementMagic = 0x9D79BC39
	QueryMagic        = 0x2CA856F5
)

Variables

View Source
var (
	DefaultErrorRetryInternval     = 60 * time.Second
	DefaultGlobalBroadcastInterval = 1800 * time.Second
)
View Source
var (
	ErrIncorrectMagic = errors.New("incorrect magic number")
)

Functions

func Register added in v0.10.10

func Register(proto string, factory Factory)

Types

type Address

type Address struct {
	IP   []byte // max:16
	Port uint16
}

func (Address) AppendXDR

func (o Address) AppendXDR(bs []byte) ([]byte, error)

func (*Address) DecodeXDR

func (o *Address) DecodeXDR(r io.Reader) error

func (Address) EncodeXDR

func (o Address) EncodeXDR(w io.Writer) (int, error)

func (Address) MarshalXDR

func (o Address) MarshalXDR() ([]byte, error)

func (Address) MustMarshalXDR added in v0.10.3

func (o Address) MustMarshalXDR() []byte

func (*Address) UnmarshalXDR

func (o *Address) UnmarshalXDR(bs []byte) error

type Announce

type Announce struct {
	Magic uint32
	This  Device
	Extra []Device // max:16
}

func (Announce) AppendXDR

func (o Announce) AppendXDR(bs []byte) ([]byte, error)

func (*Announce) DecodeXDR

func (o *Announce) DecodeXDR(r io.Reader) error

func (Announce) EncodeXDR

func (o Announce) EncodeXDR(w io.Writer) (int, error)

func (Announce) MarshalXDR

func (o Announce) MarshalXDR() ([]byte, error)

func (Announce) MustMarshalXDR added in v0.10.3

func (o Announce) MustMarshalXDR() []byte

func (*Announce) UnmarshalXDR

func (o *Announce) UnmarshalXDR(bs []byte) error

type CacheEntry added in v0.10.2

type CacheEntry struct {
	Address string
	Seen    time.Time
}

type Client added in v0.10.10

type Client interface {
	Lookup(device protocol.DeviceID) []string
	StatusOK() bool
	Address() string
	Stop()
}

func New added in v0.10.10

func New(addr string, pkt *Announce) (Client, error)

type Device added in v0.10.0

type Device struct {
	ID        []byte    // max:32
	Addresses []Address // max:16
}

func (Device) AppendXDR added in v0.10.0

func (o Device) AppendXDR(bs []byte) ([]byte, error)

func (*Device) DecodeXDR added in v0.10.0

func (o *Device) DecodeXDR(r io.Reader) error

func (Device) EncodeXDR added in v0.10.0

func (o Device) EncodeXDR(w io.Writer) (int, error)

func (Device) MarshalXDR added in v0.10.0

func (o Device) MarshalXDR() ([]byte, error)

func (Device) MustMarshalXDR added in v0.10.3

func (o Device) MustMarshalXDR() []byte

func (*Device) UnmarshalXDR added in v0.10.0

func (o *Device) UnmarshalXDR(bs []byte) error

type Discoverer

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

func NewDiscoverer

func NewDiscoverer(id protocol.DeviceID, addresses []string) *Discoverer

func (*Discoverer) All

func (d *Discoverer) All() map[protocol.DeviceID][]CacheEntry

func (*Discoverer) ExtAnnounceOK

func (d *Discoverer) ExtAnnounceOK() map[string]bool

func (*Discoverer) Hint

func (d *Discoverer) Hint(device string, addrs []string)

func (*Discoverer) Lookup

func (d *Discoverer) Lookup(device protocol.DeviceID) []string

func (*Discoverer) StartGlobal

func (d *Discoverer) StartGlobal(servers []string, extPort uint16)

func (*Discoverer) StartLocal

func (d *Discoverer) StartLocal(localPort int, localMCAddr string)

func (*Discoverer) StopGlobal

func (d *Discoverer) StopGlobal()

type Factory added in v0.10.10

type Factory func(*url.URL, *Announce) (Client, error)

type Query

type Query struct {
	Magic    uint32
	DeviceID []byte // max:32
}

func (Query) AppendXDR

func (o Query) AppendXDR(bs []byte) ([]byte, error)

func (*Query) DecodeXDR

func (o *Query) DecodeXDR(r io.Reader) error

func (Query) EncodeXDR

func (o Query) EncodeXDR(w io.Writer) (int, error)

func (Query) MarshalXDR

func (o Query) MarshalXDR() ([]byte, error)

func (Query) MustMarshalXDR added in v0.10.3

func (o Query) MustMarshalXDR() []byte

func (*Query) UnmarshalXDR

func (o *Query) UnmarshalXDR(bs []byte) error

type UDPClient added in v0.10.10

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

func (*UDPClient) Address added in v0.10.10

func (d *UDPClient) Address() string

func (*UDPClient) Lookup added in v0.10.10

func (d *UDPClient) Lookup(device protocol.DeviceID) []string

func (*UDPClient) Start added in v0.10.10

func (d *UDPClient) Start(uri *url.URL, pkt *Announce) error

func (*UDPClient) StatusOK added in v0.10.10

func (d *UDPClient) StatusOK() bool

func (*UDPClient) Stop added in v0.10.10

func (d *UDPClient) Stop()

Jump to

Keyboard shortcuts

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