access

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddClient

func AddClient(ctx context.Context, c *amplifi.Client, cl Client) error

AddClient adds cl to the client table under cl.MAC.

func AddProfile

func AddProfile(ctx context.Context, c *amplifi.Client, p Profile) (string, error)

AddProfile creates profile p and returns its ID. An empty p.ID picks one more than the largest numeric ID in use.

func AddRule

func AddRule(ctx context.Context, c *amplifi.Client, r Rule) (string, error)

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

func DeleteClients(ctx context.Context, c *amplifi.Client, macs ...amplifi.MAC) error

DeleteClients removes client entries by MAC.

func DeleteProfiles

func DeleteProfiles(ctx context.Context, c *amplifi.Client, ids ...string) error

DeleteProfiles deletes profiles by ID.

func DeleteRules

func DeleteRules(ctx context.Context, c *amplifi.Client, ids ...string) error

DeleteRules deletes rules by ID.

func SetProfilePaused

func SetProfilePaused(ctx context.Context, c *amplifi.Client, id string, paused bool) error

SetProfilePaused blocks (paused true) or unblocks the internet access of every client in profile id.

func UpdateClient

func UpdateClient(ctx context.Context, c *amplifi.Client, mac amplifi.MAC, u ClientUpdate) error

UpdateClient applies u to the client entry for mac.

func UpdateProfile

func UpdateProfile(ctx context.Context, c *amplifi.Client, id string, u ProfileUpdate) error

UpdateProfile applies u to profile id.

func UpdateRule

func UpdateRule(ctx context.Context, c *amplifi.Client, id string, u RuleUpdate) error

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.

func Clients

func Clients(ctx context.Context, c *amplifi.Client) ([]Client, error)

Clients lists the access control client table, ordered by MAC.

type ClientUpdate

type ClientUpdate struct {
	Name *string
	Tag  *int
	DSCP *DSCP
}

ClientUpdate is a partial update of a client entry. Nil fields are left unchanged.

type DSCP

type DSCP int

DSCP is the traffic priority the app assigns to a client.

const (
	DSCPNone      DSCP = 0
	DSCPStreaming DSCP = 40
	DSCPGaming    DSCP = 56
)

DSCP values the app uses.

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.

func Profiles

func Profiles(ctx context.Context, c *amplifi.Client) ([]Profile, error)

Profiles lists the scheduled access control profiles, ordered by ID.

type ProfileUpdate

type ProfileUpdate struct {
	Name    *string
	Paused  *bool
	Clients []amplifi.MAC
}

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

func Rules(ctx context.Context, c *amplifi.Client) ([]Rule, error)

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

func (r Rule) MarshalJSON() ([]byte, error)

MarshalJSON renders Start and Duration in seconds and the week days by name.

type RuleUpdate

type RuleUpdate struct {
	Description *string
	Enabled     *bool
	Start       *time.Duration
	Duration    *time.Duration
	WeekDays    []time.Weekday
}

RuleUpdate is a partial update of a rule. Nil fields are left unchanged.

Jump to

Keyboard shortcuts

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