make launcher server optional

This commit is contained in:
wish
2022-08-23 18:38:13 +10:00
parent 6e7259a068
commit 8099c5fd66
3 changed files with 36 additions and 29 deletions

View File

@@ -5,6 +5,7 @@
"devmode": true, "devmode": true,
"devmodeoptions": { "devmodeoptions": {
"serverName" : "", "serverName" : "",
"EnableLauncherServer": false,
"hideLoginNotice": false, "hideLoginNotice": false,
"loginNotice": "<BODY><CENTER><SIZE_3><C_4>Welcome to Erupe SU9 (Patch 1)!<BR><BODY><LEFT><SIZE_2><C_5>Erupe is experimental software<C_7>, we are not liable for any<BR><BODY>issues caused by installing the software!<BR><BODY><BR><BODY><C_4>■Report bugs on Discord!<C_7><BR><BODY><BR><BODY><C_4>■Test everything!<C_7><BR><BODY><BR><BODY><C_4>■Don't talk to softlocking NPCs!<C_7><BR><BODY><BR><BODY><C_4>■Fork the code on GitHub!<C_7><BR><BODY><BR><BODY>Thank you to all of the contributors,<BR><BODY><BR><BODY>this wouldn't exist without you.", "loginNotice": "<BODY><CENTER><SIZE_3><C_4>Welcome to Erupe SU9 (Patch 1)!<BR><BODY><LEFT><SIZE_2><C_5>Erupe is experimental software<C_7>, we are not liable for any<BR><BODY>issues caused by installing the software!<BR><BODY><BR><BODY><C_4>■Report bugs on Discord!<C_7><BR><BODY><BR><BODY><C_4>■Test everything!<C_7><BR><BODY><BR><BODY><C_4>■Don't talk to softlocking NPCs!<C_7><BR><BODY><BR><BODY><C_4>■Fork the code on GitHub!<C_7><BR><BODY><BR><BODY>Thank you to all of the contributors,<BR><BODY><BR><BODY>this wouldn't exist without you.",
"cleandb": false, "cleandb": false,

View File

@@ -24,23 +24,24 @@ type Config struct {
// DevModeOptions holds various debug/temporary options for use while developing Erupe. // DevModeOptions holds various debug/temporary options for use while developing Erupe.
type DevModeOptions struct { type DevModeOptions struct {
ServerName string // To get specific instance server about (Current Players/Event Week) ServerName string // To get specific instance server about (Current Players/Event Week)
HideLoginNotice bool // Hide the Erupe notice on login EnableLauncherServer bool // Enables the launcher server to be served on port 80
LoginNotice string // MHFML string of the login notice displayed HideLoginNotice bool // Hide the Erupe notice on login
CleanDB bool // Automatically wipes the DB on server reset. LoginNotice string // MHFML string of the login notice displayed
MaxLauncherHR bool // Sets the HR returned in the launcher to HR9 so that you can join non-beginner worlds. CleanDB bool // Automatically wipes the DB on server reset.
FixedStageID bool // Causes all move_stage to use the ID sl1Ns200p0a0u0 to get you into all stages MaxLauncherHR bool // Sets the HR returned in the launcher to HR9 so that you can join non-beginner worlds.
LogInboundMessages bool // Log all messages sent to the server FixedStageID bool // Causes all move_stage to use the ID sl1Ns200p0a0u0 to get you into all stages
LogOutboundMessages bool // Log all messages sent to the clients LogInboundMessages bool // Log all messages sent to the server
MaxHexdumpLength int // Maximum number of bytes printed when logs are enabled LogOutboundMessages bool // Log all messages sent to the clients
DivaEvent int // Diva Defense event status MaxHexdumpLength int // Maximum number of bytes printed when logs are enabled
FestaEvent int // Hunter's Festa event status DivaEvent int // Diva Defense event status
TournamentEvent int // VS Tournament event status FestaEvent int // Hunter's Festa event status
MezFesEvent bool // MezFes status TournamentEvent int // VS Tournament event status
MezFesAlt bool // Swaps out Volpakkun for Tokotoko MezFesEvent bool // MezFes status
DisableTokenCheck bool // Disables checking login token exists in the DB (security risk!) MezFesAlt bool // Swaps out Volpakkun for Tokotoko
DisableMailItems bool // Hack to prevent english versions of MHF from crashing DisableTokenCheck bool // Disables checking login token exists in the DB (security risk!)
SaveDumps SaveDumpOptions DisableMailItems bool // Hack to prevent english versions of MHF from crashing
SaveDumps SaveDumpOptions
} }
type SaveDumpOptions struct { type SaveDumpOptions struct {

29
main.go
View File

@@ -125,18 +125,21 @@ func main() {
// Now start our server(s). // Now start our server(s).
// Launcher HTTP server. // Launcher HTTP server.
launcherServer := launcherserver.NewServer( var launcherServer *launcherserver.Server
&launcherserver.Config{ if erupeConfig.DevMode && erupeConfig.DevModeOptions.EnableLauncherServer {
Logger: logger.Named("launcher"), launcherServer = launcherserver.NewServer(
ErupeConfig: erupeConfig, &launcherserver.Config{
DB: db, Logger: logger.Named("launcher"),
UseOriginalLauncherFiles: erupeConfig.Launcher.UseOriginalLauncherFiles, ErupeConfig: erupeConfig,
}) DB: db,
err = launcherServer.Start() UseOriginalLauncherFiles: erupeConfig.Launcher.UseOriginalLauncherFiles,
if err != nil { })
preventClose(fmt.Sprintf("Failed to start launcher server: %s", err.Error())) 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. // Entrance server.
entranceServer := entranceserver.NewServer( entranceServer := entranceserver.NewServer(
@@ -219,7 +222,9 @@ func main() {
} }
signServer.Shutdown() signServer.Shutdown()
entranceServer.Shutdown() entranceServer.Shutdown()
launcherServer.Shutdown() if erupeConfig.DevModeOptions.EnableLauncherServer {
launcherServer.Shutdown()
}
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
} }