response

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UnmarshalCustomAs

func UnmarshalCustomAs[T any](response []byte) (T, error)

func UnmarshalRaw

func UnmarshalRaw(response []byte) (map[string]interface{}, error)

Types

type BoxType

type BoxType string
const (
	BoxTypeDSL BoxType = "dsl"
)
const (
	DevTypeFritzBox BoxType = "fritzbox"
)

type BridgeModeType

type BridgeModeType string

BridgeModeType [unidentified]

const (
	BridgeModeTypeWlan BridgeModeType = "wlan_bridge"
)

type CategoryType

type CategoryType string

CategoryType is the type of category the device is in the topology

const (
	CategoryOwn  CategoryType = "ownentry"
	CategoryLan  CategoryType = "lan"
	CategoryWlan CategoryType = "wlan"
)

type ConnectionInfo

type ConnectionInfo struct {
	Kind  ConnectionType `json:"kind"`  // Kind is the type of connection
	Speed string         `json:"speed"` // Speed is the speed of the connection with unit (ex. 100 MBit/s or 1 GBit/s)
	Desc  string         `json:"desc"`  // Desc is a description of the connection (ex. LAN 1 or 2.4GHz, 5GHz)

	UsedBands int `json:"usedbands"` // UsedBands is the number of wlan bands used by the device
	// BandInfo is the information about the wlan band used
	BandInfo []struct {
		Band    int    `json:"band"`     // Band is the band number
		SpeedTx int    `json:"speed_tx"` // SpeedTx is the speed of the connection in transmit direction in mbit/s
		SpeedRx int    `json:"speed_rx"` // SpeedRx is the speed of the connection in receive direction in mbit/s
		Speed   string `json:"speed"`    // Speed is the speed of the connection with unit (ex. 100 MBit/s or 1 GBit/s)
		Desc    string `json:"desc"`     // Desc is a description of the connection (ex. 2.4GHz, 5GHz)
	} `json:"bandinfo"`
}

ConnectionInfo is the information about the connection to the router

type ConnectionType

type ConnectionType string

ConnectionType is the type of connection the device has to the network

const (
	ConnectionTypeAny  ConnectionType = "any"
	ConnectionTypeLan  ConnectionType = "lan"
	ConnectionTypeWlan ConnectionType = "wlan"
)

type DNSInfo

type DNSInfo struct {
	Edns0Mode string `json:"edns0_mode"`
	Type      string `json:"type"`
	IP        string `json:"ip"`
	Purpose   string `json:"purpose"`
}

type DataResponse

type DataResponse[T any] struct {
	PageId string `json:"pid"`
	// TODO: figure out what 'hide' does and how its defined
	// It seems to be a map of true values configuring a set of ui options that should be hidden
	Hide           map[string]bool `json:"hide"`
	TimeTillLogout string          `json:"timeTillLogout"`
	// TODO: figure out what 'time' does and how its defined
	// Until now it only saw empty arrays for this field
	Time []any  `json:"time"`
	Data T      `json:"data"`
	Sid  string `json:"sid"`
}

func UnmarshalAs

func UnmarshalAs[T any](response []byte) (DataResponse[T], error)

type Detailinfo

type Detailinfo struct {
	Wlan24      bool `json:"wlan24"`      // Wlan24 whether the 2.4GHz wlan is enabled
	Wlan5       bool `json:"wlan5"`       // Wlan5 whether the 5GHz wlan is enabled
	GuestAccess bool `json:"guestaccess"` // GuestAccess whether a guest network is enabled

	Edit struct {
		// Pid [unidentified] seems to be the page id of the edit page
		Pid string `json:"pid"`
		// Params [unidentified] seem to be url parameters for navigation actions
		// known params are:
		//   - dev -> device.UID
		//   - back_to_page -> homeNet (current page id)
		Params map[string]string `json:"params"`
	} `json:"edit"`
	PortRelease bool `json:"portrelease"`
}

DetailInfo is information about details of the device (in the ui)

type DevType

type DevType string

type Energy

type Energy struct {
	Intro struct {
		Text []string `json:"text"`
	} `json:"intro"`
	Drain []EnergyDrainInfo `json:"drain"`
}

type EnergyDrainInfo

type EnergyDrainInfo struct {
	CurrentPercentage     int             `json:"actPerc"`                      // CurrentPercentage is the current percentage of energy usage
	AccumulatedPercentage int             `json:"cumPerc"`                      // AccumulatedPercentage is the accumulated percentage of the last 24 hours
	Name                  string          `json:"name"`                         // Name is the name of the metric
	Statuses              []string        `json:"statuses" transform:"toSlice"` // Statuses is the status of the metric
	Lan                   []EnergyLanInfo `json:"lan"`                          // Lan is the status of the lan ports (usually only in the last element)
}

