Add disabling frontend (#137)

* Add disabling frontend

* fixes requested in review

* Document EnableWebFrontEnd in configuration.md
This commit is contained in:
хлифи 2025-02-03 13:16:32 +10:00 committed by GitHub
parent cda9c270f9
commit c16361c6bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 34 additions and 25 deletions

View File

@ -75,6 +75,7 @@ type Config struct {
Domain string Domain string
EnableBackgroundEffect bool EnableBackgroundEffect bool
EnableFooter bool EnableFooter bool
EnableWebFrontEnd bool
FallbackAPIServers []FallbackAPIServer FallbackAPIServers []FallbackAPIServer
ForwardSkins bool ForwardSkins bool
InstanceName string InstanceName string
@ -123,6 +124,7 @@ func DefaultConfig() Config {
Domain: "", Domain: "",
EnableBackgroundEffect: true, EnableBackgroundEffect: true,
EnableFooter: true, EnableFooter: true,
EnableWebFrontEnd: true,
ForwardSkins: true, ForwardSkins: true,
InstanceName: "Drasl", InstanceName: "Drasl",
ListenAddress: "0.0.0.0:25585", ListenAddress: "0.0.0.0:25585",

View File

@ -23,6 +23,7 @@ Other available options:
- `PreMigrationBackups`: Back up the database to `/path/to/StateDirectory/drasl.X.YYYY-mm-ddTHH-MM-SSZ.db` (where `X` is the old database version) before migrating to a new database version. Boolean. Default value: `true`. - `PreMigrationBackups`: Back up the database to `/path/to/StateDirectory/drasl.X.YYYY-mm-ddTHH-MM-SSZ.db` (where `X` is the old database version) before migrating to a new database version. Boolean. Default value: `true`.
- `EnableBackgroundEffect`: Whether to enable the 3D background animation in the web UI. Boolean. Default value: `true`. - `EnableBackgroundEffect`: Whether to enable the 3D background animation in the web UI. Boolean. Default value: `true`.
- `EnableFooter`: Whether to enable the page footer in the web UI. Boolean. Default value: `true`. - `EnableFooter`: Whether to enable the page footer in the web UI. Boolean. Default value: `true`.
- `EnableWebFrontEnd`: Whether to enable the web UI. Boolean. Default value: `true`.
- `[RateLimit]`: Rate-limit requests per IP address to limit abuse. Only applies to certain web UI routes, not any Yggdrasil routes. Requests for skins, capes, and web pages are also unaffected. Uses [Echo](https://echo.labstack.com)'s [rate limiter middleware](https://echo.labstack.com/middleware/rate-limiter/). - `[RateLimit]`: Rate-limit requests per IP address to limit abuse. Only applies to certain web UI routes, not any Yggdrasil routes. Requests for skins, capes, and web pages are also unaffected. Uses [Echo](https://echo.labstack.com)'s [rate limiter middleware](https://echo.labstack.com/middleware/rate-limiter/).
- `Enable`: Boolean. Default value: `true`. - `Enable`: Boolean. Default value: `true`.
- `RequestsPerSecond`: Number of requests per second allowed per IP address. Integer. Default value: `5`. - `RequestsPerSecond`: Number of requests per second allowed per IP address. Integer. Default value: `5`.

View File

@ -144,6 +144,7 @@ func (app *App) MakeServer() *echo.Echo {
} }
// Front // Front
if app.Config.EnableWebFrontEnd {
t := NewTemplate(app) t := NewTemplate(app)
e.Renderer = t e.Renderer = t
e.GET("/", FrontRoot(app)) e.GET("/", FrontRoot(app))
@ -168,6 +169,7 @@ func (app *App) MakeServer() *echo.Echo {
e.POST("/web/update-player", FrontUpdatePlayer(app)) e.POST("/web/update-player", FrontUpdatePlayer(app))
e.POST("/web/update-user", FrontUpdateUser(app)) e.POST("/web/update-user", FrontUpdateUser(app))
e.Static("/web/public", path.Join(app.Config.DataDirectory, "public")) e.Static("/web/public", path.Join(app.Config.DataDirectory, "public"))
}
e.Static("/web/texture/cape", path.Join(app.Config.StateDirectory, "cape")) e.Static("/web/texture/cape", path.Join(app.Config.StateDirectory, "cape"))
e.Static("/web/texture/default-cape", path.Join(app.Config.StateDirectory, "default-cape")) e.Static("/web/texture/default-cape", path.Join(app.Config.StateDirectory, "default-cape"))
e.Static("/web/texture/default-skin", path.Join(app.Config.StateDirectory, "default-skin")) e.Static("/web/texture/default-skin", path.Join(app.Config.StateDirectory, "default-skin"))
@ -435,7 +437,11 @@ func setup(config *Config) *App {
log.Fatal(result.Error) log.Fatal(result.Error)
} }
} }
if app.Config.EnableWebFrontEnd {
log.Println("No users found! Here's an invite URL:", Unwrap(app.InviteURL(&invite))) log.Println("No users found! Here's an invite URL:", Unwrap(app.InviteURL(&invite)))
} else {
log.Println("No users found! Here's an invite code:", invite.Code)
}
} }
} }
} }