12 banList map[string]*time.Time
18 func NewBanFile(path string) (*BanFile, error) {
21 banList: make(map[string]*time.Time),
29 func (bf *BanFile) Load() error {
33 bf.banList = make(map[string]*time.Time)
35 fh, err := os.Open(bf.filePath)
37 if os.IsNotExist(err) {
44 decoder := yaml.NewDecoder(fh)
45 err = decoder.Decode(&bf.banList)
53 func (bf *BanFile) Add(ip string, until *time.Time) error {
57 bf.banList[ip] = until
59 out, err := yaml.Marshal(bf.banList)
64 return os.WriteFile(filepath.Join(bf.filePath), out, 0644)
67 func (bf *BanFile) IsBanned(ip string) (bool, *time.Time) {
71 if until, ok := bf.banList[ip]; ok {