Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DoWithRetry ¶
func DoWithRetry[T interface{}](c *FritzBoxClientWithRefresh, reqFactory func() *http.Request, res *T) error
DoWithRetry executes the given do request for the fritzbox client
Types ¶
type FritzBoxClientWithRefresh ¶
type FritzBoxClientWithRefresh struct {
// contains filtered or unexported fields
}
func CreateAuthenticatedFritzBoxClient ¶
func CreateAuthenticatedFritzBoxClient(config *config.AppConfig) (*FritzBoxClientWithRefresh, error)
CreateAuthenticatedFritzBoxClient generates an fritzbox client based on given configuration. After parsing the url a login is attempted, if that fails an error is returned
func NewFritzBoxClientWithRefresh ¶
func NewFritzBoxClientWithRefresh(c *http.Client, endpoint *url.URL) FritzBoxClientWithRefresh
func (*FritzBoxClientWithRefresh) Auth ¶
func (c *FritzBoxClientWithRefresh) Auth(username string, password string) error
Auth sends a auth request and returns an error, if any. Session is stored in client in order to perform requests with authentification.
func (*FritzBoxClientWithRefresh) Do ¶
Do executes the given request. If it leads to a expired session error it updates the session
func (*FritzBoxClientWithRefresh) NewRequest ¶
func (c *FritzBoxClientWithRefresh) NewRequest(method, urlStr string, data url.Values) (*http.Request, error)
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 NetDevicesResponse ¶
type NetDevicesResponse struct { Data struct { Active []struct { Mac string `json:"mac"` Name string `json:"name"` State struct { Class string `json:"class"` } `json:"state"` } `json:"active"` } `json:"data"` }
NetDevicesResponse represents the Fritz!Box data request to get all network devices known
func GetNetDevices ¶
func GetNetDevices(c *FritzBoxClientWithRefresh) (response *NetDevicesResponse, err error)
GetNetDevices loads all known devices from fritzbox using the specified client
type UsersOnlineMapping ¶
UsersOnlineMapping is indexed by the human-readable username and a list of all devices currently connected for them
func CreateUsersOnlineMapping ¶
func CreateUsersOnlineMapping() UsersOnlineMapping
func MapToOnlineUsers ¶
func MapToOnlineUsers(netDevicesRes *NetDevicesResponse, includeOffline bool) UsersOnlineMapping
MapToOnlineUsers takes a given net devices response and transforms it into the user mapping