Documentation
¶
Index ¶
- Constants
- Variables
- func ConnectWithPassword(loginID string, password string, caCert *x509.Certificate, connectURL string, ...) (cc messaging.IClientConnection, token string, err error)
- func ConnectWithToken(clientID string, token string, caCert *x509.Certificate, connectURL string, ...) (cc messaging.IClientConnection, err error)
- func ConnectWithTokenFile(clientID string, keysDir string, connectURL string, timeout time.Duration) (cc messaging.IClientConnection, token string, caCert *x509.Certificate, ...)
- func GetProtocolFromURL(fullURL string) string
- func LoadCA(caDir string) (*x509.Certificate, error)
- func LoadToken(clientID string, keysDir string) (string, error)
- func NewHiveotClient(clientID string, caCert *x509.Certificate, connectURL string, ...) (cc messaging.IClientConnection, err error)
Constants ¶
const TokenFileExt = ".token"
TokenFileExt defines the filename extension under which client tokens are stored in the keys directory.
Variables ¶
var DefaultTimeout = time.Second * 3
Functions ¶
func ConnectWithPassword ¶
func ConnectWithPassword( loginID string, password string, caCert *x509.Certificate, connectURL string, authURL string, timeout time.Duration) ( cc messaging.IClientConnection, token string, err error)
ConnectWithPassword is a convenience function to authenticate with a password and create a secured client connection using a CA from the directory.
This discovers the server if no URL is provided or the url is not able to authenticate.
loginID is the clientID to login as password to authenticate with caCert is the server CA. See also LoadCA() connectURL of the server to connect to, or "" to use discovery authURL of the authentication server, or "" to use connectURL
This returns the client connection with the authentication token used or an error if invalid
func ConnectWithToken ¶
func ConnectWithToken( clientID string, token string, caCert *x509.Certificate, connectURL string, timeout time.Duration) ( cc messaging.IClientConnection, err error)
ConnectWithToken is a convenience function to create a client and connect with a token and CA certificate.
clientID to identify as token to authenticate with caCert of the server for validating the SSL connect connectURL is the optional URL of the server. Leave empty to auto-discover timeout is optional connection timeout or 0 for default
This returns the client connection or an error if invalid
func ConnectWithTokenFile ¶
func ConnectWithTokenFile(clientID string, keysDir string, connectURL string, timeout time.Duration) ( cc messaging.IClientConnection, token string, caCert *x509.Certificate, err error)
ConnectWithTokenFile is a convenience function to create a connection using a saved token and optional CA file. This is similar to ConnectWithToken but reads a token and CA from file.
clientID to identify as
keysDir is the directory with the {clientID}.key, {clientID}.token and caCert.pem files.
connectURL is the full connection URL of the server to connect to.
timeout is optional connection timeout or 0 for default
This returns the connection, token and CaCert used or an error if invalid
func GetProtocolFromURL ¶
GetProtocolFromURL determines which transport protocol type the URL represents This returns an empty string if the protocol cannot be determined
fullURL contains the full server address as provided by discovery:
WARNING: hiveot can use a different protocol for the sse and wss schemas. In case of doubt the hiveot protocol is used.
https://addr:port/ for http-basic sse://addr:port/hiveot/sse for hiveot sse-sc subprotocol binding sse://addr:port/... default WoT SSE (not supported) wss://addr:port/wss path for websocket direct messaging mqtts://addr:port/ for mqtt over websocket over TLS
func LoadCA ¶
func LoadCA(caDir string) (*x509.Certificate, error)
LoadCA is a simple helper to load the default CA from file
func NewHiveotClient ¶
func NewHiveotClient( clientID string, caCert *x509.Certificate, connectURL string, timeout time.Duration) ( cc messaging.IClientConnection, err error)
NewHiveotClient returns a new unconnected client ready for connecting to a hiveot server. Intended for use with the hiveot hub, but should be usable with other hiveot servers.
Note 1: This doesnt use forms as request/response envelopes dont need it.
clientID is the ID to authenticate as when using one of the Connect... methods caCert is the server's CA certificate to verify the connection. connectURL contains the connection URL for the protocol. timeout is optional maximum wait time for connecting or waiting for responses.
If no connectURL is specified then this uses discovery to determine the best protocol.
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package discovery with client for DNS-SD service discovery
|
Package discovery with client for DNS-SD service discovery |