type EnergyLanInfo

type EnergyLanInfo struct {
	Name  string       `json:"name"`
	Class LanInfoClass `json:"class"`
}

type FirmwareCheck

type FirmwareCheck struct {
	NotDone bool `json:"notdone"`
	NoCheck bool `json:"nocheck"`
	Auto    bool `json:"auto"`
	Started bool `json:"started"`
}

FirmwareCheck is the status of the firmware check

type HomeNet

type HomeNet struct {
	Searching bool `json:"searching"` // Searching [unidentified]
	IPClient  bool `json:"ipclient"`  // IPClient [unidentified]
	// Updating [unidentified]
	// NOTE: this may be connected to a request field 'updating'
	// it may be in realtion to probably partial ui updates but the
	// responses don't seem to be reduced in size
	Updating      string        `json:"updating"`
	Devices       []MeshDevice  `json:"devices"`     // Devices is a list of all devices currently connected to the (mesh)-network
	Topology      Topology      `json:"topology"`    // Topology is a hierarchical representation of the currently connected devices in the network
	FirmwareCheck FirmwareCheck `json:"fwcheck"`     // FirmwareCheck [unidentified] seems to be status of the firmware check
	NexusClient   bool          `json:"nexusclient"` // NexusClient [unidentified]
}

HomeNet is the response of requests send by the mesh Site

type IPv4Info

type IPv4Info struct {
	Node        string `json:"_node"`    // Node [unidentified]
	AddressType string `json:"addrtype"` // AddressType is the type of the address (eg. ipv4)
	Dhcp        string `json:"dhcp"`     // DHCP is whether the device uses DHCP (values: "1" or "0")
	LastUsed    string `json:"lastused"` // LastUsed is the last time the device was used
	IP          string `json:"ip"`       // IP is the ipv4 address of the device
}

IPv4 is the ipv4 address of the device

type InternetConnection

type InternetConnection struct {
	Name             string                   `json:"name"`
	Connected        bool                     `json:"connected"`
	Active           bool                     `json:"active"`
	DslDiagnosis     bool                     `json:"dsl_diagnosis"`
	DirectConnection bool                     `json:"direct_connection"`
	ReadyForFallback bool                     `json:"ready_for_fallback"`
	ShapedRate       bool                     `json:"shapedrate"`
	SpeedManual      bool                     `json:"speed_manual"`
	Downstream       int                      `json:"downstream"`        // in kbit/s
	MediumDownstream int                      `json:"medium_downstream"` // in kbit/s
	Upstream         int                      `json:"upstream"`          // in kbit/s
	MediumUpstream   int                      `json:"medium_upstream"`   // in kbit/s
	Role             string                   `json:"role"`
	Provider         string                   `json:"provider"`
	State            InternetConnectionState  `json:"state"`
	Type             InternetConnectionType   `json:"type"`
	Medium           InternetConnectionMedium `json:"medium"`

	IPv4 struct {
		Connected bool      `json:"connected"`
		IP        string    `json:"ip"`
		Since     int       `json:"since"`
		DNS       []DNSInfo `json:"dns"`
		DSLite    bool      `json:"dslite"`
		Ipv6AFTR  string    `json:"ipv6_aftr"`
	} `json:"ipv4"`
	Ipv6 struct {
		Connected  bool   `json:"connected"`
		IP         string `json:"ip"`
		Since      int    `json:"since"`
		IPLifetime struct {
			Valid     int `json:"valid"`
			Preferred int `json:"preferred"`
		} `json:"ip_lifetime"`
		Prefix         string `json:"prefix"`
		PrefixLifetime struct {
			Valid     int `json:"valid"`
			Preferred int `json:"preferred"`
		} `json:"prefix_lifetime"`
		DNS []DNSInfo `json:"dns"`
	} `json:"ipv6"`
}

InternetConnection is the connection information of the device

type InternetConnectionMedium

type InternetConnectionMedium string
const (
	InternetConnectionMediumDSL InternetConnectionMedium = "dsl"
)

type InternetConnectionState

type InternetConnectionState string
const (
	InternetConnectionStateConnected InternetConnectionState = "connected"
)

type InternetConnectionType

type InternetConnectionType string
const (
	InternetConnectionTypeDSL InternetConnectionType = "dsl"
)

type LanInfoClass

type LanInfoClass string
const (
	LanInfoClassGreen LanInfoClass = "green"
)

