models

package
v1.0.51 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2023 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const TalkgroupSeederRows = 1
View Source
const UserSeederRows = 2

Variables

View Source
var (
	ErrInvalidCallsign  = errors.New("invalid callsign")
	ErrInvalidColorCode = errors.New("invalid color code")
	ErrInvalidLatitude  = errors.New("invalid latitude")
	ErrInvalidLongitude = errors.New("invalid longitude")
	ErrInvalidInt       = errors.New("invalid integer")
	ErrInvalidFloat     = errors.New("invalid float")
)

Functions

func ActiveCallExists

func ActiveCallExists(db *gorm.DB, streamID uint, src uint, dst uint, slot bool, groupCall bool) bool

func CountCalls

func CountCalls(db *gorm.DB) int

func CountPeers added in v1.0.35

func CountPeers(db *gorm.DB) int

func CountRepeaterCalls

func CountRepeaterCalls(db *gorm.DB, repeaterID uint) int

func CountRepeaters

func CountRepeaters(db *gorm.DB) (int, error)

func CountTalkgroupCalls

func CountTalkgroupCalls(db *gorm.DB, talkgroupID uint) int

func CountTalkgroups

func CountTalkgroups(db *gorm.DB) (int, error)

func CountTalkgroupsByOwnerID

func CountTalkgroupsByOwnerID(db *gorm.DB, ownerID uint) (int, error)

func CountUserAdmins

func CountUserAdmins(db *gorm.DB) (int, error)

func CountUserCalls

func CountUserCalls(db *gorm.DB, userID uint) int

func CountUserPeers added in v1.0.35

func CountUserPeers(db *gorm.DB, id uint) int

func CountUserRepeaters

func CountUserRepeaters(db *gorm.DB, id uint) (int, error)

func CountUserSuspended

func CountUserSuspended(db *gorm.DB) (int, error)

func CountUserUnapproved

func CountUserUnapproved(db *gorm.DB) (int, error)

func CountUsers

func CountUsers(db *gorm.DB) (int, error)

func DeletePeer added in v1.0.35

func DeletePeer(db *gorm.DB, id uint)

func DeleteRepeater

func DeleteRepeater(db *gorm.DB, id uint) error

func DeleteTalkgroup

func DeleteTalkgroup(db *gorm.DB, id uint) error

func DeleteUser

func DeleteUser(db *gorm.DB, id uint) error

func PeerExists added in v1.0.35

func PeerExists(db *gorm.DB, peer Peer) bool

func PeerIDExists added in v1.0.35

func PeerIDExists(db *gorm.DB, id uint) bool

func RepeaterExists

func RepeaterExists(db *gorm.DB, repeater Repeater) (bool, error)

func RepeaterIDExists

func RepeaterIDExists(db *gorm.DB, id uint) (bool, error)

func TalkgroupIDExists

func TalkgroupIDExists(db *gorm.DB, id uint) (bool, error)

func UserExists

func UserExists(db *gorm.DB, user User) (bool, error)

func UserIDExists

func UserIDExists(db *gorm.DB, id uint) (bool, error)

Types

type AppSettings

