mirror of
https://github.com/sot-tech/mochi.git
synced 2026-06-18 18:39:46 -07:00
middleware/client: be more specific with error messages
contributes to #160
This commit is contained in:
@@ -15,9 +15,9 @@ func init() {
|
||||
tracker.RegisterAnnounceMiddleware("client_blacklist", blacklistAnnounceClient)
|
||||
}
|
||||
|
||||
// ErrBlockedClient is returned by an announce middleware if the announcing
|
||||
// Client is disallowed.
|
||||
var ErrBlockedClient = tracker.ClientError("disallowed client")
|
||||
// ErrBlacklistedClient is returned by an announce middleware if the announcing
|
||||
// Client is blacklisted.
|
||||
var ErrBlacklistedClient = tracker.ClientError("client blacklisted")
|
||||
|
||||
// blacklistAnnounceClient provides a middleware that only allows Clients to
|
||||
// announce that are not stored in the StringStore.
|
||||
@@ -27,7 +27,7 @@ func blacklistAnnounceClient(next tracker.AnnounceHandler) tracker.AnnounceHandl
|
||||
if err != nil {
|
||||
return err
|
||||
} else if blacklisted {
|
||||
return ErrBlockedClient
|
||||
return ErrBlacklistedClient
|
||||
}
|
||||
return next(cfg, req, resp)
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ func whitelistAnnounceClient(next tracker.AnnounceHandler) tracker.AnnounceHandl
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !whitelisted {
|
||||
return ErrBlockedClient
|
||||
return ErrNotWhitelistedClient
|
||||
}
|
||||
return next(cfg, req, resp)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user