diff options
author | FChannel <> | 2022-06-16 13:59:15 -0700 |
---|---|---|
committer | FChannel <> | 2022-06-19 12:53:29 -0700 |
commit | bc096c388bb0beeee09fa866a55ea1fbb41b9cb6 (patch) | |
tree | eefde542c7921e7422b3e2012c3b85b9d0e261fb | |
parent | aebf10de3b631f452600a5b31c1f43c1bbf8bdf2 (diff) |
config to set static modkey instead of randomly generate
-rw-r--r-- | config-init | 7 | ||||
-rw-r--r-- | config/config.go | 4 | ||||
-rw-r--r-- | main.go | 6 |
3 files changed, 11 insertions, 6 deletions
diff --git a/config-init b/config-init index 99a75f7..ae950b8 100644 --- a/config-init +++ b/config-init @@ -26,13 +26,14 @@ emailpass: ## enter proxy ip and port if you want to have tor connections supported ## 127.0.0.1:9050 default - torproxy: ## Change to true if you want your instance to be added to the public instance index - publicindex:false ## add your instance salt here for secure tripcodes - instancesalt: + +## this is the key used to access moderation pages leave empty to randomly generate each restart +## share with other admin or jannies if you are having others to moderate +modkey: diff --git a/config/config.go b/config/config.go index 11f4792..02d43eb 100644 --- a/config/config.go +++ b/config/config.go @@ -33,10 +33,12 @@ var PostCountPerPage = 10 var SupportedFiles = []string{"image/gif", "image/jpeg", "image/png", "image/webp", "image/apng", "video/mp4", "video/ogg", "video/webm", "audio/mpeg", "audio/ogg", "audio/wav", "audio/wave", "audio/x-wav"} var Log = log.New(os.Stdout, "", log.Ltime) var MediaHashs = make(map[string]string) -var Key string +var Key = GetConfigValue("modkey", "") var Themes []string var DB *sql.DB +// TODO Change this to some other config format like YAML +// to save into a struct and only read once func GetConfigValue(value string, ifnone string) string { file, err := os.Open("config/config-init") @@ -143,8 +143,10 @@ func Init() { config.Log.Println(err) } - if config.Key, err = util.CreateKey(32); err != nil { - config.Log.Println(err) + if config.Key == "" { + if config.Key, err = util.CreateKey(32); err != nil { + config.Log.Println(err) + } } if err = util.LoadThemes(); err != nil { |