type Log

type Log struct {
	// Show seems to be the available filter options
	Show struct {
		All     bool `json:"all"`
		System  bool `json:"sys"`
		Network bool `json:"net"`
		Phone   bool `json:"fon"`
		USB     bool `json:"usb"`
		WLAN    struct {
			WPA2Support bool `json:"has_wpa2_support"`
			WPA3Support bool `json:"has_wpa3_support"`
		} `json:"wlan"`
	} `json:"show"`
	Logs              []LogEntry `json:"log"`               // Logs the system logs
	Filter            LogFilter  `json:"filter"`            // Filter the currently applied log filter
	WLANGuestPushMail bool       `json:"wlanGuestPushmail"` // WLANGuestPushMail [unidentified]
	WLAN              bool       `json:"wlan"`              // WLAN [unidentified]
}

type LogEntry

type LogEntry struct {
	ID      int       `json:"id"`     // ID seem to be the type of the log entry (the help link will show help according to the id)
	Time    string    `json:"time"`   // Time is the time of the log entry
	Group   LogFilter `json:"group"`  // Group is the group of the log entry
	Message string    `json:"msg"`    // Message is the message of the log entry
	Date    string    `json:"date"`   // Date is the date of the log entry
	NoHelp  int       `json:"noHelp"` // NoHelp seems to be a flag if the help link should be shown
}

type LogFilter

type LogFilter string
const (
	LogFilterAll  LogFilter = "all"
	LogFilterSys  LogFilter = "sys"
	LogFilterNet  LogFilter = "net"
	LogFilterFon  LogFilter = "fon"
	LogFilterUSB  LogFilter = "usb"
	LogFilterWLAN LogFilter = "wlan"
)

type MeshDevice

type MeshDevice struct {
	UID             string         `json:"UID"`               // UID is the unique identifier of the device in the mesh topology
	OwnEntry        bool           `json:"ownentry"`          // OwnEntry is whether the device is itself
	OwnClientDevice bool           `json:"own_client_device"` // OwnClientDevice is whether this device is the currently interacting client
	Master          bool           `json:"master"`            // Master is whether the device is the master device
	Dist            int            `json:"dist"`              // Dist [unidentified] this seems to be the distance (in nodes) to the root device in the mesh
	Parent          string         `json:"parent"`            // Parent the parent device in the topology view
	Children        []string       `json:"children"`          // Children is a list of all devices connected to this device
	Category        CategoryType   `json:"category"`          // Category the category of the device in the topology (ownentry for the root device)
	ConnectionType  ConnectionType `json:"conn"`              // ConnectionType the type of connection (any for the root device)
	Switch          bool           `json:"switch"`            // Switch [unidentified] might be whether the devices acts like a switch
	DevType         DevType        `json:"devtype"`           // DevType the type of the device
	IPInfo          string         `json:"ipinfo"`            // IPInfo [unidentified] seems to be the ip address of the device
	Gateway         bool           `json:"gateway"`           // Gateway [unidentified]
	BoxType         BoxType        `json:"boxType"`           // BoxType [unidentified] seems to be the type of the fritz box

	NameInfo    NameInfo            `json:"nameinfo"`                              // NameInfo is the name information of the device
	VersionInfo VersionInfo         `json:"versioninfo" transform:"extendedEmpty"` // VersionInfo is the version information of the device
	StateInfo   MeshDeviceStateInfo `json:"stateinfo"`                             // StateInfo is the state information of the device
	UpdateInfo  UpdateInfo          `json:"updateinfo"`                            // UpdateInfo is the software update information of the device (none for unknown/"normal" devices)
	PhoneInfo   PhoneInfo           `json:"phone"`                                 // PhoneInfo is the phone information of the device (only for the root device)
	WlanInfo    []WlanInfo          `json:"wlaninfo"`                              // WlanInfo is the information about wlan networks exposed by the device
	Detailinfo  Detailinfo          `json:"detailinfo"`                            // Detailinfo is information about details of the device (in the ui)
	ConnInfo    ConnectionInfo      `json:"conninfo" transform:"extendedEmpty"`    // ConnectionInfo is the information about the connection to the router

	Connections []InternetConnection `json:"connections"` // Connections is a list of all connections the device has to the internet (only for the root device)
}

MeshDevice is a device connected to the network

type MeshDeviceStateInfo

