Skip to content

Commit

Permalink
Merge pull request #147 from GrappigPanda/issue-146
Browse files Browse the repository at this point in the history
Fixes #146
  • Loading branch information
Ian Clark authored Jun 19, 2016
2 parents e336fc9 + c863f2f commit fae8fca
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 fae8fca

Please sign in to comment.