Update last contact even if the remote peer is not authorized yet
This commit is contained in:
parent
5986d2bb9b
commit
41f3d5c7ac
|
@ -61,9 +61,17 @@ func Authenticate(store peering.Store, key *rsa.PublicKey, funcs ...OptionFunc)
|
|||
clientClaims, err := assertClientToken(serverClaims.PeerID, store, clientToken)
|
||||
if err != nil {
|
||||
logger.Printf("[ERROR] %s", err)
|
||||
if err == peering.ErrPeerNotFound || err == ErrNotPeered {
|
||||
switch err {
|
||||
case peering.ErrPeerNotFound:
|
||||
sendError(w, http.StatusUnauthorized)
|
||||
} else {
|
||||
case ErrNotPeered:
|
||||
if err := store.UpdateLastContact(serverClaims.PeerID, r.RemoteAddr, time.Now()); err != nil {
|
||||
logger.Printf("[ERROR] %s", err)
|
||||
sendError(w, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
sendError(w, http.StatusUnauthorized)
|
||||
default:
|
||||
sendError(w, http.StatusInternalServerError)
|
||||
}
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue