Просмотр исходного кода

add validation check for 0.0.0.0 OSCAR_HOST

Mike 1 год назад
Родитель
Сommit
1cd8918fb0
1 измененных файлов с 7 добавлено и 0 удалено
  1. 7 0
      cmd/server/factory.go

+ 7 - 0
cmd/server/factory.go

@@ -1,6 +1,7 @@
 package main
 
 import (
+	"errors"
 	"fmt"
 	"log/slog"
 	"net"
@@ -35,6 +36,12 @@ func MakeCommonDeps() (Container, error) {
 		return c, fmt.Errorf("unable to process app config: %s\n", err.Error())
 	}
 
+	if c.cfg.OSCARHost == "0.0.0.0" {
+		return c, errors.New("invalid config: OSCAR_HOST cannot be set to " +
+			"the 'all interfaces' IP (0.0.0.0). it must be a specific IP " +
+			"address or hostname reachable by AIM/ICQ clients")
+	}
+
 	c.sqLiteUserStore, err = state.NewSQLiteUserStore(c.cfg.DBPath)
 	if err != nil {
 		return c, fmt.Errorf("unable to create feedbag store: %s\n", err.Error())