2020-03-27 13:57:14 +00:00
|
|
|
package adlin
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2022-03-05 11:04:59 +00:00
|
|
|
var (
|
2023-02-28 14:01:28 +00:00
|
|
|
AssociatedDomainSuffixes = []string{"adlin2024.driive.online.", "adlin2024.driive.site.", "adlin2024.drivve.online.", "adlin2024.drivee.site.", "adlin2024.p0m.fr."}
|
|
|
|
DelegatedDomainSuffixes = []string{"srs.driive.online.", "srs.driive.site.", "srs.drivve.online.", "srs.drivee.site.", "srs.p0m.fr."}
|
2020-03-27 13:57:14 +00:00
|
|
|
)
|
|
|
|
|
2022-03-05 11:04:59 +00:00
|
|
|
func (student *Student) MyDelegatedDomainSuffix() string {
|
2022-03-28 21:55:31 +00:00
|
|
|
if student.DelegatedDomain != nil {
|
|
|
|
for _, ddomain := range DelegatedDomainSuffixes {
|
|
|
|
if strings.HasSuffix(*student.DelegatedDomain, ddomain) {
|
|
|
|
return ddomain
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-05 11:04:59 +00:00
|
|
|
return DelegatedDomainSuffixes[int(student.Id)%len(DelegatedDomainSuffixes)]
|
|
|
|
}
|
|
|
|
|
2021-03-07 11:39:38 +00:00
|
|
|
func (student *Student) MyDelegatedDomain() string {
|
2021-03-04 00:04:58 +00:00
|
|
|
if student.DelegatedDomain != nil {
|
|
|
|
return *student.DelegatedDomain
|
|
|
|
}
|
2022-03-28 21:55:31 +00:00
|
|
|
|
|
|
|
return fmt.Sprintf("%s.%s", strings.Trim(strings.Replace(student.Login, "_", "-", -1), "-_"), student.MyDelegatedDomainSuffix())
|
2020-03-27 13:57:14 +00:00
|
|
|
}
|
|
|
|
|
2022-03-05 11:04:59 +00:00
|
|
|
func (student *Student) MyAssociatedDomainSuffix() string {
|
|
|
|
return AssociatedDomainSuffixes[int(student.Id)%len(AssociatedDomainSuffixes)]
|
|
|
|
}
|
|
|
|
|
2021-03-07 11:39:38 +00:00
|
|
|
func (student *Student) DefaultAssociatedDomain() string {
|
2022-03-05 11:04:59 +00:00
|
|
|
return fmt.Sprintf("%s.%s", strings.Trim(strings.Replace(student.Login, "_", "-", -1), "-_"), student.MyAssociatedDomainSuffix())
|
2021-03-05 13:52:14 +00:00
|
|
|
}
|
|
|
|
|
2021-03-07 11:39:38 +00:00
|
|
|
func (student *Student) MyAssociatedDomain() string {
|
2021-03-04 00:04:58 +00:00
|
|
|
if student.AssociatedDomain != nil {
|
|
|
|
return *student.AssociatedDomain
|
|
|
|
}
|
2022-03-28 21:55:31 +00:00
|
|
|
|
|
|
|
return student.DefaultAssociatedDomain()
|
2020-03-27 13:57:14 +00:00
|
|
|
}
|
|
|
|
|
2021-03-07 11:39:38 +00:00
|
|
|
func (student *Student) GetAssociatedDomains() (ds []string) {
|
2021-03-05 13:52:14 +00:00
|
|
|
defdn := student.DefaultAssociatedDomain()
|
|
|
|
ds = append(ds, defdn)
|
|
|
|
|
2020-03-27 13:57:14 +00:00
|
|
|
studentDomain := student.MyAssociatedDomain()
|
|
|
|
|
2021-03-05 13:52:14 +00:00
|
|
|
if defdn != studentDomain {
|
|
|
|
ds = append(ds, studentDomain)
|
|
|
|
}
|
2020-03-27 13:57:14 +00:00
|
|
|
|
|
|
|
return
|
|
|
|
}
|