type AppSettings struct {
	ID        uint `gorm:"primaryKey"`
	HasSeeded bool
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

type Call

type Call struct {
	ID             uint           `json:"id" gorm:"primarykey"`
	CallData       []byte         `json:"-"`
	StreamID       uint           `json:"-"`
	StartTime      time.Time      `json:"start_time"`
	Duration       time.Duration  `json:"duration"`
	Active         bool           `json:"active"`
	User           User           `json:"user" gorm:"foreignKey:UserID"`
	UserID         uint           `json:"-"`
	Repeater       Repeater       `json:"repeater" gorm:"foreignKey:RepeaterID"`
	RepeaterID     uint           `json:"-"`
	TimeSlot       bool           `json:"time_slot"`
	GroupCall      bool           `json:"group_call"`
	IsToTalkgroup  bool           `json:"is_to_talkgroup"`
	ToTalkgroupID  *uint          `json:"-"`
	ToTalkgroup    Talkgroup      `json:"to_talkgroup" gorm:"foreignKey:ToTalkgroupID"`
	IsToUser       bool           `json:"is_to_user"`
	ToUserID       *uint          `json:"-"`
	ToUser         User           `json:"to_user" gorm:"foreignKey:ToUserID"`
	IsToRepeater   bool           `json:"is_to_repeater"`
	ToRepeaterID   *uint          `json:"-"`
	ToRepeater     Repeater       `json:"to_repeater" gorm:"foreignKey:ToRepeaterID"`
	DestinationID  uint           `json:"destination_id"`
	TotalPackets   uint           `json:"-"`
	LostSequences  uint           `json:"-"`
	Loss           float32        `json:"loss"`
	Jitter         float32        `json:"jitter"`
	LastFrameNum   uint           `json:"-"`
	LastSeq        uint           `json:"-"`
	BER            float32        `json:"ber"`
	RSSI           float32        `json:"rssi"`
	TotalBits      uint           `json:"-"`
	TotalErrors    int            `json:"-"`
	LastPacketTime time.Time      `json:"-"`
	HasHeader      bool           `json:"-"`
	HasTerm        bool           `json:"-"`
	CreatedAt      time.Time      `json:"-"`
	UpdatedAt      time.Time      `json:"-"`
	DeletedAt      gorm.DeletedAt `json:"-" gorm:"index"`
}

func FindActiveCall

func FindActiveCall(db *gorm.DB, streamID uint, src uint, dst uint, slot bool, groupCall bool) (Call, error)

func FindCalls

func FindCalls(db *gorm.DB) []Call

func FindRepeaterCalls

func FindRepeaterCalls(db *gorm.DB, repeaterID uint) []Call

func FindTalkgroupCalls

func FindTalkgroupCalls(db *gorm.DB, talkgroupID uint) []Call

func FindUserCalls

func FindUserCalls(db *gorm.DB, userID uint) []Call

type Packet

type Packet struct {
	Signature   string             `msg:"signature"`
	Seq         uint               `msg:"seq"`
	Src         uint               `msg:"src"`
	Dst         uint               `msg:"dst"`
	Repeater    uint               `msg:"repeater"`
	Slot        bool               `msg:"slot"`
	GroupCall   bool               `msg:"groupCall"`
	FrameType   dmrconst.FrameType `msg:"frameType,extension"`
	DTypeOrVSeq uint               `msg:"dtypeOrVSeq"`
	StreamID    uint               `msg:"streamID"`
	DMRData     [33]byte           `msg:"dmrData"`
	// The next two are technically unsigned, but the data type is 1 byte
	// We also want to be able to represent -1 as a null, so we use int
	BER  int `msg:"ber"`
	RSSI int `msg:"rssi"`
}

Packet is a DMR packet

func UnpackPacket

func UnpackPacket(data []byte) (Packet, bool)

func (*Packet) Encode

func (p *Packet) Encode() []byte

func (Packet) Equal

func (p Packet) Equal(other Packet) bool

func (*Packet) String

func (p *Packet) String() string

type Peer added in v1.0.35

type Peer struct {
	ID        uint           `json:"id" gorm:"primaryKey" msg:"id"`
	LastPing  time.Time      `json:"last_ping_time" msg:"last_ping"`
	IP        string         `json:"-" gorm:"-" msg:"ip"`
	Port      int            `json:"-" gorm:"-" msg:"port"`
	Password  string         `json:"-" msg:"-"`
	Owner     User           `json:"owner" gorm:"foreignKey:OwnerID" msg:"-"`
	OwnerID   uint           `json:"-" msg:"-"`
	Ingress   bool           `json:"ingress" msg:"-"`
	Egress    bool           `json:"egress" msg:"-"`
	CreatedAt time.Time      `json:"created_at" msg:"-"`
	UpdatedAt time.Time      `json:"-" msg:"-"`
	DeletedAt gorm.DeletedAt `json:"-" gorm:"index" msg:"-"`
}

Peer is the model for an OpenBridge DMR peer

func FindPeerByID added in v1.0.35

func FindPeerByID(db *gorm.DB, id uint) Peer

func GetUserPeers added in v1.0.35

func GetUserPeers(db *gorm.DB, id uint) []Peer

func ListPeers added in v1.0.35

func ListPeers(db *gorm.DB) []Peer

func (*Peer) String added in v1.0.35

func (p *Peer) String() string

type PeerRule added in v1.0.38

type PeerRule struct {
	ID     uint `json:"id" gorm:"primarykey"`
	PeerID uint `json:"-"`
	Peer   Peer `json:"peer" gorm:"foreignKey:PeerID"`

	// Direction is true for ingress, false for egress
	Direction bool `json:"direction"`
	// SubjectID is the ID of the subject (talkgroup/user/repeater)
	SubjectIDMin uint `json:"subject_id_min"`
	SubjectIDMax uint `json:"subject_id_max"`

	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"-"`
	DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
}

PeerRule is the model for an OpenBridge DMR peer's routing rules

func ListEgressRulesForPeer added in v1.0.38

func ListEgressRulesForPeer(db *gorm.DB, peerID uint) []PeerRule

func ListIngressRulesForPeer added in v1.0.38

func ListIngressRulesForPeer(db *gorm.DB, peerID uint) []PeerRule

func ListRulesForPeer added in v1.0.38

func ListRulesForPeer(db *gorm.DB, peerID uint) []PeerRule

func (*PeerRule) String added in v1.0.38

func (p *PeerRule) String() string

type RawDMRPacket

type RawDMRPacket struct {
	Data       []byte `msg:"data"`
	RemoteIP   string `msg:"remote_ip"`
	RemotePort int    `msg:"remote_port"`
}

RawDMRPacket is a raw DMR packet

type Repeater

type Repeater struct {
	Connection            string         `json:"-" gorm:"-" msg:"connection"`
	Connected             time.Time      `json:"connected_time" msg:"connected"`
	PingsReceived         uint           `json:"-" gorm:"-" msg:"pings_received"`
	LastPing              time.Time      `json:"last_ping_time" msg:"last_ping"`
	IP                    string         `json:"-" gorm:"-" msg:"ip"`
	Port                  int            `json:"-" gorm:"-" msg:"port"`
	Salt                  uint32         `json:"-" gorm:"-" msg:"salt"`
	Password              string         `json:"-" msg:"-"`
	TS1StaticTalkgroups   []Talkgroup    `json:"ts1_static_talkgroups" gorm:"many2many:repeater_ts1_static_talkgroups;" msg:"-"`
	TS2StaticTalkgroups   []Talkgroup    `json:"ts2_static_talkgroups" gorm:"many2many:repeater_ts2_static_talkgroups;" msg:"-"`
	TS1DynamicTalkgroupID *uint          `json:"-" msg:"-"`
	TS2DynamicTalkgroupID *uint          `json:"-" msg:"-"`
	TS1DynamicTalkgroup   Talkgroup      `json:"ts1_dynamic_talkgroup" gorm:"foreignKey:TS1DynamicTalkgroupID" msg:"-"`
	TS2DynamicTalkgroup   Talkgroup      `json:"ts2_dynamic_talkgroup" gorm:"foreignKey:TS2DynamicTalkgroupID" msg:"-"`
	Owner                 User           `json:"owner" gorm:"foreignKey:OwnerID" msg:"-"`
	OwnerID               uint           `json:"-" msg:"-"`
	Hotspot               bool           `json:"hotspot" msg:"hotspot"`
	CreatedAt             time.Time      `json:"created_at" msg:"-"`
	UpdatedAt             time.Time      `json:"-" msg:"-"`
	DeletedAt             gorm.DeletedAt `json:"-" gorm:"index" msg:"-"`
	RepeaterConfiguration
}

Repeater is the model for a DMR repeater

func FindRepeaterByID

func FindRepeaterByID(db *gorm.DB, id uint) (Repeater, error)

func GetUserRepeaters

func GetUserRepeaters(db *gorm.DB, id uint) ([]Repeater, error)

func ListRepeaters

func ListRepeaters(db *gorm.DB) ([]Repeater, error)

func (*Repeater) InTS1StaticTalkgroups

func (p *Repeater) InTS1StaticTalkgroups(dest uint) bool

func (*Repeater) InTS2StaticTalkgroups

func (p *Repeater) InTS2StaticTalkgroups(dest uint) bool

func (*Repeater) String

func (p *Repeater) String() string

func (*Repeater) UpdateFromRedis added in v1.0.43

func (p *Repeater) UpdateFromRedis(repeater Repeater)

func (*Repeater) WantRX

func (p *Repeater) WantRX(packet Packet) (bool, bool)

func (*Repeater) WantRXCall added in v1.0.15

func (p *Repeater) WantRXCall(call Call) (bool, bool)

type RepeaterConfiguration added in v1.0.43

type RepeaterConfiguration struct {
	Callsign    string  `json:"callsign" msg:"callsign"`
	ID          uint    `json:"id" gorm:"primaryKey" msg:"id"`
	RXFrequency uint    `json:"rx_frequency" msg:"rx_frequency"`
	TXFrequency uint    `json:"tx_frequency" msg:"tx_frequency"`
	TXPower     uint8   `json:"tx_power" msg:"tx_power"`
	ColorCode   uint8   `json:"color_code" msg:"color_code"`
	Latitude    float64 `json:"latitude" msg:"latitude"`
	Longitude   float64 `json:"longitude" msg:"longitude"`
	Height      uint16  `json:"height" msg:"height"`
	Location    string  `json:"location" msg:"location"`
	Description string  `json:"description" msg:"description"`
	URL         string  `json:"url" msg:"url"`
	SoftwareID  string  `json:"software_id" msg:"software_id"`
	PackageID   string  `json:"package_id" msg:"package_id"`
	Slots       uint    `json:"slots" msg:"slots"`
}

func (*RepeaterConfiguration) Check added in v1.0.43

func (c *RepeaterConfiguration) Check() error

func (*RepeaterConfiguration) ParseConfig added in v1.0.43

func (c *RepeaterConfiguration) ParseConfig(data []byte) error

type Talkgroup

type Talkgroup struct {
	ID          uint           `json:"id" gorm:"primaryKey"`
	Name        string         `json:"name"`
	Description string         `json:"description"`
	Admins      []User         `json:"admins" gorm:"many2many:talkgroup_admins;"`
	NCOs        []User         `json:"ncos" gorm:"many2many:talkgroup_ncos;"`
	CreatedAt   time.Time      `json:"created_at"`
	UpdatedAt   time.Time      `json:"-"`
	DeletedAt   gorm.DeletedAt `json:"-" gorm:"index"`
}

func FindTalkgroupByID

func FindTalkgroupByID(db *gorm.DB, id uint) (Talkgroup, error)

func FindTalkgroupsByOwnerID

func FindTalkgroupsByOwnerID(db *gorm.DB, ownerID uint) ([]Talkgroup, error)

func ListTalkgroups

func ListTalkgroups(db *gorm.DB) ([]Talkgroup, error)

type TalkgroupsSeeder

type TalkgroupsSeeder struct {
	gorm_seeder.SeederAbstract
}

func (*TalkgroupsSeeder) Clear

func (s *TalkgroupsSeeder) Clear(_ *gorm.DB) error

func (*TalkgroupsSeeder) Seed

func (s *TalkgroupsSeeder) Seed(db *gorm.DB) error

type User

type User struct {
	ID        uint           `json:"id" gorm:"primaryKey" binding:"required"`
	Callsign  string         `json:"callsign" gorm:"uniqueIndex" binding:"required"`
	Username  string         `json:"username" gorm:"uniqueIndex" binding:"required"`
	Password  string         `json:"-"`
	Admin     bool           `json:"admin"`
	Approved  bool           `json:"approved" binding:"required"`
	Suspended bool           `json:"suspended"`
	Repeaters []Repeater     `json:"repeaters" gorm:"foreignKey:OwnerID"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"-"`
	DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
}

func FindUserAdmins

func FindUserAdmins(db *gorm.DB) ([]User, error)

func FindUserByID

func FindUserByID(db *gorm.DB, id uint) (User, error)

func FindUserSuspended

func FindUserSuspended(db *gorm.DB) ([]User, error)

func FindUserUnapproved

func FindUserUnapproved(db *gorm.DB) ([]User, error)

func ListUsers

func ListUsers(db *gorm.DB) ([]User, error)

func (User) TableName

func (u User) TableName() string

type UsersSeeder

type UsersSeeder struct {
	gorm_seeder.SeederAbstract
}

func (*UsersSeeder) Clear

func (s *UsersSeeder) Clear(_ *gorm.DB) error

func (*UsersSeeder) Seed

func (s *UsersSeeder) Seed(db *gorm.DB) error

Jump to

Keyboard shortcuts

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