peer expiry feature: expiration check

This commit is contained in:
Christoph Haas
2022-10-29 11:21:04 +02:00
parent 6f4af97024
commit 4a0e773d96
5 changed files with 80 additions and 4 deletions

View File

@@ -255,6 +255,20 @@ func (p Peer) WillExpire() bool {
return false
}
func (p Peer) IsExpired() bool {
if p.ExpiresAt == nil {
return false
}
if p.ExpiresAt.Before(time.Now()) {
return true
}
return false
}
func (p Peer) IsDeactivated() bool {
return p.DeactivatedAt != nil
}
func (p Peer) GetConfigFileName() string {
reg := regexp.MustCompile("[^a-zA-Z0-9_-]+")
return reg.ReplaceAllString(strings.ReplaceAll(p.Identifier, " ", "-"), "") + ".conf"