From 8099c5fd666f23a9c75159fa96cfcc9337da8734 Mon Sep 17 00:00:00 2001 From: wish Date: Tue, 23 Aug 2022 18:38:13 +1000 Subject: [PATCH] make launcher server optional --- config.json | 1 + config/config.go | 35 ++++++++++++++++++----------------- main.go | 29 +++++++++++++++++------------ 3 files changed, 36 insertions(+), 29 deletions(-) diff --git a/config.json b/config.json index 67087d28c..c035f60c0 100644 --- a/config.json +++ b/config.json @@ -5,6 +5,7 @@ "devmode": true, "devmodeoptions": { "serverName" : "", + "EnableLauncherServer": false, "hideLoginNotice": false, "loginNotice": "
Welcome to Erupe SU9 (Patch 1)!
Erupe is experimental software, we are not liable for any
issues caused by installing the software!

■Report bugs on Discord!

■Test everything!

■Don't talk to softlocking NPCs!

■Fork the code on GitHub!

Thank you to all of the contributors,

this wouldn't exist without you.", "cleandb": false, diff --git a/config/config.go b/config/config.go index b025e7a0a..bfbf8086a 100644 --- a/config/config.go +++ b/config/config.go @@ -24,23 +24,24 @@ type Config struct { // DevModeOptions holds various debug/temporary options for use while developing Erupe. type DevModeOptions struct { - ServerName string // To get specific instance server about (Current Players/Event Week) - HideLoginNotice bool // Hide the Erupe notice on login - LoginNotice string // MHFML string of the login notice displayed - CleanDB bool // Automatically wipes the DB on server reset. - MaxLauncherHR bool // Sets the HR returned in the launcher to HR9 so that you can join non-beginner worlds. - FixedStageID bool // Causes all move_stage to use the ID sl1Ns200p0a0u0 to get you into all stages - LogInboundMessages bool // Log all messages sent to the server - LogOutboundMessages bool // Log all messages sent to the clients - MaxHexdumpLength int // Maximum number of bytes printed when logs are enabled - DivaEvent int // Diva Defense event status - FestaEvent int // Hunter's Festa event status - TournamentEvent int // VS Tournament event status - MezFesEvent bool // MezFes status - MezFesAlt bool // Swaps out Volpakkun for Tokotoko - DisableTokenCheck bool // Disables checking login token exists in the DB (security risk!) - DisableMailItems bool // Hack to prevent english versions of MHF from crashing - SaveDumps SaveDumpOptions + ServerName string // To get specific instance server about (Current Players/Event Week) + EnableLauncherServer bool // Enables the launcher server to be served on port 80 + HideLoginNotice bool // Hide the Erupe notice on login + LoginNotice string // MHFML string of the login notice displayed + CleanDB bool // Automatically wipes the DB on server reset. + MaxLauncherHR bool // Sets the HR returned in the launcher to HR9 so that you can join non-beginner worlds. + FixedStageID bool // Causes all move_stage to use the ID sl1Ns200p0a0u0 to get you into all stages + LogInboundMessages bool // Log all messages sent to the server + LogOutboundMessages bool // Log all messages sent to the clients + MaxHexdumpLength int // Maximum number of bytes printed when logs are enabled + DivaEvent int // Diva Defense event status + FestaEvent int // Hunter's Festa event status + TournamentEvent int // VS Tournament event status + MezFesEvent bool // MezFes status + MezFesAlt bool // Swaps out Volpakkun for Tokotoko + DisableTokenCheck bool // Disables checking login token exists in the DB (security risk!) + DisableMailItems bool // Hack to prevent english versions of MHF from crashing + SaveDumps SaveDumpOptions } type SaveDumpOptions struct { diff --git a/main.go b/main.go index 2bc598a06..b9dc62538 100644 --- a/main.go +++ b/main.go @@ -125,18 +125,21 @@ func main() { // Now start our server(s). // Launcher HTTP server. - launcherServer := launcherserver.NewServer( - &launcherserver.Config{ - Logger: logger.Named("launcher"), - ErupeConfig: erupeConfig, - DB: db, - UseOriginalLauncherFiles: erupeConfig.Launcher.UseOriginalLauncherFiles, - }) - err = launcherServer.Start() - if err != nil { - preventClose(fmt.Sprintf("Failed to start launcher server: %s", err.Error())) + var launcherServer *launcherserver.Server + if erupeConfig.DevMode && erupeConfig.DevModeOptions.EnableLauncherServer { + launcherServer = launcherserver.NewServer( + &launcherserver.Config{ + Logger: logger.Named("launcher"), + ErupeConfig: erupeConfig, + DB: db, + UseOriginalLauncherFiles: erupeConfig.Launcher.UseOriginalLauncherFiles, + }) + err = launcherServer.Start() + if err != nil { + preventClose(fmt.Sprintf("Failed to start launcher server: %s", err.Error())) + } + logger.Info("Started launcher server") } - logger.Info("Started launcher server") // Entrance server. entranceServer := entranceserver.NewServer( @@ -219,7 +222,9 @@ func main() { } signServer.Shutdown() entranceServer.Shutdown() - launcherServer.Shutdown() + if erupeConfig.DevModeOptions.EnableLauncherServer { + launcherServer.Shutdown() + } time.Sleep(1 * time.Second) }