gb vendor updates
gb vendor update github.com/matrix-org/gomatrixserverlib
gb vendor update github.com/matrix-org/util
MODIFY
vendor/manifest
vendor/manifest
{
"importpath": "github.com/matrix-org/gomatrixserverlib",
"repository": "https://github.com/matrix-org/gomatrixserverlib",
- "revision": "27d214da42f51906c2038ad3ddcffac9103c8e8f",
+ "revision": "fb17c27f65a0699b0d15f5311a530225b4aea5e0",
"branch": "master"
},
{
{
"importpath": "github.com/matrix-org/util",
"repository": "https://github.com/matrix-org/util",
- "revision": "53326ed5598b226681112cbd441f59f3cffc9c82",
+ "revision": "cf7e2e3871b7ae39106a1763312deaaf0c139531",
"branch": "master"
},
{

MODIFY
vendor/src/github.com/matrix-org/gomatrixserverlib/client.go
vendor/src/github.com/matrix-org/gomatrixserverlib/client.go
@@ -92,7 +92,13 @@ func (f *federationTripper) RoundTrip(r *http.Request) (*http.Response, error) {
if err != nil {
return nil, err
}
+
+ if len(dnsResult.Addrs) == 0 {
+ return nil, fmt.Errorf("no address found for matrix host %v", serverName)
+ }
+
var resp *http.Response
+ // TODO: respect the priority and weight fields from the SRV record
for _, addr := range dnsResult.Addrs {
u := makeHTTPSURL(r.URL, addr)
r.URL = &u
@@ -100,8 +106,12 @@ func (f *federationTripper) RoundTrip(r *http.Request) (*http.Response, error) {
if err == nil {
return resp, nil
}
+ util.GetLogger(r.Context()).Warnf("Error sending request to %s: %v",
+ u.String(), err)
}
- return nil, fmt.Errorf("no address found for matrix host %v", serverName)
+
+ // just return the most recent error
+ return nil, err
}
// LookupUserInfo gets information about a user from a given matrix homeserver
@@ -253,9 +263,10 @@ func (fc *Client) CreateMediaDownloadRequest(
func (fc *Client) doHTTPRequest(ctx context.Context, req *http.Request) (*http.Response, error) {
reqID := util.RandomString(12)
logger := util.GetLogger(ctx).WithField("server", req.URL.Host).WithField("out.req.ID", reqID)
+ newCtx := util.ContextWithLogger(ctx, logger)
logger.Infof("Outgoing request %s %s", req.Method, req.URL)
- resp, err := fc.client.Do(req.WithContext(ctx))
+ resp, err := fc.client.Do(req.WithContext(newCtx))
if err != nil {
logger.Infof("Outgoing request %s %s failed with %v", req.Method, req.URL, err)
return nil, err

MODIFY
vendor/src/github.com/matrix-org/gomatrixserverlib/federationclient.go
vendor/src/github.com/matrix-org/gomatrixserverlib/federationclient.go
@@ -36,6 +36,7 @@ func NewFederationClient(
func (ac *FederationClient) doRequest(ctx context.Context, r FederationRequest, resBody interface{}) error {
reqID := util.RandomString(12)
logger := util.GetLogger(ctx).WithField("server", r.fields.Destination).WithField("out.req.ID", reqID)
+ newCtx := util.ContextWithLogger(ctx, logger)
if err := r.Sign(ac.serverName, ac.serverKeyID, ac.serverPrivateKey); err != nil {
return err
@@ -47,7 +48,7 @@ func (ac *FederationClient) doRequest(ctx context.Context, r FederationRequest,
}
logger.Infof("Outgoing request %s %s", req.Method, req.URL)
- res, err := ac.client.Do(req.WithContext(ctx))
+ res, err := ac.client.Do(req.WithContext(newCtx))
if res != nil {
defer res.Body.Close() // nolint: errcheck
}

MODIFY
vendor/src/github.com/matrix-org/util/context.go
vendor/src/github.com/matrix-org/util/context.go
@@ -35,3 +35,8 @@ func GetLogger(ctx context.Context) *log.Entry {
}
return l.(*log.Entry)
}
+
+// ContextWithLogger creates a new context, which will use the given logger.
+func ContextWithLogger(ctx context.Context, l *log.Entry) context.Context {
+ return context.WithValue(ctx, ctxValueLogger, l)
+}

MODIFY
vendor/src/github.com/matrix-org/util/json.go
vendor/src/github.com/matrix-org/util/json.go
@@ -99,7 +99,7 @@ func Protect(handler http.HandlerFunc) http.HandlerFunc {
func RequestWithLogging(req *http.Request) *http.Request {
reqID := RandomString(12)
// Set a Logger and request ID on the context
- ctx := context.WithValue(req.Context(), ctxValueLogger, log.WithFields(log.Fields{
+ ctx := ContextWithLogger(req.Context(), log.WithFields(log.Fields{
"req.method": req.Method,
"req.path": req.URL.Path,
"req.id": reqID,

gb vendor updates

gb vendor update github.com/matrix-org/gomatrixserverlib
gb vendor update github.com/matrix-org/util