Documentation
¶
Index ¶
- Constants
- Variables
- func ConnStateEvent(conn net.Conn, event http.ConnState)
- func Conns() map[string]*Conn
- func KeyDerivativeFuncRFC2945(h srp.HashFunc, id []byte) srp.KeyDerivationFunc
- func NewChunkedWriter(wr io.Writer, chunk int) io.Writer
- func NewFsStore(dir string) *fsStore
- func NewMemStore() memStore
- func Sessions() map[string]interface{}
- func SetConn(addr string, conn *Conn)
- func SetSession(addr string, sess interface{})
- type AccessoriesPayload
- type CharacteristicData
- type Conn
- type KeyPair
- type Listener
- type NotificationPayload
- type PairSetupPayload
- type PairSetupSession
- type PairSetupStep1Payload
- type PairSetupStep2Payload
- type PairSetupStep4Payload
- type PairSetupStep6EncryptedPayload
- type PairSetupStep6Payload
- type PairVerifyPayload
- type PairVerifySession
- type Pairing
- type PairingPayload
- type ServeMux
- type Server
- func (srv *Server) GetAccessories(res http.ResponseWriter, req *http.Request)
- func (srv *Server) GetCharacteristics(res http.ResponseWriter, req *http.Request)
- func (srv *Server) Identify(res http.ResponseWriter, req *http.Request)
- func (s *Server) ListenAndServe(ctx context.Context) error
- func (srv *Server) PairSetup(res http.ResponseWriter, req *http.Request)
- func (srv *Server) PairSetupStep1(res http.ResponseWriter, req *http.Request, data PairSetupPayload)
- func (srv *Server) PairSetupStep3(res http.ResponseWriter, req *http.Request, data PairSetupPayload)
- func (srv *Server) PairSetupStep5(res http.ResponseWriter, req *http.Request, data PairSetupPayload)
- func (srv *Server) PairVerify(res http.ResponseWriter, req *http.Request)
- func (srv *Server) PairVerifyStep1(res http.ResponseWriter, req *http.Request, data PairVerifyPayload)
- func (srv *Server) PairVerifyStep3(res http.ResponseWriter, req *http.Request, data PairVerifyPayload)
- func (srv *Server) Pairings(res http.ResponseWriter, req *http.Request)
- func (srv *Server) PutCharacteristics(res http.ResponseWriter, req *http.Request)
- func (s *Server) ServeMux() ServeMux
- type Session
- type Store
Constants ¶
const ( JsonStatusSuccess = 0 JsonStatusInsufficientPrivileges = -70401 JsonStatusServiceCommunicationFailure = -70402 JsonStatusResourceBusy = -70403 JsonStatusReadOnlyCharacteristic = -70404 JsonStatusWriteOnlyCharacteristic = -70405 JsonStatusNotificationNotSupported = -70406 JsonStatusOutOfResource = -70407 JsonStatusOperationTimedOut = -70408 JsonStatusResourceDoesNotExist = -70409 JsonStatusInvalidValueInRequest = -70410 )
const ( TlvErrorUnknown = 0x1 TlvErrorInvalidRequest = 0x2 TlvErrorAuthentication = 0x2 TlvErrorBackoff = 0x3 TlvErrorMaxPeers = 0x4 TlvErrorUnknownPeer = 0x4 TlvErrorMaxTries = 0x5 TlvErrorBusy = 0x7 )
const ( // HTTPContentTypePairingTLV8 is the HTTP content type for pairing HTTPContentTypePairingTLV8 = "application/pairing+tlv8" // HTTPContentTypeHAPJson is the HTTP content type for json data HTTPContentTypeHAPJson = "application/hap+json" )
const ( Step1 byte = 0x1 Step2 byte = 0x2 Step3 byte = 0x3 Step4 byte = 0x4 Step5 byte = 0x5 Step6 byte = 0x6 )
const ( MethodPair byte = 0x0 // pair MethodPairMFi byte = 0x1 // MFi compliant accessory MethodVerifyPair byte = 0x2 // verify a pairing MethodAddPairing byte = 0x3 // add client through secure connection MethodDeletePairing byte = 0x4 // delete pairing through secure connection MethodListPairings byte = 0x5 )
const ( PermissionUser byte = 0x0 PermissionAdmin byte = 0x1 )
const (
// PacketLengthMax is the max length of encrypted packets
PacketLengthMax = 0x400
)
const (
SRPGroup = "rfc5054.3072" // N (modulo) => 384 byte
)
Main SRP algorithm is described in http://srp.stanford.edu/design.html The HAP uses the SRP-6a Stanford implementation with the following characteristics
x = H(s | H(I | ":" | P)) -> called the key derivative function M1 = H(H(N) xor H(g), H(I), s, A, B, K)
Variables ¶
Functions ¶
func KeyDerivativeFuncRFC2945 ¶
func KeyDerivativeFuncRFC2945(h srp.HashFunc, id []byte) srp.KeyDerivationFunc
KeyDerivativeFuncRFC2945 returns the SRP-6a key derivative function which does
x = H(s | H(I | ":" | P))
func NewChunkedWriter ¶
NewChunkedWriter returns a writer which writes bytes in chunkes of specified size.
func NewFsStore ¶
func NewFsStore(dir string) *fsStore
func NewMemStore ¶
func NewMemStore() memStore
func SetSession ¶
func SetSession(addr string, sess interface{})
Types ¶
type AccessoriesPayload ¶
type CharacteristicData ¶
type CharacteristicData struct { Aid uint64 `json:"aid"` Iid uint64 `json:"iid"` Value interface{} `json:"value,omitempty"` // optional values Type *string `json:"type,omitempty"` Permissions []string `json:"perms,omitempty"` Status *int `json:"status,omitempty"` Events *bool `json:"ev,omitempty"` Format *string `json:"format,omitempty"` Unit *string `json:"unit,omitempty"` MinValue interface{} `json:"minValue,omitempty"` MaxValue interface{} `json:"maxValue,omitempty"` MinStep interface{} `json:"minStep,omitempty"` MaxLen *int `json:"maxLen,omitempty"` Remote *bool `json:"remote,omitempty"` Response *bool `json:"r,omitempty"` }
type Conn ¶
type Listener ¶
type Listener struct {
*net.TCPListener
}
type NotificationPayload ¶
type NotificationPayload struct {
Cs []CharacteristicData `json:"characteristics"`
}
type PairSetupPayload ¶
type PairSetupPayload struct { Method byte `tlv8:"0"` Identifier string `tlv8:"1"` Salt []byte `tlv8:"2"` PublicKey []byte `tlv8:"3"` Proof []byte `tlv8:"4"` EncryptedData []byte `tlv8:"5"` State byte `tlv8:"6"` Error byte `tlv8:"7"` RetryDelay byte `tlv8:"8"` Certificate []byte `tlv8:"9"` Signature []byte `tlv8:"10"` Permissions byte `tlv8:"11"` FragmentData []byte `tlv8:"13"` FragmentLast []byte `tlv8:"14"` }
type PairSetupSession ¶
type PairSetupSession struct { Identifier []byte Salt []byte // s PublicKey []byte // A PrivateKey []byte // S EncryptionKey [32]byte // K // contains filtered or unexported fields }
func GetPairSetupSession ¶
func GetPairSetupSession(addr string) (*PairSetupSession, error)
func NewPairSetupSession ¶
func NewPairSetupSession(id, pin string) (*PairSetupSession, error)
NewPairSetupSession return a new setup server session.
func (*PairSetupSession) ProofFromClientProof ¶
func (p *PairSetupSession) ProofFromClientProof(clientProof []byte) ([]byte, error)
ProofFromClientProof validates client proof (`M1`) and returns authenticator or error if proof is not valid.
func (*PairSetupSession) SetupEncryptionKey ¶
func (p *PairSetupSession) SetupEncryptionKey(salt []byte, info []byte) error
SetupEncryptionKey calculates and internally sets encryption key `K` based on salt and info
Only 32 bytes are used from HKDF-SHA512
func (*PairSetupSession) SetupPrivateKeyFromClientPublicKey ¶
func (p *PairSetupSession) SetupPrivateKeyFromClientPublicKey(key []byte) error
SetupPrivateKeyFromClientPublicKey calculates and internally sets secret key `S` based on client public key `A`
type PairSetupStep1Payload ¶
type PairSetupStep1Payload struct {
State byte `tlv8:"6"`
}
type PairSetupStep2Payload ¶
type PairSetupStep4Payload ¶
type PairSetupStep6Payload ¶
type PairVerifyPayload ¶
type PairVerifySession ¶
type PairVerifySession struct { OtherPublicKey []byte PublicKey [32]byte PrivateKey [32]byte EncryptionKey [32]byte }
func GetPairVerifySession ¶
func GetPairVerifySession(addr string) (*PairVerifySession, error)
type PairingPayload ¶
type ServeMux ¶
type ServeMux interface { // Handle registers the handler for the given pattern. Handle(pattern string, handler http.Handler) // HandleFuncs registers the handler function for the given pattern. HandleFunc(pattern string, handler http.HandlerFunc) }
A ServeMux lets you attach handlers to http url paths.
type Server ¶
type Server struct { // Pin specifies the pincode used to pair // with the accessory. Pin string // Addr specifies the tcp address for the server // to listen to in form of "host:port". // If empty, a random port is used. Addr string MfiCompliant bool // default false Protocol string // default "1.0" SetupId string Key KeyPair // public and private key (generated and stored on disk) // contains filtered or unexported fields }
A server handles incoming HTTP request for an accessory. The server uses dnssd to announce the accessory on the local network.
func NewServer ¶
NewServer returns a new server give a store (to persist data) and accessories. If more than one accessory is added to the server, *a* acts as a bridge.
func (*Server) GetAccessories ¶
func (srv *Server) GetAccessories(res http.ResponseWriter, req *http.Request)
func (*Server) GetCharacteristics ¶
func (srv *Server) GetCharacteristics(res http.ResponseWriter, req *http.Request)
func (*Server) ListenAndServe ¶
ListenAndServe starts the server.
func (*Server) PairSetupStep1 ¶
func (srv *Server) PairSetupStep1(res http.ResponseWriter, req *http.Request, data PairSetupPayload)
func (*Server) PairSetupStep3 ¶
func (srv *Server) PairSetupStep3(res http.ResponseWriter, req *http.Request, data PairSetupPayload)
func (*Server) PairSetupStep5 ¶
func (srv *Server) PairSetupStep5(res http.ResponseWriter, req *http.Request, data PairSetupPayload)
func (*Server) PairVerify ¶
func (srv *Server) PairVerify(res http.ResponseWriter, req *http.Request)
func (*Server) PairVerifyStep1 ¶
func (srv *Server) PairVerifyStep1(res http.ResponseWriter, req *http.Request, data PairVerifyPayload)
func (*Server) PairVerifyStep3 ¶
func (srv *Server) PairVerifyStep3(res http.ResponseWriter, req *http.Request, data PairVerifyPayload)
func (*Server) PutCharacteristics ¶
func (srv *Server) PutCharacteristics(res http.ResponseWriter, req *http.Request)
type Session ¶
type Session struct { Pairing Pairing // contains filtered or unexported fields }
func GetSession ¶
type Store ¶
type Store interface { // Set sets the value for the given key. Set(key string, value []byte) error // Get returns the value for the given key. Get(key string) ([]byte, error) // Delete deletes the value for the given key. Delete(key string) error // KeysWithSuffix returns a list keys with the give suffix. KeysWithSuffix(suffix string) ([]string, error) }
A Store lets you store key-value pairs.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
THIS FILE IS AUTO-GENERATED
|
THIS FILE IS AUTO-GENERATED |
THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED Package characteristic implements the HomeKit characteristics.
|
THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED Package characteristic implements the HomeKit characteristics. |
cmd
|
|
switch
This example show an example of a switch accessory which periodically changes it's state between on and off.
|
This example show an example of a switch accessory which periodically changes it's state between on and off. |
THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED
|
THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED THIS FILE IS AUTO-GENERATED |