parent
2998e1d039
commit
8c04a9ac96
|
@ -411,16 +411,17 @@ func (s *Server) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||||
var conns []*Connection
|
var conns []*Connection
|
||||||
ctx := req.Context()
|
ctx := req.Context()
|
||||||
|
|
||||||
|
f := ln.F{
|
||||||
|
"remote": req.RemoteAddr,
|
||||||
|
"host": req.Host,
|
||||||
|
"uri": req.RequestURI,
|
||||||
|
}
|
||||||
|
|
||||||
val, ok := s.domains.Get(req.Host)
|
val, ok := s.domains.Get(req.Host)
|
||||||
if ok {
|
if ok {
|
||||||
conns, ok = val.([]*Connection)
|
conns, ok = val.([]*Connection)
|
||||||
if !ok {
|
if !ok {
|
||||||
ln.Error(ctx, ErrNoSuchBackend, ln.F{
|
ln.Error(ctx, ErrNoSuchBackend, f, ln.Action("no backend available"))
|
||||||
"action": "no_backend_connected",
|
|
||||||
"remote": req.RemoteAddr,
|
|
||||||
"host": req.Host,
|
|
||||||
"uri": req.RequestURI,
|
|
||||||
})
|
|
||||||
|
|
||||||
return gen502Page(req), nil
|
return gen502Page(req), nil
|
||||||
}
|
}
|
||||||
|
@ -434,12 +435,7 @@ func (s *Server) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(goodConns) == 0 {
|
if len(goodConns) == 0 {
|
||||||
ln.Error(ctx, ErrNoSuchBackend, ln.F{
|
ln.Error(ctx, ErrNoSuchBackend, f, ln.Action("no good backends available"))
|
||||||
"action": "no_backend_connected",
|
|
||||||
"remote": req.RemoteAddr,
|
|
||||||
"host": req.Host,
|
|
||||||
"uri": req.RequestURI,
|
|
||||||
})
|
|
||||||
|
|
||||||
return gen502Page(req), nil
|
return gen502Page(req), nil
|
||||||
}
|
}
|
||||||
|
@ -448,19 +444,13 @@ func (s *Server) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||||
|
|
||||||
resp, err := c.RoundTrip(req)
|
resp, err := c.RoundTrip(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ln.Error(ctx, err, c, ln.F{
|
ln.Error(ctx, err, c, f, ln.Action("connection roundtrip"))
|
||||||
"action": "connection_roundtrip",
|
|
||||||
})
|
|
||||||
|
|
||||||
defer c.cancel()
|
defer c.cancel()
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ln.Log(ctx, c, ln.F{
|
ln.Log(ctx, c, ln.Action("http traffic"), f, ln.F{
|
||||||
"action": "http traffic",
|
|
||||||
"remote_addr": req.RemoteAddr,
|
|
||||||
"host": req.Host,
|
|
||||||
"uri": req.URL.Path,
|
|
||||||
"status": resp.Status,
|
"status": resp.Status,
|
||||||
"status_code": resp.StatusCode,
|
"status_code": resp.StatusCode,
|
||||||
"content_length": resp.ContentLength,
|
"content_length": resp.ContentLength,
|
||||||
|
@ -474,5 +464,3 @@ type Auth struct {
|
||||||
Token string `json:"token"`
|
Token string `json:"token"`
|
||||||
Domain string `json:"domain"`
|
Domain string `json:"domain"`
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultUser = "Cadey"
|
|
||||||
|
|
Loading…
Reference in New Issue