type MeshDeviceStateInfo struct {
	Active bool `json:"active"` // Active whether the device is currently active

	GuestOwe        bool `json:"guest_owe"`       // GuestOwe [unidentified]
	Meshable        bool `json:"meshable"`        // Meshable [unidentified]
	Guest           bool `json:"guest"`           // Guest [unidentified] may be whether the device is a guest
	Online          bool `json:"online"`          // Online whether the device is currently online
	Blocked         bool `json:"blocked"`         // Blocked [unidentified]
	Realtime        bool `json:"realtime"`        // Realtime [unidentified]
	NotAllowed      bool `json:"notallowed"`      // NotAllowed [unidentified]
	InternetBlocked bool `json:"internetBlocked"` // InternetBlocked [unidentified]

	NexusTrust bool `json:"nexustrust"` // NexusTrust [unidentified] {only when the device is a FRITZ!-device}
}

MeshDeviceStateInfo is information about the state of the device

type ModelType

type ModelType string

ModelType [unidentified] seems to be the group of the device

const (
	ModelTypeFritzBox ModelType = "fbox"
	ModelTypeActive   ModelType = "active"
	ModelTypePassive  ModelType = "passive"
)

type NameInfo

type NameInfo struct {
	Name    string `json:"name"`    // Name is the name of the device
	Product string `json:"product"` // Product is the product name of the device (only when the device is a FRITZ!-device)
	URL     string `json:"url"`     // URL is an optional url to the device (only when the device has a web interface)
}

NameInfo is information about the name of the device

type NetCnt

type NetCnt struct {
	LastMonth UsageMetric `json:"LastMonth"`
	ThisWeek  UsageMetric `json:"ThisWeek"`
	Today     UsageMetric `json:"Today"`
	Yesterday UsageMetric `json:"Yesterday"`
	ThisMonth UsageMetric `json:"ThisMonth"`
}

type NetDev

type NetDev struct {
	IPClient    bool           `json:"ipclient"`    // IPClient [unidentified]
	IsRepeater  bool           `json:"isrepeater"`  // IsRepeater [unidentified]
	IsPowerline bool           `json:"ispowerline"` // IsPowerline [unidentified]
	Initial     bool           `json:"initial"`     // Initial [unidentified]
	NexusClient bool           `json:"nexusclient"` // NexusClient [unidentified]
	BackToPage  string         `json:"backToPage"`  // BackToPage [unidentified]
	BridgeMode  BridgeModeType `json:"bridgeMode"`  // BridgeMode [unidentified]

	FritzBoxOther []NetworkDevice `json:"fbox_other"` // FritzBoxOther [unidentified]
	FritzBox      []NetworkDevice `json:"fbox"`       // FritzBox [unidentified]

	Active  []NetworkDevice `json:"active"`  // Active [unidentified]
	Passive []NetworkDevice `json:"passive"` // Passive [unidentified]

	FritzBoxTitle     string `json:"fbox_title"`     // FritzBoxTitle [unidentified]
	TitleDeviceAdd    string `json:"titledeviceadd"` // TitleDeviceAdd [unidentified]
	TitleDeviceDelete string `json:"titledevicedel"` // TitleDeviceDelete [unidentified]
}

NetDev is the response of requests send by the network devices Site

type NetworkDevice

type NetworkDevice struct {
	UID             string             `json:"UID"`               // UID is the unique identifier of the device
	Mac             string             `json:"mac"`               // Mac is the mac address of the device
	OwnClientDevice bool               `json:"own_client_device"` // OwnClientDevice is whether this device is the currently interacting client
	Type            NetworkDeviceClass `json:"type"`              // Type [unidentified] seems to be the type of the connection
	Classes         NetworkDeviceClass `json:"classes"`           // Classes [unidentified] seems to be always the same as type
	Port            string             `json:"port"`              // Port on which the device is connected to the fritz box (eg. WLAN or LAN 2 mit 1 Gbit/s)
	Name            string             `json:"name"`              // Name of the device
	Model           ModelType          `json:"model"`             // Model [unidentified] seems to be the group of the device
	BoxType         BoxType            `json:"boxType"`           // BoxType [unidentified] seems to be the type of the fritz box
	URL             string             `json:"url"`               // URL is the URL to the device in the web ui

	Connections []InternetConnection `json:"connections"` // Connections is a list of all connections the device has to the internet (only fbox devices)

	Options    NetworkDeviceOptions    `json:"options"`                         // Options are additional options of the device displayed in the ui
	Parent     NetworkDeviceParent     `json:"parent"`                          // Parent [unidentified]
	Properties []NetworkDeviceProperty `json:"properties"`                      // Properties are additional properties of the device displayed in the ui
	State      NetworkDeviceStateInfo  `json:"state" transform:"extendedEmpty"` // State is the connection state displayed in the ui
	IPv4       IPv4Info                `json:"ipv4"`                            // IPv4 is the ipv4 address of the device
}

