Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Javex committed May 25, 2024
1 parent ca78ae9 commit d043505
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 23 deletions.
11 changes: 5 additions & 6 deletions banlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ type Banlist struct {

func NewBanlist(ctx caddy.Context, logger *zap.Logger, banfile *string) Banlist {
banlist := Banlist{
ctx: ctx,
bannedIps: make([]string, 0),
queries: make(chan banQuery),
logger: logger,
banfile: banfile,
reload: make(chan chan bool),
ctx: ctx,
queries: make(chan banQuery),
logger: logger,
banfile: banfile,
reload: make(chan chan bool),
}
return banlist
}
Expand Down
18 changes: 1 addition & 17 deletions fail2ban.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@ func (m *Fail2Ban) Provision(ctx caddy.Context) error {
return nil
}

// Validate implements caddy.Validator.
// func (m *Fail2Ban) Validate() error {
// // if m.w == nil {
// // return fmt.Errorf("no writer")
// // }
// return nil
// }

func (m *Fail2Ban) Match(req *http.Request) bool {
remote_ip, _, err := net.SplitHostPort(req.RemoteAddr)
if err != nil {
Expand Down Expand Up @@ -89,17 +81,9 @@ func (m *Fail2Ban) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
return nil
}

// parseCaddyfile unmarshals tokens from h into a new Middleware.
// func parseCaddyfile(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error) {
// var m Fail2Ban
// err := m.UnmarshalCaddyfile(h.Dispenser)
// return m, err
// }

// Interface guards
var (
_ caddy.Provisioner = (*Fail2Ban)(nil)
// _ caddy.Validator = (*Fail2Ban)(nil)
_ caddy.Provisioner = (*Fail2Ban)(nil)
_ caddyhttp.RequestMatcher = (*Fail2Ban)(nil)
_ caddyfile.Unmarshaler = (*Fail2Ban)(nil)
)

0 comments on commit d043505

Please sign in to comment.