Skip to content

Commit

Permalink
chore: error checking
Browse files Browse the repository at this point in the history
Signed-off-by: Glenn Vriesman <[email protected]>
  • Loading branch information
glvr182 committed Jun 5, 2020
1 parent 1cbc5ce commit 68135bb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ func main() {
pflag.StringP("database", "d", "/var/lib/fail2ban/fail2ban.sqlite3", "fail2ban sqlite database location")
pflag.StringP("remote", "r", "freeGeoIP", "remote provider to use (defaults to freeGeoIP)")
pflag.Parse()
viper.BindPFlags(pflag.CommandLine)
if err := viper.BindPFlags(pflag.CommandLine); err != nil {
log.Fatal(err)
}
viper.SetEnvPrefix("F2B") // will be uppercased automatically
viper.AutomaticEnv()
log.Println("Starting exporter")
Expand Down Expand Up @@ -104,7 +106,7 @@ func jailed(db *sqlittle.DB, provider provider.Provider) ([]prisoner, error) {
err error
)

db.SelectDone("bans", func(r sqlittle.Row) bool {
if err := db.SelectDone("bans", func(r sqlittle.Row) bool {
err = r.Scan(&p.jail, &p.ip, &p.timeofban, &p.bantime)
if err != nil {
return true
Expand All @@ -124,7 +126,9 @@ func jailed(db *sqlittle.DB, provider provider.Provider) ([]prisoner, error) {
prisoners = append(prisoners, p)
return false

}, "jail", "ip", "timeofban", "bantime")
}, "jail", "ip", "timeofban", "bantime"); err != nil {
log.Fatal(err)
}

if err != nil {
return nil, err
Expand Down

0 comments on commit 68135bb

Please sign in to comment.