Compare commits
4 Commits
2024.1.5-s
...
master
Author | SHA1 | Date |
---|---|---|
wpetit | 51bdf4d015 | |
wpetit | 635f170762 | |
wpetit | 834f6346dd | |
wpetit | 34adfb3e87 |
|
@ -5,11 +5,11 @@ import (
|
|||
"crypto/rsa"
|
||||
"crypto/sha256"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
jwt "github.com/dgrijalva/jwt-go"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
peering "forge.cadoles.com/Cadoles/go-http-peering"
|
||||
"forge.cadoles.com/Cadoles/go-http-peering/crypto"
|
||||
|
@ -52,7 +52,7 @@ func (c *Client) Advertise(attrs peering.PeerAttributes) error {
|
|||
case http.StatusConflict:
|
||||
return peering.ErrPeerExists
|
||||
default:
|
||||
return ErrUnexpectedResponse
|
||||
return errors.Wrapf(ErrUnexpectedResponse, "unexpected http status code '%d'", res.StatusCode)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ func (c *Client) UpdateAttributes(attrs peering.PeerAttributes) error {
|
|||
case http.StatusForbidden:
|
||||
return ErrRejected
|
||||
default:
|
||||
return ErrUnexpectedResponse
|
||||
return errors.Wrapf(ErrUnexpectedResponse, "unexpected http status code '%d'", res.StatusCode)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ func (c *Client) Ping() error {
|
|||
case http.StatusForbidden:
|
||||
return ErrRejected
|
||||
default:
|
||||
return ErrUnexpectedResponse
|
||||
return errors.Wrapf(ErrUnexpectedResponse, "unexpected http status code '%d'", res.StatusCode)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
FROM golang:1.19
|
||||
FROM reg.cadoles.com/proxy_cache/library/golang:1.21
|
||||
|
||||
RUN apt-get update && apt-get install -y make upx-ucl curl ca-certificates bash jq
|
||||
RUN apt-get update && apt-get install -y make curl ca-certificates bash jq
|
||||
|
||||
RUN curl -k https://forge.cadoles.com/Cadoles/Jenkins/raw/branch/master/resources/com/cadoles/common/add-letsencrypt-ca.sh | bash
|
||||
|
|
|
@ -34,7 +34,7 @@ func AdvertiseHandler(store peering.Store, key *rsa.PublicKey, funcs ...OptionFu
|
|||
|
||||
serverClaims, err := assertServerToken(key, serverToken)
|
||||
if err != nil {
|
||||
logger.Printf("[ERROR] %+v", errors.WithStack(err))
|
||||
logger.Printf("[ERROR] %+v", errors.Wrapf(err, "could not validate token '%s'", serverToken))
|
||||
sendError(w, http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
@ -54,14 +54,14 @@ func AdvertiseHandler(store peering.Store, key *rsa.PublicKey, funcs ...OptionFu
|
|||
return
|
||||
}
|
||||
|
||||
peer, err := store.Get(serverClaims.PeerID)
|
||||
_, err = store.Get(serverClaims.PeerID)
|
||||
if err == nil {
|
||||
logger.Printf("[ERROR] %+v", errors.WithStack(ErrPeerIDAlreadyInUse))
|
||||
logger.Printf("[WARN] %s", errors.WithStack(ErrPeerIDAlreadyInUse))
|
||||
options.ErrorHandler(w, r, ErrPeerIDAlreadyInUse)
|
||||
return
|
||||
}
|
||||
|
||||
if err != peering.ErrPeerNotFound {
|
||||
if !errors.Is(err, peering.ErrPeerNotFound) {
|
||||
logger.Printf("[ERROR] %+v", errors.WithStack(err))
|
||||
options.ErrorHandler(w, r, err)
|
||||
return
|
||||
|
@ -69,7 +69,7 @@ func AdvertiseHandler(store peering.Store, key *rsa.PublicKey, funcs ...OptionFu
|
|||
|
||||
attrs := filterAttributes(options.PeerAttributes, advertising.Attributes)
|
||||
|
||||
peer, err = store.Create(serverClaims.PeerID, attrs)
|
||||
peer, err := store.Create(serverClaims.PeerID, attrs)
|
||||
if err != nil {
|
||||
logger.Printf("[ERROR] %+v", errors.WithStack(err))
|
||||
options.ErrorHandler(w, r, err)
|
||||
|
|
Loading…
Reference in New Issue