2023-03-09 23:26:08 +00:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
_ "embed"
|
|
|
|
"encoding/json"
|
2024-07-12 13:51:53 +00:00
|
|
|
"log"
|
2024-07-15 19:37:06 +00:00
|
|
|
"slices"
|
2023-03-09 23:26:08 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
//go:embed domain.json
|
|
|
|
var domainsFiles []byte
|
|
|
|
|
2024-07-15 19:37:06 +00:00
|
|
|
var Domains map[string][]string
|
2023-03-09 23:26:08 +00:00
|
|
|
|
|
|
|
func init() {
|
|
|
|
err := json.Unmarshal(domainsFiles, &Domains)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-15 19:37:06 +00:00
|
|
|
func AddDomain(domain, tld string) {
|
|
|
|
if _, ok := Domains[domain]; ok {
|
|
|
|
if !slices.Contains(Domains[domain], tld) {
|
|
|
|
Domains[domain] = append(Domains[domain], tld)
|
2023-03-09 23:26:08 +00:00
|
|
|
}
|
2024-07-15 19:37:06 +00:00
|
|
|
} else {
|
|
|
|
Domains[domain] = []string{tld}
|
2023-03-09 23:26:08 +00:00
|
|
|
}
|
|
|
|
}
|