networks

package
v0.0.0-...-8baf154 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const BYPASS_FILTERING = 1
View Source
const DISABLED = -1
View Source
const ENABLE_FILTERING = 0
View Source
const SSID_SOURCE_TYPE = 2
View Source
const (

	// Wifis return list of sites for network controller
	Wifis = networksPrefix + "/wifis/{ssid}"
)

Variables

This section is empty.

Functions

func IsSpeedLimitEqual

func IsSpeedLimitEqual(
	speedLimitEnable *bool,
	speedLimit *int,
	speedLimitType *int,
	requestSpeedLimit *int) bool

func NewBool

func NewBool(b bool) *bool

func NewInt

func NewInt(num int) *int

func NewStr

func NewStr(str string) *string

Types

type Controller

type Controller interface {
	GetWifi(w http.ResponseWriter, r *http.Request)
	UpdateWifi(w http.ResponseWriter, r *http.Request)
}

func NewController

func NewController(config *config.Configuration) Controller

Creates new networks controller

func NewControllerWithParams

func NewControllerWithParams(config *config.Configuration,
	ufc UrlFilterController, r Repository) Controller

Creates a new controller with additional dependencies for tests

type Data

type Data struct {
	// common params
	Id     *string `json:"id,omitempty"`
	Name   *string `json:"name,omitempty"`
	SiteId *string `json:"siteid,omitempty"`
	Policy *int    `json:"policy,omitempty"`

	// ssid params
	Band               *int               `json:"band,omitempty"`
	WlanId             *string            `json:"wlanid,omitempty"`
	VlanEnable         *bool              `json:"vlanEnable,omitempty"`
	VlanId             *int               `json:"vlanId,omitempty"`
	Broadcast          *bool              `json:"broadcast,omitempty"`
	Security           *int               `json:"security,omitempty"`
	GuestNetEnable     *bool              `json:"guestNetEnable,omitempty"`
	WlanScheduleEnable *bool              `json:"wlanScheduleEnable,omitempty"`
	Action             *int               `json:"action,omitempty"`
	ScheduleId         *string            `json:"scheduleId,omitempty"`
	MacFilterEnable    *bool              `json:"macFilterEnable,omitempty"`
	MacFilterId        *string            `json:"macFilterId,omitempty"`
	RateLimit          *RateLimit         `json:"rateLimit,omitempty"`
	PskSetting         *PskSetting        `json:"pskSetting,omitempty"`
	WpaSetting         *WpaSetting        `json:"wpaSetting,omitempty"`
	RateAndBeaconCtrl  *RateAndBeaconCtrl `json:"rateAndBeaconCtrl,omitempty"`

	// time range params
	DayMode  *int        `json:"dayMode,omitempty"`
	TimeList *[]TimeList `json:"timeList,omitempty"`
	DayMon   *bool       `json:"dayMon,omitempty"`
	DayTue   *bool       `json:"dayTue,omitempty"`
	DayWed   *bool       `json:"dayWed,omitempty"`
	DayThu   *bool       `json:"dayThu,omitempty"`
	DayFri   *bool       `json:"dayFri,omitempty"`
	DaySat   *bool       `json:"daySat,omitempty"`
	DaySun   *bool       `json:"daySun,omitempty"`

	// url filtering
	Type       *string   `json:"type,omitempty"`
	EntryId    *int      `json:"entryId,omitempty"`
	Status     *bool     `json:"status,omitempty"`
	SourceType *int      `json:"sourceType,omitempty"`
	SourceIds  *[]string `json:"sourceIds,omitempty"`
	Urls       *[]string `json:"urls,omitempty"`
}

func (*Data) ToDownloadRateLimit

func (d *Data) ToDownloadRateLimit() (*int, error)

Returns download rate limit in KBPS from omada SSID data response Returns -1 if no limit is set

func (*Data) ToUploadRateLimit

func (d *Data) ToUploadRateLimit() (*int, error)

Returns upload rate limit in KBPS from omada SSID data response Returns -1 if no limit is set

type NetworksResponse

type NetworksResponse struct {
	Ssid          *string      `json:"ssid,omitempty"`
	RadioOn       *bool        `json:"radioOn,omitempty"`
	UploadLimit   *int         `json:"uploadLimit,omitempty"`
	DownloadLimit *int         `json:"downloadLimit,omitempty"`
	UrlFilters    *[]UrlFilter `json:"urlFilters,omitempty"`
	Updated       *bool        `json:"updated,omitempty"`
	ErrorMessage  *string      `json:"errorMessage,omitempty"`
}

