Skip to content

Commit

Permalink
Issue #146
Browse files Browse the repository at this point in the history
CHANGE:
  - config.yaml Made a note about how whitelisting defaults to false.
  - config/config.go We now explicitly parse a whitelist value from a string
  • Loading branch information
Ianleeclark committed Jun 19, 2016
1 parent 3a2eb92 commit 3ff0b3b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ RedisServer: localhost
RedisPort: 6379
# Whitelist indicates that torrent whitelisting is activated. When torrent
# whitelisting is activated, only pre-approved torrents can be served by
# Notorious
Whitelist: false
# Notorious. If whitelist is unable to be parsed, we will default to `false`
whitelist: false
# UseEnvVariables allows environmental variables to be used instead of
# expliclitly defined config variables.
UseEnvVariables: true
9 changes: 7 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package config

import (
"github.com/spf13/viper"
"strconv"
)

// ConfigStruct holds the values that our config file holds
Expand Down Expand Up @@ -34,6 +35,10 @@ func LoadConfig() ConfigStruct {
viper.BindEnv("mysqluser")
}

whitelist, err := strconv.ParseBool(viper.Get("whitelist").(string))
if err != nil {
whitelist = false
}

if viper.Get("MySQLPass").(string) != "" {
return ConfigStruct{
Expand All @@ -42,7 +47,7 @@ func LoadConfig() ConfigStruct {
viper.Get("mysqluser").(string),
viper.Get("mysqlpass").(string),
viper.Get("mysqldb").(string),
viper.Get("whitelist").(bool),
whitelist,
}
} else {
return ConfigStruct{
Expand All @@ -51,7 +56,7 @@ func LoadConfig() ConfigStruct {
viper.Get("mysqluser").(string),
"",
viper.Get("mysqldb").(string),
viper.Get("whitelist").(bool),
whitelist,
}
}

Expand Down

0 comments on commit 3ff0b3b

Please sign in to comment.