Documentation ¶
Index ¶
- Constants
- func DecodeKey(s string) []byte
- func GenerateID(name string) string
- func GenerateKey() []byte
- func GenerateUUID() string
- func WriteChunked(w io.Writer, contentType string, body []byte) (err error)
- func WriteResponse(w io.Writer, statusCode int, contentType string, body []byte) (err error)
- func WriteStatusCode(w io.Writer, statusCode int) (err error)
- type Accessories
- type Accessory
- type Character
- func (c *Character) AddListener(w io.Writer)
- func (c *Character) GenerateEvent() (data []byte, err error)
- func (c *Character) NotifyListeners(ignore io.Writer) error
- func (c *Character) ReadBool() bool
- func (c *Character) ReadTLV8(v any) (err error)
- func (c *Character) RemoveListener(w io.Writer)
- func (c *Character) Set(v any) (err error)
- func (c *Character) String() string
- func (c *Character) Write(v any) (err error)
- type Characters
- type Conn
- func (c *Conn) ClientPublic() []byte
- func (c *Conn) Close() error
- func (c *Conn) DeletePairing(id string) error
- func (c *Conn) Dial() error
- func (c *Conn) DialAndServe() error
- func (c *Conn) Do(req *http.Request) (*http.Response, error)
- func (c *Conn) Get(uri string) (*http.Response, error)
- func (c *Conn) GetAccessories() ([]*Accessory, error)
- func (c *Conn) GetCharacter(char *Character) error
- func (c *Conn) GetCharacters(query string) ([]*Character, error)
- func (c *Conn) GetImage(width, height int) ([]byte, error)
- func (c *Conn) Handle() (err error)
- func (c *Conn) ListPairings() error
- func (c *Conn) LocalAddr() string
- func (c *Conn) Pair(mfi bool, pin string) (err error)
- func (c *Conn) PairingsAdd(clientID string, clientPublic []byte, admin bool) error
- func (c *Conn) Post(uri string, data []byte) (*http.Response, error)
- func (c *Conn) Put(uri string, data []byte) (*http.Response, error)
- func (c *Conn) PutCharacters(characters ...*Character) (err error)
- func (c *Conn) URL() string
- func (c *Conn) Write(p []byte) (r io.Reader, err error)
- type PairVerifyPayload
- type Secure
- type Server
- func (s *Server) Accept(conn net.Conn) (err error)
- func (s *Server) HandlePairings(w io.Writer, r *http.Request)
- func (s *Server) HandleRequest(conn net.Conn, req *http.Request) (err error)
- func (s *Server) HandleSecure(secure *Secure) (err error)
- func (s *Server) PairSetupHandler(conn net.Conn, req *http.Request) (clientID string, err error)
- func (s *Server) PairVerifyHandler(conn net.Conn, req *http.Request) (secure *Secure, err error)
- func (s *Server) Serve(address string) (err error)
- type Service
Constants ¶
View Source
const ( MimeTLV8 = "application/pairing+tlv8" MimeJSON = "application/hap+json" UriPairSetup = "/pair-setup" UriPairVerify = "/pair-verify" UriPairings = "/pairings" UriAccessories = "/accessories" UriCharacteristics = "/characteristics" UriResource = "/resource" )
View Source
const DeviceAID = 1 // TODO: fix someday
Variables ¶
This section is empty.
Functions ¶
func GenerateID ¶
func GenerateKey ¶
func GenerateKey() []byte
func GenerateUUID ¶
func GenerateUUID() string
func WriteResponse ¶
Types ¶
type Accessories ¶
type Accessories struct {
Accessories []*Accessory `json:"accessories"`
}
type Accessory ¶
func (*Accessory) GetCharacter ¶
func (*Accessory) GetCharacterByID ¶
func (*Accessory) GetService ¶
type Character ¶
type Character struct { AID int `json:"aid,omitempty"` IID int `json:"iid"` Type string `json:"type,omitempty"` Format string `json:"format,omitempty"` Value any `json:"value,omitempty"` Event any `json:"ev,omitempty"` Perms []string `json:"perms,omitempty"` Description string `json:"description,omitempty"` // contains filtered or unexported fields }
func (*Character) AddListener ¶
func (*Character) GenerateEvent ¶
GenerateEvent with raw HTTP headers
func (*Character) RemoveListener ¶
type Characters ¶
type Characters struct {
Characters []*Character `json:"characteristics"`
}
type Conn ¶
type Conn struct { core.Listener DeviceAddress string // including port DeviceID string DevicePublic []byte ClientID string ClientPrivate []byte OnEvent func(res *http.Response) Output func(msg any) // contains filtered or unexported fields }
Conn for HomeKit. DevicePublic can be null.
func (*Conn) ClientPublic ¶
func (*Conn) DeletePairing ¶
func (*Conn) DialAndServe ¶
func (*Conn) GetAccessories ¶
func (*Conn) GetCharacter ¶
func (*Conn) ListPairings ¶
func (*Conn) PairingsAdd ¶
func (*Conn) PutCharacters ¶
type PairVerifyPayload ¶
type Server ¶
type Server struct { // Pin can't be null because server proof will be wrong Pin string `json:"-"` ServerID string `json:"server_id"` // 32 bytes private key + 32 bytes public key ServerPrivate []byte `json:"server_private"` // Pairings can be nil for disable pair verify check // ClientID: 32 bytes client public + 1 byte (isAdmin) Pairings map[string][]byte `json:"pairings"` DefaultPlainHandler func(w io.Writer, r *http.Request) error DefaultSecureHandler func(w io.Writer, r *http.Request) error OnPairChange func(clientID string, clientPublic []byte) `json:"-"` OnRequest func(w io.Writer, r *http.Request) `json:"-"` }
func (*Server) HandleRequest ¶
func (*Server) HandleSecure ¶
func (*Server) PairSetupHandler ¶
func (*Server) PairVerifyHandler ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.