From 42b86e4e34295ba468d625361de9de1aae31cfdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=20Jurmanovi=C4=87?= Date: Wed, 5 Feb 2025 18:39:29 +0100 Subject: [PATCH] better security --- local/api/api.go | 2 +- local/model/config.go | 58 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/local/api/api.go b/local/api/api.go index 2b65c16..0424bd4 100644 --- a/local/api/api.go +++ b/local/api/api.go @@ -32,7 +32,7 @@ func Init(di *dig.Container, app *fiber.App) { Lookup: groups.Group("/lookup"), } - routeGroups.Api.Use(basicAuthConfig) + groups.Use(basicAuthConfig) err := di.Provide(func() *common.RouteGroups { return routeGroups diff --git a/local/model/config.go b/local/model/config.go index 22b0ef2..2b8d8c3 100644 --- a/local/model/config.go +++ b/local/model/config.go @@ -19,3 +19,61 @@ type Configurations struct { EventRules map[string]interface{} Settings map[string]interface{} } + +type ServerSettings struct { + ServerName string `json:"serverName"` + AdminPassword string `json:"adminPassword"` + CarGroup string `json:"carGroup"` + TrackMedalsRequirement int `json:"trackMedalsRequirement"` + SafetyRatingRequirement int `json:"safetyRatingRequirement"` + RacecraftRatingRequirement int `json:"racecraftRatingRequirement"` + Password string `json:"password"` + SpectatorPassword string `json:"spectatorPassword"` + MaxCarSlots int `json:"maxCarSlots"` + DumpLeaderboards int `json:"dumpLeaderboards"` + IsRaceLocked int `json:"isRaceLocked"` + RandomizeTrackWhenEmpty int `json:"randomizeTrackWhenEmpty"` + CentralEntryListPath string `json:"centralEntryListPath"` + AllowAutoDQ int `json:"allowAutoDQ"` + ShortFormationLap int `json:"shortFormationLap"` + FormationLapType int `json:"formationLapType"` + IgnorePrematureDisconnects int `json:"ignorePrematureDisconnects"` +} + +type EventConfig struct { + Track string `json:"track"` + PreRaceWaitingTimeSeconds int `json:"preRaceWaitingTimeSeconds"` + SessionOverTimeSeconds int `json:"sessionOverTimeSeconds"` + AmbientTemp int `json:"ambientTemp"` + CloudLevel float64 `json:"cloudLevel"` + Rain float64 `json:"rain"` + WeatherRandomness int `json:"weatherRandomness"` + PostQualySeconds int `json:"postQualySeconds"` + PostRaceSeconds int `json:"postRaceSeconds"` + SimracerWeatherConditions int `json:"simracerWeatherConditions"` + IsFixedConditionQualification int `json:"isFixedConditionQualification"` + + Sessions []Session `json:"sessions"` +} + +type Session struct { + HourOfDay int `json:"hourOfDay"` + DayOfWeekend int `json:"dayOfWeekend"` + TimeMultiplier int `json:"timeMultiplier"` + SessionType string `json:"sessionType"` + SessionDurationMinutes int `json:"sessionDurationMinutes"` +} + +type EventRules struct { + QualifyStandingType int `json:"qualifyStandingType"` + PitWindowLengthSec int `json:"pitWindowLengthSec"` + DriverStintTimeSec int `json:"driverStintTimeSec"` + MandatoryPitstopCount int `json:"mandatoryPitstopCount"` + MaxTotalDrivingTime int `json:"maxTotalDrivingTime"` + IsRefuellingAllowedInRace bool `json:"isRefuellingAllowedInRace"` + IsRefuellingTimeFixed bool `json:"isRefuellingTimeFixed"` + IsMandatoryPitstopRefuellingRequired bool `json:"isMandatoryPitstopRefuellingRequired"` + IsMandatoryPitstopTyreChangeRequired bool `json:"isMandatoryPitstopTyreChangeRequired"` + IsMandatoryPitstopSwapDriverRequired bool `json:"isMandatoryPitstopSwapDriverRequired"` + TyreSetCount int `json:"tyreSetCount"` +} \ No newline at end of file