type NetworksSsidRequest

type NetworksSsidRequest struct {
	RadioOn       *bool        `json:"radioOn,omitempty"`
	UploadLimit   *int         `json:"uploadLimit,omitempty"`
	DownloadLimit *int         `json:"downloadLimit,omitempty"`
	UrlFilters    *[]UrlFilter `json:"urlFilters,omitempty"`
}

type OmadaApi

type OmadaApi interface {
	GetControllerId() (*OmadaResponse, error)
	Login(omadaControllerId *string) (*OmadaResponse, []*http.Cookie, error)
	GetSites(omadaControllerId *string, cookies []*http.Cookie,
		loginToken *string) (*OmadaResponse, error)
	GetWlans(omadaControllerId *string, cookies []*http.Cookie, loginToken *string,
		siteId *string) (*OmadaResponse, error)
	GetSsids(omadaControllerId *string, cookies []*http.Cookie, loginToken *string,
		siteId *string, wlanId *string) (*OmadaResponse, error)
	UpdateSsid(omadaControllerId *string, cookies []*http.Cookie, loginToken *string,
		siteId *string, wlanId *string, ssidUpdateData *Data) (*OmadaResponse, error)
	GetTimeRanges(omadaControllerId *string, cookies []*http.Cookie, loginToken *string,
		siteId *string) (*OmadaResponse, error)
	CreateTimeRange(omadaControllerId *string, cookies []*http.Cookie, loginToken *string,
		siteId *string, trData *Data) (*OmadaResponse, error)

	QueryUrlFilters(omadaControllerId *string, cookies []*http.Cookie, loginToken *string,
		siteId *string) (*OmadaResponse, error)
	CreateUrlFilter(omadaControllerId *string, cookies []*http.Cookie,
		loginToken *string, siteId *string, urlFilterData *Data) (*OmadaResponse, error)
	UpdateUrlFilter(omadaControllerId *string, cookies []*http.Cookie,
		loginToken *string, siteId *string, urlFilterData *Data) (*OmadaResponse, error)
	DeleteUrlFilter(omadaControllerId *string, cookies []*http.Cookie,
		loginToken *string, siteId *string, urlFilterId *string) (*OmadaResponse, error)
}

func NewOmadaApi

func NewOmadaApi(config *config.Configuration, httpClient apihttp.Client) OmadaApi

NewOmadaApi creates new omada api

type OmadaLoginData

type OmadaLoginData struct {
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
}

type OmadaResponse

type OmadaResponse struct {
	ErrorCode int     `json:"errorCode"`
	Msg       *string `json:"msg,omitempty"`
	Result    *Result `json:"result,omitempty"`
}

nested within sbserver response

type OmadaTimeRangeData

type OmadaTimeRangeData struct {
	Name     *string     `json:"name,omitempty"`
	DayMode  *int        `json:"dayMode,omitempty"`
	TimeList *[]TimeList `json:"timeList,omitempty"`
}

type PskSetting

type PskSetting struct {
	SecurityKey       *string `json:"securityKey,omitempty"`
	VersionPsk        *int    `json:"versionPsk,omitempty"`
	EncryptionPsk     *int    `json:"encryptionPsk,omitempty"`
	GikRekeyPskEnable *bool   `json:"gikRekeyPskEnable,omitempty"`
	RekeyPskInterval  *int    `json:"rekeyPskInterval,omitempty"`
	IntervalPskType   *int    `json:"intervalPskType,omitempty"`
}

type RateAndBeaconCtrl

type RateAndBeaconCtrl struct {
	Rate2gCtrlEnable *bool `json:"rate2gCtrlEnable,omitempty"`
	Rate5gCtrlEnable *bool `json:"rate5gCtrlEnable,omitempty"`
	Rate6gCtrlEnable *bool `json:"rate6gCtrlEnable,omitempty"`
}

type RateLimit

type RateLimit struct {
	DownLimitEnable *bool   `json:"downLimitEnable,omitempty"`
	DownLimit       *int    `json:"downLimit,omitempty"`
	DownLimitType   *int    `json:"downLimitType,omitempty"`
	UpLimitEnable   *bool   `json:"upLimitEnable,omitempty"`
	UpLimit         *int    `json:"upLimit,omitempty"`
	UpLimitType     *int    `json:"upLimitType,omitempty"`
	RateLimitId     *string `json:"rateLimitId,omitempty"`
}

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

Repository to interact with networks data providers

func NewRepository

