linked device, device tasks and certs in database
This commit is contained in:
@@ -227,7 +227,7 @@ func (h *MediaMTXHandler) StartStreamPayload(guid string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
whip := fmt.Sprintf("%s/whip/%s?token=%s",
|
||||
strings.TrimRight(h.cfg.WebRTCBaseURL, "/"),
|
||||
strings.TrimRight(h.cfg.PublicBaseURL, "/"),
|
||||
path,
|
||||
url.QueryEscape(tok),
|
||||
)
|
||||
|
||||
@@ -13,6 +13,7 @@ type DeviceCertificate struct {
|
||||
NotAfter time.Time
|
||||
PemCert string `gorm:"type:text"` // PEM of leaf cert
|
||||
CreatedAt time.Time
|
||||
Device Device `gorm:"constraint:OnDelete:CASCADE;foreignKey:DeviceGUID;references:GUID"`
|
||||
}
|
||||
|
||||
// “Instant kill” list checked by the mTLS guard before allowing access.
|
||||
|
||||
@@ -3,10 +3,12 @@ package models
|
||||
import "time"
|
||||
|
||||
type Device struct {
|
||||
GUID string `gorm:"primaryKey"`
|
||||
Name string `gorm:"size:255;not null"`
|
||||
Users []User `gorm:"many2many:user_devices;constraint:OnDelete:CASCADE;"`
|
||||
Records []Record `gorm:"foreignKey:DeviceGUID;references:GUID;constraint:OnDelete:CASCADE"`
|
||||
GUID string `gorm:"primaryKey"`
|
||||
Name string `gorm:"size:255;not null"`
|
||||
Users []User `gorm:"many2many:user_devices;constraint:OnDelete:CASCADE;"`
|
||||
Records []Record `gorm:"foreignKey:DeviceGUID;references:GUID;constraint:OnDelete:CASCADE"`
|
||||
Tasks []DEviceTask `gorm:"foreignKey:DeviceGUID;references:GUID;constraint:OnDelete:CASCADE"`
|
||||
Certs []DeviceCertificate `gorm:"foreignKey:DeviceGUID;references:GUID;constraint:OnDelete:CASCADE"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
@@ -48,4 +48,5 @@ type DEviceTask struct {
|
||||
|
||||
// Optional: small attempt/lease system if you ever need retries/timeouts
|
||||
// Attempts int `gorm:"not null;default:0"`
|
||||
Device Device `gorm:"constraint:OnDelete:CASCADE;foreignKey:DeviceGUID;references:GUID"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user