Documentation
¶
Overview ¶
Package access manages scheduled access control, the app's parental controls.
The router keeps three tables, each a JSON object keyed by ID: profiles (a named group of client MACs that can be paused), clients (per-client settings keyed by MAC, the router's "devices") and rules (time windows when a profile's clients are blocked, keyed by "<profile ID>.<n>"). Writes take an object of ID -> fields; the router answers {"changed": bool}, which is ignored. The router announces changes with the Device signal ScheduledAccessControlConfigChanged.
Index ¶
- func AddClient(ctx context.Context, c *amplifi.Client, cl Client) error
- func AddProfile(ctx context.Context, c *amplifi.Client, p Profile) (string, error)
- func AddRule(ctx context.Context, c *amplifi.Client, r Rule) (string, error)
- func DeleteClients(ctx context.Context, c *amplifi.Client, macs ...amplifi.MAC) error
- func DeleteProfiles(ctx context.Context, c *amplifi.Client, ids ...string) error
- func DeleteRules(ctx context.Context, c *amplifi.Client, ids ...string) error
- func SetProfilePaused(ctx context.Context, c *amplifi.Client, id string, paused bool) error
- func UpdateClient(ctx context.Context, c *amplifi.Client, mac amplifi.MAC, u ClientUpdate) error
- func UpdateProfile(ctx context.Context, c *amplifi.Client, id string, u ProfileUpdate) error
- func UpdateRule(ctx context.Context, c *amplifi.Client, id string, u RuleUpdate) error
- type Client
- type ClientUpdate
- type DSCP
- type Profile
- type ProfileUpdate
- type Rule
- type RuleUpdate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddProfile ¶
AddProfile creates profile p and returns its ID. An empty p.ID picks one more than the largest numeric ID in use.
func AddRule ¶
AddRule creates rule r and returns its ID. An empty r.ID generates one for r.ProfileID; a given ID must be "<profile ID>.<n>".
func DeleteClients ¶
DeleteClients removes client entries by MAC.
func DeleteProfiles ¶
DeleteProfiles deletes profiles by ID.
func DeleteRules ¶
DeleteRules deletes rules by ID.
func SetProfilePaused ¶
SetProfilePaused blocks (paused true) or unblocks the internet access of every client in profile id.
func UpdateClient ¶
UpdateClient applies u to the client entry for mac.
func UpdateProfile ¶
UpdateProfile applies u to profile id.
func UpdateRule ¶
UpdateRule applies u to rule id.
Types ¶
type Client ¶
type Client struct {
MAC amplifi.MAC `json:"mac"`
Name string `json:"name,omitempty"`
Tag *int `json:"tag,omitempty"`
DSCP *DSCP `json:"dscp,omitempty"`
R2RAccessID string `json:"r2r_access_id,omitempty"`
R2RAccessIDType string `json:"r2r_access_id_type,omitempty"`
R2RPause string `json:"r2r_pause,omitempty"`
}
Client is a client's entry in the access control client table.
type ClientUpdate ¶
ClientUpdate is a partial update of a client entry. Nil fields are left unchanged.
type Profile ¶
type Profile struct {
ID string `json:"id"`
Name string `json:"name"`
Enabled bool `json:"enabled"`
Paused bool `json:"paused"`
Tag *int `json:"tag,omitempty"`
Clients []amplifi.MAC `json:"clients"`
}
Profile is a scheduled access control profile: a set of clients that rules and pausing apply to.
type ProfileUpdate ¶
ProfileUpdate is a partial update of a profile. Nil fields are left unchanged; a non-nil Clients replaces the whole member list.
type Rule ¶
type Rule struct {
ID string `json:"id"`
ProfileID string `json:"profile_id"`
Description string `json:"description,omitempty"`
Enabled bool `json:"enabled"`
Start time.Duration `json:"start"`
Duration time.Duration `json:"duration"`
WeekDays []time.Weekday `json:"week_days"`
}
Rule is a time window during which the clients of profile ProfileID are blocked. Start is the time of day as a duration since midnight; Duration is at most 24 hours. Both have minute resolution.
func Rules ¶
Rules lists the scheduled access control rules of all profiles, ordered by ID. The app's GetScheduledAccessControlRules2 is this same call with a different parser.
func (Rule) MarshalJSON ¶
MarshalJSON renders Start and Duration in seconds and the week days by name.