func NewRepository(omadaApi OmadaApi) Repository

NewRepository creates new networks repository

func (*Repository) CreateTimeRange

func (r *Repository) CreateTimeRange(omadaControllerId *string, cookies []*http.Cookie, loginToken *string,
	siteId *string, timeRangeData *Data) (*OmadaResponse, error)

func (*Repository) CreateUrlFilter

func (r *Repository) CreateUrlFilter(omadaControllerId *string, cookies []*http.Cookie,
	loginToken *string, siteId *string, urlFilterData *Data) (*OmadaResponse, error)

func (*Repository) DeleteUrlFilter

func (r *Repository) DeleteUrlFilter(omadaControllerId *string, cookies []*http.Cookie,
	loginToken *string, siteId *string, urlFilterId *string) (*OmadaResponse, error)

func (*Repository) GetControllerId

func (r *Repository) GetControllerId() (*OmadaResponse, error)

func (*Repository) GetSites

func (r *Repository) GetSites(omadaControllerId *string, cookies []*http.Cookie,
	loginToken *string) (*OmadaResponse, error)

func (*Repository) GetSsids

func (r *Repository) GetSsids(omadaControllerId *string, cookies []*http.Cookie, loginToken *string,
	siteId *string, wlanId *string) (*OmadaResponse, error)

func (*Repository) GetTimeRanges

func (r *Repository) GetTimeRanges(omadaControllerId *string, cookies []*http.Cookie, loginToken *string,
	siteId *string) (*OmadaResponse, error)

func (*Repository) GetWlans

func (r *Repository) GetWlans(omadaControllerId *string, cookies []*http.Cookie, loginToken *string,
	siteId *string) (*OmadaResponse, error)

func (*Repository) Login

func (r *Repository) Login(omadaControllerId *string) (*OmadaResponse, []*http.Cookie, error)

func (*Repository) QueryUrlFilters

func (r *Repository) QueryUrlFilters(omadaControllerId *string, cookies []*http.Cookie,
	loginToken *string, siteId *string) (*OmadaResponse, error)

func (*Repository) UpdateSsid

func (r *Repository) UpdateSsid(omadaControllerId *string, cookies []*http.Cookie, loginToken *string,
	siteId *string, wlanId *string, ssidUpdateData *Data) (*OmadaResponse, error)

func (*Repository) UpdateUrlFilter

func (r *Repository) UpdateUrlFilter(omadaControllerId *string, cookies []*http.Cookie,
	loginToken *string, siteId *string, urlFilterData *Data) (*OmadaResponse, error)

type Result

type Result struct {
	OmadacId  *string `json:"omadacId,omitempty"`
	Token     *string `json:"token,omitempty"`
	ProfileId *string `json:"profileId,omitempty"`
	Data      *[]Data `json:"data,omitempty"`
}

type TimeList

type TimeList struct {
	DayType    *int `json:"dayType,omitempty"`
	StartTimeH *int `json:"startTimeH,omitempty"`
	StartTimeM *int `json:"startTimeM,omitempty"`
	EndTimeH   *int `json:"endTimeH,omitempty"`
	EndTimeM   *int `json:"endTimeM,omitempty"`
}

type UrlFilter

type UrlFilter struct {
	Name   *string   `json:"name,omitempty"`
	Enable *bool     `json:"enable,omitempty"`
	Urls   *[]string `json:"urls,omitempty"`
}

type UrlFilterController

type UrlFilterController interface {
	QueryUrlFilters(omadaControllerId *string, cookies []*http.Cookie,
		loginToken *string, siteId *string, ssidData *Data) (*[]UrlFilter, error)
	MaybeUpdateUrlFilters(omadaControllerId *string,
		cookies []*http.Cookie, loginToken *string, siteId *string, ssidData *Data,
		requestedFilters *[]UrlFilter) (*[]UrlFilter, *bool, error)
}

Controller to operatate with URL filters

func NewUrlFilterController

func NewUrlFilterController(r Repository) UrlFilterController

creates new URL filter controller

type WpaSetting

type WpaSetting struct {
	VersionEnt      *int    `json:"versionEnt,omitempty"`
	EncryptionEnt   *int    `json:"encryptionEnt,omitempty"`
	GikRekeyEnable  *bool   `json:"gikRekeyEnable,omitempty"`
	RekeyInterval   *bool   `json:"rekeyInterval,omitempty"`
	IntervalType    *int    `json:"intervalType,omitempty"`
	RadiusProfileId *string `json:"radiusProfileId,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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