control_models

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddSiteMember

type AddSiteMember struct {
	Email string `json:"email"form:"email"`
	Role  int    `json:"role"form:"role"`
}

type Agent

type Agent struct {
	ID          primitive.ObjectID       `bson:"_id, omitempty"json:"id"`
	Name        string                   `bson:"name"json:"name"`
	Site        primitive.ObjectID       `bson:"site"json:"site"` // _id of mongo object
	AgentConfig agent_models.AgentConfig `bson:"agent_config"json:"agent_config"`
	Pin         string                   `bson:"pin"json:"pin"` // used for registration & authentication
	Hash        string                   `bson:"hash"json:"hash"`
	Heartbeat   time.Time                `bson:"heartbeat"json:"heartbeat"`
}

type AgentStats

type AgentStats struct {
	ID          primitive.ObjectID       `json:"id"`
	Name        string                   `json:"name"`
	Heartbeat   time.Time                `json:"heartbeat"`
	NetworkInfo agent_models.NetworkInfo `json:"network_info"`
	LastSeen    time.Duration            `json:"last_seen"`
	Online      bool                     `json:"online"`
}

type AgentStatsList

type AgentStatsList struct {
	List []AgentStats `json:"list"`
}

type CreateAgent

type CreateAgent struct {
	Name        string `json:"name"form:"name"`
	IcmpTargets string `json:"icmpTargets"form:"icmpTargets"`
	MtrTargets  string `json:"mtrTargets"form:"mtrTargets"`
}

type IcmpData

type IcmpData struct {
	ID        primitive.ObjectID        `bson:"_id, omitempty"json:"id"`
	Agent     primitive.ObjectID        `bson:"agent"json:"agent"` // _id of mongo object
	Data      []agent_models.IcmpTarget `bson:"data"json:"data"`
	Timestamp time.Time                 `bson:"timestamp"json:"timestamp"`
}

type LoginUser

type LoginUser struct {
	Email    string `bson:"email"form:"email"`       // email, will be used as username
	Password string `bson:"password"form:"password"` // password in sha256?
}

type Mtr

type Mtr struct {
	Destination string        `json:"destination"bson:"destination"`
	Statistic   map[int]Stats `json:"statistic"bson:"statistic"`
}

type MtrData

type MtrData struct {
	ID        primitive.ObjectID `bson:"_id, omitempty"json:"id"`
	Agent     primitive.ObjectID `bson:"agent"json:"agent"`
	Data      []RealMtrData      `bson:"data"json:"data"`
	Timestamp time.Time          `bson:"timestamp"json:"timestamp"`
}

type MtrResult

type MtrResult struct {
	Triggered      bool      `json:"triggered"bson:"triggered"`
	Mtr            Mtr       `json:"mtr"bson:"mtr"`
	StartTimestamp time.Time `json:"start_timestamp"bson:"start_timestamp"`
	StopTimestamp  time.Time `json:"stop_timestamp"bson:"stop_timestamp"`
}

type NetworkData

type NetworkData struct {
	ID        primitive.ObjectID       `bson:"_id, omitempty"json:"id"`
	Agent     primitive.ObjectID       `bson:"agent"json:"agent"`
	Data      agent_models.NetworkInfo `bson:"data"json:"data"`
	Timestamp time.Time                `bson:"timestamp"json:"timestamp"`
}

type RealMtrData

type RealMtrData struct {
	Address string    `json:"address"bson:"address"`
	Result  MtrResult `json:"result"bson:"result"`
}

type RegisterUser

type RegisterUser struct {
	Email           string `bson:"email"form:"email"` // email, will be used as username
	FirstName       string `bson:"first_name"form:"first_name"`
	LastName        string `bson:"last_name"form:"last_name"`
	Password        string `bson:"password"form:"password"`                 // password in sha256?
	PasswordConfirm string `bson:"password_confirm"form:"password_confirm"` // password in sha256?
}

type Site

type Site struct {
	ID              primitive.ObjectID `bson:"_id, omitempty"json:"id"`
	Name            string             `bson:"name"form:"name"json:"name"`
	Members         []SiteMember       `bson:"members"json:"members"`
	CreateTimestamp time.Time          `bson:"create_timestamp"json:"create_timestamp"`
}

func (*Site) AddMember

func (s *Site) AddMember(id primitive.ObjectID, role int, db *mongo.Database) (bool, error)

AddMember Add a member to the site then update document

func (*Site) CreateSite

func (s *Site) CreateSite(owner primitive.ObjectID, db *mongo.Database) (primitive.ObjectID, error)

func (*Site) IsMember

func (s *Site) IsMember(id primitive.ObjectID) bool

IsMember check if a user id is a member in the site

type SiteMember

type SiteMember struct {
	User primitive.ObjectID `bson:"user"json:"user"`
	Role int                `bson:"role"json:"role"`
}

type SpeedTestData

type SpeedTestData struct {
	ID        primitive.ObjectID         `bson:"_id, omitempty"json:"id"`
	Agent     primitive.ObjectID         `bson:"agent"json:"agent"`
	Data      agent_models.SpeedTestInfo `bson:"data"json:"data"`
	Timestamp time.Time                  `bson:"timestamp"json:"timestamp"`
}

type Stats

type Stats struct {
	Sent        int     `json:"sent"bson:"sent"`
	TTL         int     `json:"ttl"bson:"TTL"`
	Target      string  `json:"target"bson:"target"`
	LastMs      float32 `json:"last_ms"bson:"last_ms"`
	BestMs      float32 `json:"best_ms"bson:"best_ms"`
	WorstMs     float32 `json:"worst_ms"bson:"worst_ms"`
	AvgMs       float32 `json:"avg_ms"bson:"avg_ms"`
	LossPercent int     `json:"loss_percent"bson:"loss_percent"`
}

type User

type User struct {
	ID              primitive.ObjectID   `bson:"_id, omitempty"json:"id"`
	Email           string               `bson:"email"json:"email"` // email, will be used as username
	FirstName       string               `bson:"first_name"json:"first_name"`
	LastName        string               `bson:"last_name"json:"last_name"`
	Admin           bool                 `bson:"admin" default:"false"json:"admin"`
	Password        string               `bson:"password"`             // password in sha256?
	Sites           []primitive.ObjectID `bson:"sites"json:"sites"`    // _id's of mongo objects
	Verified        bool                 `bson:"verified"json:"sites"` // verified, meaning email confirmation
	CreateTimestamp time.Time            `bson:"create_timestamp"json:"create_timestamp"`
}

func (*User) AddSite

func (u *User) AddSite(site primitive.ObjectID, db *mongo.Database) (bool, error)

AddSite add the id of a site

func (*User) Create

func (u *User) Create(db *mongo.Database) (bool, error)

Create returns true if successful, false if otherwise with the error

func (*User) GetUserFromEmail

func (u *User) GetUserFromEmail(db *mongo.Database) (*User, error)

func (*User) GetUserFromID

func (u *User) GetUserFromID(db *mongo.Database) (*User, error)

func (*User) UserExistsEmail

func (u *User) UserExistsEmail(db *mongo.Database) (bool, error)

UserExistsEmail check based on wether a user with the email in user exists

func (*User) UserExistsID

func (u *User) UserExistsID(db *mongo.Database) (bool, error)

UserExistsID check based on wether a user with the email in user exists

Jump to

Keyboard shortcuts

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