Skip to content

Commit 869e18e

Browse files
committed
feat: allow user enable dashboard with config
1 parent caefdd8 commit 869e18e

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ docker-compose up -d
2929
If ```grimd.toml``` is not found, it will be generated for you, below is the default configuration.
3030
```toml
3131
# version this config was generated from
32-
version = "1.0.8"
32+
version = "1.0.9"
3333

3434
# list of sources to pull blocklists from, stores them in ./sources
3535
sources = [
@@ -58,6 +58,9 @@ logconfig = "file:grimd.log@2,stderr@2"
5858
# apidebug enables the debug mode of the http api library
5959
apidebug = false
6060

61+
# enable the web interface by default
62+
dashboard = true
63+
6164
# address to bind to for the DNS server
6265
bind = "0.0.0.0:53"
6366

api.go

+9-6
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,16 @@ func StartAPIServer(config *Config,
5858

5959
router.Use(cors.Default())
6060

61-
router.GET("/", func(c *gin.Context) {
62-
c.Redirect(http.StatusTemporaryRedirect, "/dashboard")
63-
c.Abort()
64-
})
61+
// Serves only if the user configuration enables the dashboard
62+
if config.Dashboard {
63+
router.GET("/", func(c *gin.Context) {
64+
c.Redirect(http.StatusTemporaryRedirect, "/dashboard")
65+
c.Abort()
66+
})
6567

66-
dashboardAssets, _ := fs.Sub(dashboardAssets, "dashboard/reaper")
67-
router.StaticFS("/dashboard", http.FS(dashboardAssets))
68+
dashboardAssets, _ := fs.Sub(dashboardAssets, "dashboard/reaper")
69+
router.StaticFS("/dashboard", http.FS(dashboardAssets))
70+
}
6871

6972
router.GET("/blockcache", func(c *gin.Context) {
7073
special := make([]string, 0, len(blockCache.Special))

config.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
var BuildVersion = "1.0.7"
1717

1818
// ConfigVersion returns the version of grimd, this should be incremented every time the config changes so grimd presents a warning
19-
var ConfigVersion = "1.0.8"
19+
var ConfigVersion = "1.0.9"
2020

2121
// Config holds the configuration parameters
2222
type Config struct {
@@ -41,6 +41,7 @@ type Config struct {
4141
CustomDNSRecords []string
4242
ToggleName string
4343
ReactivationDelay uint
44+
Dashboard bool
4445
APIDebug bool
4546
DoH string
4647
UseDrbl int
@@ -80,6 +81,9 @@ logconfig = "file:grimd.log@2,stderr@2"
8081
# apidebug enables the debug mode of the http api library
8182
apidebug = false
8283
84+
# enable the web interface by default
85+
dashboard = true
86+
8387
# address to bind to for the DNS server
8488
bind = "0.0.0.0:53"
8589

0 commit comments

Comments
 (0)