type NetworkDeviceClass

type NetworkDeviceClass string

NetworkDeviceClass classifies the devices by connection type

const (
	NetWorkDeviceClassWlan     NetworkDeviceClass = "wlan"
	NetWorkDeviceClassEthernet NetworkDeviceClass = "ethernet"
	NetWorkDeviceClassUnknown  NetworkDeviceClass = "unknown"
)

type NetworkDeviceOptions

type NetworkDeviceOptions struct {
	Guest      bool `json:"guest"`
	Editable   bool `json:"editable"`
	Deleteable bool `json:"deleteable"`
	Disable    bool `json:"disable"`
}

Options are additional options of the device displayed in the ui

type NetworkDeviceParent

type NetworkDeviceParent struct {
	Name string `json:"name"`
	URL  string `json:"url"`
}

Parent [unidentified]

type NetworkDeviceProperty

type NetworkDeviceProperty struct {
	Txt     string `json:"txt"`
	OnClick string `json:"onclick"`
	Icon    string `json:"icon"`
	Link    string `json:"link"`
}

Properties are additional properties of the device displayed in the ui

type NetworkDeviceStateClass

type NetworkDeviceStateClass string

NetworkDeviceStateClass classifies the connection state of the device

const (
	NetworkDeviceStateClassLedGreen    NetworkDeviceStateClass = "led_green"
	NetworkDeviceStateClassGlobeOnline NetworkDeviceStateClass = "globe_online"
)

type NetworkDeviceStateInfo

type NetworkDeviceStateInfo struct {
	Class NetworkDeviceStateClass `json:"class"`
}

State is the connection state displayed in the ui

type PhoneInfo

type PhoneInfo struct {
	NumberCount int `json:"numberCount"` // NumberCount is the number of available phone numbers
	ActiveCount int `json:"activeCount"` // ActiveCount is the number of active phone numbers
}

PhoneInfo is information about available phone numbers of the device

type Right struct {
	Name   string `xml:"Name"`
	Access int    `xml:"Access"`
}

type SessionInfo

type SessionInfo struct {
	XMLName     xml.Name `xml:"SessionInfo"`
	SID         string   `xml:"SID"`           // SID is the current session id
	Challenge   string   `xml:"Challenge"`     // Challenge is the challenge string for login
	BlockTime   int      `xml:"BlockTime"`     // BlockTime is the time in seconds until the next login attempt is allowed
	Users       []User   `xml:"Users>User"`    // Users is a list of users
	RightName   []string `xml:"Rights>Name"`   // RightName is a list of rights
	RightAccess []int    `xml:"Rights>Access"` // RightAccess is a list of access for those rights
}

func (SessionInfo) GetRights

func (s SessionInfo) GetRights() []Right

type Topology

type Topology struct {
	RootDeviceId string                `json:"rootuid"`
	Devices      map[string]MeshDevice `json:"devices"`
}

Topology is a hierarchical representation of the currently connected devices in the network

type UpdateInfo

type UpdateInfo struct {
	State UpdateInfoState `json:"state"` // State is the state of the software update info
}

UpdateInfo is the software update information of the device

type UpdateInfoState

type UpdateInfoState string
const (
	UpdateInfoStateCurrent UpdateInfoState = "current"
	UpdateInfoStateNone    UpdateInfoState = "none"
)

type UsageMetric

type UsageMetric struct {
	BytesSentHigh     int64 `json:"BytesSentHigh" transform:"stringToInt"`
	BytesSentLow      int64 `json:"BytesSentLow" transform:"stringToInt"`
	BytesReceivedHigh int64 `json:"BytesReceivedHigh" transform:"stringToInt"`
	BytesReceivedLow  int64 `json:"BytesReceivedLow" transform:"stringToInt"`
}

type User

type User struct {
	Last int    `xml:"last,attr"`
	Name string `xml:",chardata"`
}

type VersionInfo

type VersionInfo struct {
	Version string `json:"version"` // Version is the version of the device
	Fos     bool   `json:"fos"`     // Fos [unidentified]
}

VersionInfo information about the version of the device

type WlanInfo

type WlanInfo struct {
	Text       string `json:"text"`       // Text is the name (SSID) of the wlan network
	Title      string `json:"title"`      // Title is the title of the wlan network (ex. WLAN-Funknetz or Gastfunknetz)
	ShortTitle string `json:"shorttitle"` // ShortTitle is a shorter version of the title
}

WlanInfo is the information about wlan networks exposed by the device

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL