Documentation
¶
Index ¶
- Constants
- func Create(v interface{}) *gorm.DB
- func Setup() (err error)
- func Update(v interface{}) *gorm.DB
- func UpdateFields(v interface{}, fields map[string]interface{}) *gorm.DB
- func ValidateMessage(data, signature string) error
- type AccessPoint
- type EnrollmentRequest
- type Message
- type Unit
- func (u Unit) FindAccessPoint(essid, bssid string) *AccessPoint
- func (u *Unit) GetInboxMessage(id int) *Message
- func (u *Unit) GetPagedInbox(page int) (messages []Message, total int, pages int)
- func (u Unit) Identity() string
- func (u *Unit) MarshalJSON() ([]byte, error)
- func (u *Unit) UpdateWith(enroll EnrollmentRequest) error
- type UnitsByCountry
Constants ¶
View Source
const ( MessageDataMaxSize = 512000 MessageSignatureMaxSize = 10000 )
View Source
const ( TokenTTL = time.Minute * 30 CacheTTL = time.Minute * 120 )
Variables ¶
This section is empty.
Functions ¶
func UpdateFields ¶
func ValidateMessage ¶
Types ¶
type AccessPoint ¶
type EnrollmentRequest ¶
type EnrollmentRequest struct { Identity string `json:"identity"` // name@SHA256(public_key) PublicKey string `json:"public_key"` // BASE64(public_key.pem) Signature string `json:"signature"` // BASE64(SIGN(identity, private_key)) Data map[string]interface{} `json:"data"` // misc data for the unit KeyPair *crypto.KeyPair `json:"-"` // parsed from public_key Name string `json:"-"` Fingerprint string `json:"-"` // SHA256(public_key) Address string `json:"-"` Country string `json:"-"` }
func (*EnrollmentRequest) Validate ¶
func (enroll *EnrollmentRequest) Validate() error
type Message ¶
type Message struct { ID uint `gorm:"primary_key" json:"id"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt *time.Time `sql:"index" json:"deleted_at"` SeenAt *time.Time `json:"seen_at" sql:"index"` SenderID uint `json:"-"` ReceiverID uint `json:"-"` SenderName string `gorm:"size:255" json:"sender_name"` Sender string `gorm:"size:255;not null" json:"sender"` Data string `gorm:"size:512000;not null" json:"-"` Signature string `gorm:"size:10000;not null" json:"-"` }
type Unit ¶
type Unit struct { ID uint `gorm:"primary_key" json:"-"` CreatedAt time.Time `json:"enrolled_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt *time.Time `sql:"index" json:"-"` Address string `gorm:"size:50;not null" json:"-"` Country string `gorm:"size:10" json:"country"` Name string `gorm:"size:255;not null" json:"name"` Fingerprint string `gorm:"size:255;not null;unique" json:"fingerprint"` PublicKey string `gorm:"size:10000;not null" json:"public_key"` Token string `gorm:"size:10000;not null" json:"-"` Data string `gorm:"size:10000;not null" json:"data"` AccessPoints []AccessPoint `gorm:"foreignkey:UnitID" json:"-"` Inbox []Message `gorm:"foreignkey:ReceiverID" json:"-"` Sent []Message `gorm:"foreignkey:SenderID" json:"-"` }
func EnrollUnit ¶
func EnrollUnit(enroll EnrollmentRequest) (err error, unit *Unit)
func FindUnitByFingerprint ¶
func (Unit) FindAccessPoint ¶
func (u Unit) FindAccessPoint(essid, bssid string) *AccessPoint
func (*Unit) GetInboxMessage ¶
func (*Unit) GetPagedInbox ¶
func (*Unit) MarshalJSON ¶
func (*Unit) UpdateWith ¶
func (u *Unit) UpdateWith(enroll EnrollmentRequest) error
type UnitsByCountry ¶
func GetUnitsByCountry ¶
func GetUnitsByCountry() ([]UnitsByCountry, error)
Click to show internal directories.
Click to hide internal directories.