Back out field name changes
This commit is contained in:
parent
76e6d3872e
commit
ded5fa6f20
|
@ -3,7 +3,6 @@ package wfe
|
|||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/jmhodges/clock"
|
||||
|
@ -12,16 +11,16 @@ import (
|
|||
)
|
||||
|
||||
type requestEvent struct {
|
||||
ID string `json:",omitempty"`
|
||||
ClientAddr string `json:",omitempty"`
|
||||
Path string `json:",omitempty"`
|
||||
Method string `json:",omitempty"`
|
||||
Status int `json:",omitEmpty"`
|
||||
RequestTime time.Time `json:",omitempty"`
|
||||
ResponseTime time.Time `json:",omitempty"`
|
||||
Errors []string
|
||||
RegistrationID int64 `json:",omitempty"`
|
||||
Contacts []*core.AcmeURL `json:",omitempty"`
|
||||
ID string `json:",omitempty"`
|
||||
RealIP string `json:",omitempty"`
|
||||
ClientAddr string `json:",omitempty"`
|
||||
Endpoint string `json:",omitempty"`
|
||||
Method string `json:",omitempty"`
|
||||
RequestTime time.Time `json:",omitempty"`
|
||||
ResponseTime time.Time `json:",omitempty"`
|
||||
Errors []string
|
||||
Requester int64 `json:",omitempty"`
|
||||
Contacts []*core.AcmeURL `json:",omitempty"`
|
||||
|
||||
Extra map[string]interface{} `json:",omitempty"`
|
||||
}
|
||||
|
@ -49,13 +48,14 @@ type topHandler struct {
|
|||
func (th *topHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
logEvent := &requestEvent{
|
||||
ID: core.NewToken(),
|
||||
RealIP: r.Header.Get("X-Real-IP"),
|
||||
ClientAddr: getClientAddr(r),
|
||||
Method: r.Method,
|
||||
RequestTime: time.Now(),
|
||||
Extra: make(map[string]interface{}, 0),
|
||||
}
|
||||
if r.URL != nil {
|
||||
logEvent.Path = r.URL.String()
|
||||
logEvent.Endpoint = r.URL.String()
|
||||
}
|
||||
defer th.logEvent(logEvent)
|
||||
|
||||
|
@ -73,14 +73,13 @@ func (th *topHandler) logEvent(logEvent *requestEvent) {
|
|||
th.log.InfoObject(msg, logEvent)
|
||||
}
|
||||
|
||||
// Comma-separated list of HTTP clients involved in making this request,
|
||||
// including the remote end of our TCP connection (which is typically our own
|
||||
// proxy) as well as addresses from the X-Forwarded-For and X-Real-IP headers.
|
||||
// Comma-separated list of HTTP clients involved in making this
|
||||
// request, starting with the original requestor and ending with the
|
||||
// remote end of our TCP connection (which is typically our own
|
||||
// proxy).
|
||||
func getClientAddr(r *http.Request) string {
|
||||
addrs := []string{
|
||||
r.RemoteAddr,
|
||||
r.Header.Get("X-Forwarded-For"),
|
||||
r.Header.Get("X-Real-IP"),
|
||||
if xff := r.Header.Get("X-Forwarded-For"); xff != "" {
|
||||
return xff + "," + r.RemoteAddr
|
||||
}
|
||||
return strings.Join(addrs, ",")
|
||||
return r.RemoteAddr
|
||||
}
|
||||
|
|
|
@ -417,7 +417,7 @@ func (wfe *WebFrontEndImpl) verifyPOST(logEvent *requestEvent, request *http.Req
|
|||
} else {
|
||||
// If the lookup was successful, use that key.
|
||||
key = ®.Key
|
||||
logEvent.RegistrationID = reg.ID
|
||||
logEvent.Requester = reg.ID
|
||||
logEvent.Contacts = reg.Contact
|
||||
}
|
||||
|
||||
|
@ -498,7 +498,6 @@ func (wfe *WebFrontEndImpl) sendError(response http.ResponseWriter, logEvent *re
|
|||
}
|
||||
|
||||
// Record details to the log event
|
||||
logEvent.Status = code
|
||||
logEvent.AddError(msg)
|
||||
|
||||
// Only audit log internal errors so users cannot purposefully cause
|
||||
|
@ -579,7 +578,7 @@ func (wfe *WebFrontEndImpl) NewRegistration(logEvent *requestEvent, response htt
|
|||
wfe.sendError(response, logEvent, "Error creating new registration", err, statusCodeFromError(err))
|
||||
return
|
||||
}
|
||||
logEvent.RegistrationID = reg.ID
|
||||
logEvent.Requester = reg.ID
|
||||
logEvent.Contacts = reg.Contact
|
||||
|
||||
// Use an explicitly typed variable. Otherwise `go vet' incorrectly complains
|
||||
|
|
|
@ -179,10 +179,6 @@ func (pa *MockPA) WillingToIssue(id core.AcmeIdentifier, regID int64) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func newRequestEvent() *requestEvent {
|
||||
return &requestEvent{Extra: make(map[string]interface{})}
|
||||
}
|
||||
|
||||
func makeBody(s string) io.ReadCloser {
|
||||
return ioutil.NopCloser(strings.NewReader(s))
|
||||
}
|
||||
|
@ -1284,10 +1280,11 @@ func TestGetCertificate(t *testing.T) {
|
|||
test.AssertEquals(t, responseWriter.Header().Get("Content-Type"), "application/pkix-cert")
|
||||
test.Assert(t, bytes.Compare(responseWriter.Body.Bytes(), certBlock.Bytes) == 0, "Certificates don't match")
|
||||
|
||||
t.Logf("UGH %#v", mockLog.GetAll()[0])
|
||||
reqlogs := mockLog.GetAllMatching(`Successful request`)
|
||||
test.AssertEquals(t, len(reqlogs), 1)
|
||||
test.AssertEquals(t, reqlogs[0].Priority, syslog.LOG_INFO)
|
||||
test.AssertContains(t, reqlogs[0].Message, `"ClientAddr":"192.168.0.1,,"`)
|
||||
test.AssertContains(t, reqlogs[0].Message, `"ClientAddr":"192.168.0.1"`)
|
||||
|
||||
// Unused serial, no cache
|
||||
mockLog.Clear()
|
||||
|
@ -1303,7 +1300,7 @@ func TestGetCertificate(t *testing.T) {
|
|||
reqlogs = mockLog.GetAllMatching(`Terminated request`)
|
||||
test.AssertEquals(t, len(reqlogs), 1)
|
||||
test.AssertEquals(t, reqlogs[0].Priority, syslog.LOG_INFO)
|
||||
test.AssertContains(t, reqlogs[0].Message, `"ClientAddr":"192.168.0.1,192.168.99.99,"`)
|
||||
test.AssertContains(t, reqlogs[0].Message, `"ClientAddr":"192.168.99.99,192.168.0.1"`)
|
||||
|
||||
// Invalid serial, no cache
|
||||
responseWriter = httptest.NewRecorder()
|
||||
|
@ -1430,3 +1427,7 @@ func TestStatusCodeFromError(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func newRequestEvent() *requestEvent {
|
||||
return &requestEvent{Extra: make(map[string]interface{})}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue