实现 MLS 设备封包投递与离线同步
This commit is contained in:
1 parent
53164d0fa8
commit
f30f01b699
15 files changed
+366
-16
No files matched your search
@@ -11,19 +11,28 @@ type Config struct {
|
||||
Addr, DatabaseURL, RedisURL string
|
||||
Origins map[string]bool
|
||||
SessionTTL time.Duration
|
||||
EnvelopeRetention time.Duration
|
||||
}
|
||||
|
||||
func Load() (Config, error) {
|
||||
c := Config{
|
||||
Addr: os.Getenv("XHCHAT_ADDR"),
|
||||
DatabaseURL: os.Getenv("DATABASE_URL"),
|
||||
RedisURL: os.Getenv("REDIS_URL"),
|
||||
Origins: make(map[string]bool),
|
||||
SessionTTL: 12 * time.Hour,
|
||||
Addr: os.Getenv("XHCHAT_ADDR"),
|
||||
DatabaseURL: os.Getenv("DATABASE_URL"),
|
||||
RedisURL: os.Getenv("REDIS_URL"),
|
||||
Origins: make(map[string]bool),
|
||||
SessionTTL: 12 * time.Hour,
|
||||
EnvelopeRetention: 30 * 24 * time.Hour,
|
||||
}
|
||||
if c.Addr == "" {
|
||||
c.Addr = "127.0.0.1:8080"
|
||||
}
|
||||
if raw := os.Getenv("XHCHAT_ENVELOPE_RETENTION"); raw != "" {
|
||||
retention, err := time.ParseDuration(raw)
|
||||
if err != nil || retention < time.Hour || retention > 365*24*time.Hour {
|
||||
return Config{}, errors.New("XHCHAT_ENVELOPE_RETENTION must be between 1h and 8760h")
|
||||
}
|
||||
c.EnvelopeRetention = retention
|
||||
}
|
||||
for _, origin := range strings.Split(os.Getenv("XHCHAT_ORIGINS"), ",") {
|
||||
if origin = strings.TrimSpace(origin); origin != "" {
|
||||
c.Origins[origin] = true
|
||||
|
||||
Reference in new issue
Block a user