Documentation ¶
Index ¶
Constants ¶
const ( // DefaultSid is an invalid session in order to perform and // identify logouts. DefaultSid = "0000000000000000" // DefaultExpires is the amount of time of inactivity before // the FRITZ!Box automatically closes a session. DefaultExpires = 10 * time.Minute )
Variables ¶
var ( // ErrInvalidCred is the error returned by Auth when // login attempt is not successful. ErrInvalidCred = errors.New("fritzbox: invalid credentials") // ErrExpiredSess means that client was too long inactive. ErrExpiredSess = errors.New("fritzbox: session expired") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // Base URL for requests. Defaults to the local fritzbox, but // can be set to a domain endpoint to use with an external FRITZ!Box. // BaseURL should always be specified with a trailing slash. BaseURL *url.URL // contains filtered or unexported fields }
A Client manages communication with the FRITZ!Box
func NewClient ¶
NewClient returns a new FRITZ!Box client. If a nil httpClient is provided, http.DefaultClient will be used. To use an external FRITZ!Box with a self-signed certificate, provide an http.Client that will be able to perform insecure connections (such as InsecureSkipVerify flag).
func (*Client) Auth ¶
Auth sends a auth request and returns an error, if any. Session is stored in client in order to perform requests with authentification.
func (*Client) Do ¶
Do sends a request and returns the response. The response is either JSON decoded or XML encoded and stored in the value pointed to by v, or returned as an error, if any.
func (*Client) NewRequest ¶
NewRequest creates an API request. A relative URL can be provided in urlStr in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by data is Query encoded and included as the request body in order to perform form requests.
type Session ¶
type Session struct { XMLName xml.Name `xml:"SessionInfo"` Sid string `xml:"SID"` Challenge string `xml:"Challenge"` BlockTime time.Duration `xml:"BlockTime"` // Rights' representation is a little bit tricky // TODO: Write UnmarshalXML to merge them RightsName []string `xml:"Rights>Name"` RightsAccess []int8 `xml:"Rights>Access"` // Session expires after 10 minutes Expires time.Time `xml:"-"` // contains filtered or unexported fields }
Session represents a FRITZ!Box session
func (*Session) Auth ¶
Auth sends the Response (Challenge-Response) to the FRITZ!Box and returns an error, if any.