💾 Archived View for code.pfad.fr › fritzgox › upnp captured on 2023-12-28 at 15:34:08. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-09-08)

🚧 View Differences

-=-=-=-=-=-=-

upnp package - code.pfad.fr/fritzgox

import "code.pfad.fr/fritzgox/upnp"

package upnp allows to query the un-authenticated UPnP fritzbox endpoints (with stats regarding the internet connection for instance).

Types

type Client

type Client struct {
	BaseURL    string
	Services   map[string]*service // Services will be populated on "NewClient"
	HTTPClient *http.Client
}

func NewClient

func NewClient(addr string, client *http.Client) (*Client, error)

NewClient creates a new UPnP client and discover the services.

Argument addr should not have a trailing slash (usually [http://192.168.178.1:49000]). If client is nil, http.DefaultClient will be used.

http://192.168.178.1:49000

func (Client) GetStrings

func (c Client) GetStrings(service, action string) (map[string]string, error)

GetStrings retrieves the values associated with the given (service, action). Call ListServicesActionsVariables to get the list of availables services, actions and variables.

func (Client) ListServicesActionsVariables

func (c Client) ListServicesActionsVariables() (map[string]map[string][]string, error)

ListServicesActionsVariables returns a list of services, with associated actions and variable names. See Example.

Example
package main

import (
	"fmt"

	"code.pfad.fr/fritzgox/upnp"
)

func main() {
	c, _ := upnp.NewClient("http://192.168.178.1:49000", nil)
	svc, _ := c.ListServicesActionsVariables()
	for s, actions := range svc {
		fmt.Println(s)
		for a, vars := range actions {
			fmt.Println(" - " + a)
			for _, v := range vars {
				fmt.Println("    " + v)
			}
		}
	}
}

Files

service.go

upnp.go

Breadcrumb

code.pfad.fr/fritzgox