Documentation
¶
Index ¶
- Constants
- Variables
- func ActiveCallExists(db *gorm.DB, streamID uint, src uint, dst uint, slot bool, groupCall bool) (bool, error)
- func CountActiveNets(db *gorm.DB) (int, error)
- func CountCalls(db *gorm.DB) (int, error)
- func CountNets(db *gorm.DB) (int, error)
- func CountNetsForTalkgroup(db *gorm.DB, talkgroupID uint) (int, error)
- func CountPeers(db *gorm.DB) (int, error)
- func CountRepeaterCalls(db *gorm.DB, repeaterID uint) (int, error)
- func CountRepeaters(db *gorm.DB) (int, error)
- func CountScheduledNets(db *gorm.DB) (int, error)
- func CountScheduledNetsForTalkgroup(db *gorm.DB, talkgroupID uint) (int, error)
- func CountTalkgroupCalls(db *gorm.DB, talkgroupID uint) (int, error)
- func CountTalkgroupCallsInTimeRange(db *gorm.DB, talkgroupID uint, startTime, endTime time.Time) (int, error)
- func CountTalkgroups(db *gorm.DB) (int, error)
- func CountTalkgroupsByOwnerID(db *gorm.DB, ownerID uint) (int, error)
- func CountUniqueUsersInTimeRange(db *gorm.DB, talkgroupID uint, startTime, endTime time.Time) (int, error)
- func CountUserAdmins(db *gorm.DB) (int, error)
- func CountUserCalls(db *gorm.DB, userID uint) (int, error)
- func CountUserPeers(db *gorm.DB, id uint) (int, error)
- func CountUserRepeaters(db *gorm.DB, id uint) (int, error)
- func CountUserSuspended(db *gorm.DB) (int, error)
- func CountUserUnapproved(db *gorm.DB) (int, error)
- func CountUsers(db *gorm.DB) (int, error)
- func CreateNet(db *gorm.DB, net *Net) error
- func CreateScheduledNet(db *gorm.DB, sn *ScheduledNet) error
- func DeleteNet(db *gorm.DB, id uint) error
- func DeletePeer(db *gorm.DB, id uint) error
- func DeletePeerRule(db *gorm.DB, id uint) error
- func DeleteRepeater(db *gorm.DB, id uint) error
- func DeleteScheduledNet(db *gorm.DB, id uint) error
- func DeleteTalkgroup(db *gorm.DB, id uint) ([]uint, error)
- func DeleteUser(db *gorm.DB, id uint) error
- func EndNet(db *gorm.DB, id uint) error
- func GenerateCronExpression(dayOfWeek int, timeOfDay string) (string, error)
- func PeerIDExists(db *gorm.DB, id uint) (bool, error)
- func RatelimitKeyExists(db *gorm.DB, key string) (bool, error)
- func RepeaterExists(db *gorm.DB, repeater Repeater) (bool, error)
- func RepeaterIDExists(db *gorm.DB, id uint) (bool, error)
- func TalkgroupIDExists(db *gorm.DB, id uint) (bool, error)
- func UpdateNetShowcase(db *gorm.DB, id uint, showcase bool) error
- func UpdateScheduledNet(db *gorm.DB, sn *ScheduledNet) error
- func UserExists(db *gorm.DB, user User) (bool, error)
- func UserIDExists(db *gorm.DB, id uint) (bool, error)
- type AppSettings
- type Call
- func FindActiveCall(db *gorm.DB, streamID uint, src uint, dst uint, slot bool, groupCall bool) (Call, error)
- func FindCalls(db *gorm.DB) ([]Call, error)
- func FindRepeaterCalls(db *gorm.DB, repeaterID uint) ([]Call, error)
- func FindTalkgroupCalls(db *gorm.DB, talkgroupID uint) ([]Call, error)
- func FindTalkgroupCallsInTimeRange(db *gorm.DB, talkgroupID uint, startTime, endTime time.Time) ([]Call, error)
- func FindUserCalls(db *gorm.DB, userID uint) ([]Call, error)
- type Net
- func FindActiveNetForTalkgroup(db *gorm.DB, talkgroupID uint) (Net, error)
- func FindNetByID(db *gorm.DB, id uint) (Net, error)
- func FindNetsForTalkgroup(db *gorm.DB, talkgroupID uint) ([]Net, error)
- func ListActiveNets(db *gorm.DB) ([]Net, error)
- func ListNets(db *gorm.DB) ([]Net, error)
- func ListShowcaseNets(db *gorm.DB) ([]Net, error)
- type Packet
- type Peer
- type PeerRule
- type Ratelimit
- type RawDMRPacket
- type Repeater
- type RepeaterConfiguration
- type RepeaterState
- type ScheduledNet
- type Talkgroup
- type TalkgroupsSeeder
- type User
- type UsersSeeder
Constants ¶
const ( // RepeaterTypeMMDVM is the type for MMDVM repeaters. RepeaterTypeMMDVM = "mmdvm" // RepeaterTypeIPSC is the type for Motorola IPSC repeaters. RepeaterTypeIPSC = "ipsc" )
const TalkgroupSeederRows = 1
const UserSeederRows = 1
Variables ¶
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 CountActiveNets ¶ added in v1.2.36
CountActiveNets returns the number of currently active nets.
func CountNetsForTalkgroup ¶ added in v1.2.36
CountNetsForTalkgroup returns the total number of nets for a talkgroup.
func CountScheduledNets ¶ added in v1.2.36
CountScheduledNets returns the total number of scheduled nets.
func CountScheduledNetsForTalkgroup ¶ added in v1.2.36
CountScheduledNetsForTalkgroup returns the count of scheduled nets for a talkgroup.
func CountTalkgroupCallsInTimeRange ¶ added in v1.2.36
func CountTalkgroupCallsInTimeRange(db *gorm.DB, talkgroupID uint, startTime, endTime time.Time) (int, error)
CountTalkgroupCallsInTimeRange returns the count of calls for a talkgroup within a time window.
func CountUniqueUsersInTimeRange ¶ added in v1.2.39
func CountUniqueUsersInTimeRange(db *gorm.DB, talkgroupID uint, startTime, endTime time.Time) (int, error)
CountUniqueUsersInTimeRange returns the number of distinct users who made calls on a talkgroup within a time window.
func CreateScheduledNet ¶ added in v1.2.36
func CreateScheduledNet(db *gorm.DB, sn *ScheduledNet) error
CreateScheduledNet persists a new scheduled net to the database.
func DeleteScheduledNet ¶ added in v1.2.36
DeleteScheduledNet soft-deletes a scheduled net.
func GenerateCronExpression ¶ added in v1.2.36
GenerateCronExpression builds a cron expression from schedule fields. The cron format is: minute hour * * day_of_week (evaluated in UTC). DayOfWeek uses 0=Sunday..6=Saturday. TimeOfDay is "HH:MM" 24h UTC.
func RatelimitKeyExists ¶ added in v1.0.66
func UpdateNetShowcase ¶ added in v1.2.36
UpdateNetShowcase toggles the showcase flag on a net.
func UpdateScheduledNet ¶ added in v1.2.36
func UpdateScheduledNet(db *gorm.DB, sn *ScheduledNet) error
UpdateScheduledNet updates a scheduled net in the database.
Types ¶
type AppSettings ¶
type Call ¶
type Call struct {
ID uint `json:"id" gorm:"primarykey"`
CallData []byte `json:"-" gorm:"type:bytea"`
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 ¶
type Net ¶ added in v1.2.36
type Net struct {
ID uint `json:"id" gorm:"primarykey" msg:"id"`
TalkgroupID uint `json:"talkgroup_id" gorm:"not null;index" msg:"talkgroup_id"`
Talkgroup Talkgroup `json:"talkgroup" gorm:"foreignKey:TalkgroupID" msg:"-"`
StartedByUserID uint `json:"started_by_user_id" msg:"started_by_user_id"`
StartedByUser User `json:"started_by_user" gorm:"foreignKey:StartedByUserID" msg:"-"`
ScheduledNetID *uint `json:"scheduled_net_id,omitempty" msg:"scheduled_net_id,omitempty"`
StartTime time.Time `json:"start_time" msg:"start_time"`
EndTime *time.Time `json:"end_time,omitempty" msg:"end_time,omitempty"`
DurationMinutes *uint `json:"duration_minutes,omitempty" msg:"duration_minutes,omitempty"`
Description string `json:"description" msg:"description"`
Active bool `json:"active" gorm:"index" msg:"active"`
Showcase bool `json:"showcase" gorm:"default:false" msg:"showcase"`
CreatedAt time.Time `json:"-" msg:"-"`
UpdatedAt time.Time `json:"-" msg:"-"`
DeletedAt gorm.DeletedAt `json:"-" gorm:"index" msg:"-"`
}
Net represents a single net check-in session on a talkgroup. A net is a period during which transmissions on a talkgroup are tracked as "check-ins". Nets can be started ad-hoc by an NCO or automatically by a ScheduledNet.
func FindActiveNetForTalkgroup ¶ added in v1.2.36
FindActiveNetForTalkgroup returns the currently active net for a talkgroup, if any.
func FindNetByID ¶ added in v1.2.36
FindNetByID returns a net by its ID.
func FindNetsForTalkgroup ¶ added in v1.2.36
FindNetsForTalkgroup returns all nets for a talkgroup, ordered by start time descending.
func ListActiveNets ¶ added in v1.2.36
ListActiveNets returns all currently active nets.
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 (*Packet) Encode ¶
Encode allocates and returns a new byte slice containing the encoded packet.
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:"ip" msg:"ip"`
Port int `json:"port" 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
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 FindPeerRuleByID ¶ added in v1.2.36
func ListEgressRulesForPeer ¶ added in v1.0.38
func ListIngressRulesForPeer ¶ added in v1.0.38
func ListRulesForPeer ¶ added in v1.0.38
type Ratelimit ¶ added in v1.0.66
type Ratelimit struct {
Key string `gorm:"primaryKey" json:"key"`
Hits int64 `json:"hits"`
Timestamp time.Time `json:"timestamp"`
}
Ratelimit is the model for a rate limit entry
func FindRatelimitByKey ¶ added in v1.0.66
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 RepeaterState `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:"-"`
Type string `json:"type" gorm:"default:'mmdvm'" 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:"-"`
SimplexRepeater bool `json:"simplex_repeater" msg:"simplex_repeater"`
City string `json:"city" msg:"-"`
State string `json:"state" msg:"-"`
Country string `json:"country" msg:"-"`
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 (*Repeater) UpdateFrom ¶ added in v1.0.66
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(version, commit string) error
func (*RepeaterConfiguration) ParseConfig ¶ added in v1.0.43
func (c *RepeaterConfiguration) ParseConfig(data []byte, version, commit string) error
type RepeaterState ¶ added in v1.2.27
type RepeaterState string
const ( RepeaterStateConnected RepeaterState = "CONNECTED" RepeaterStateChallengeSent RepeaterState = "CHALLENGE_SENT" RepeaterStateWaitingConfig RepeaterState = "WAITING_CONFIG" RepeaterStateLoginReceived RepeaterState = "LOGIN_RECEIVED" )
type ScheduledNet ¶ added in v1.2.36
type ScheduledNet struct {
ID uint `json:"id" gorm:"primarykey" msg:"id"`
TalkgroupID uint `json:"talkgroup_id" gorm:"not null;index" msg:"talkgroup_id"`
Talkgroup Talkgroup `json:"talkgroup" gorm:"foreignKey:TalkgroupID" msg:"-"`
CreatedByUserID uint `json:"created_by_user_id" msg:"created_by_user_id"`
CreatedByUser User `json:"created_by_user" gorm:"foreignKey:CreatedByUserID" msg:"-"`
Name string `json:"name" msg:"name"`
Description string `json:"description" msg:"description"`
CronExpression string `json:"cron_expression" msg:"cron_expression"`
DayOfWeek int `json:"day_of_week" msg:"day_of_week"`
TimeOfDay string `json:"time_of_day" msg:"time_of_day"`
Timezone string `json:"timezone" msg:"timezone"`
DurationMinutes *uint `json:"duration_minutes,omitempty" msg:"duration_minutes,omitempty"`
Enabled bool `json:"enabled" gorm:"default:true" msg:"enabled"`
Showcase bool `json:"showcase" gorm:"default:false" msg:"showcase"`
NextRun *time.Time `json:"next_run,omitempty" msg:"next_run,omitempty"`
CreatedAt time.Time `json:"created_at" msg:"-"`
UpdatedAt time.Time `json:"-" msg:"-"`
DeletedAt gorm.DeletedAt `json:"-" gorm:"index" msg:"-"`
}
ScheduledNet represents a recurring net schedule for a talkgroup. DayOfWeek and TimeOfDay are stored in UTC (the frontend converts from the user's local time before sending). Timezone is stored for display purposes so the UI can show the schedule in the creator's local time. The CronExpression is generated from the UTC DayOfWeek and TimeOfDay.
func FindAllEnabledScheduledNets ¶ added in v1.2.36
func FindAllEnabledScheduledNets(db *gorm.DB) ([]ScheduledNet, error)
FindAllEnabledScheduledNets returns all enabled scheduled nets across all talkgroups.
func FindScheduledNetByID ¶ added in v1.2.36
func FindScheduledNetByID(db *gorm.DB, id uint) (ScheduledNet, error)
FindScheduledNetByID returns a scheduled net by its ID.
func FindScheduledNetsForTalkgroup ¶ added in v1.2.36
func FindScheduledNetsForTalkgroup(db *gorm.DB, talkgroupID uint) ([]ScheduledNet, error)
FindScheduledNetsForTalkgroup returns all scheduled nets for a talkgroup.
func ListScheduledNets ¶ added in v1.2.36
func ListScheduledNets(db *gorm.DB) ([]ScheduledNet, error)
ListScheduledNets returns all scheduled nets, ordered by creation time descending.
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 FindTalkgroupsByOwnerID ¶
type TalkgroupsSeeder ¶
type TalkgroupsSeeder struct {
gorm_seeder.SeederAbstract
}
func NewTalkgroupsSeeder ¶
func NewTalkgroupsSeeder(cfg gorm_seeder.SeederConfiguration) TalkgroupsSeeder
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"`
SuperAdmin bool `json:"superAdmin"`
Email string `json:"email"`
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"`
}
type UsersSeeder ¶
type UsersSeeder struct {
gorm_seeder.SeederAbstract
}
func NewUsersSeeder ¶
func NewUsersSeeder(cfg gorm_seeder.SeederConfiguration) UsersSeeder