···152 NodeID int `toml:"node-id"`
153 // Whether audit reports should be stored whenever an audit event occurs.
154 Collect bool `toml:"collect"`
155- // Whether audit reports should include principal's IP address.
156- IncludeIPs bool `toml:"include-ip"`
000157 // Endpoint to notify with a `GET /<notify-url>?<id>` whenever an audit event occurs.
158 NotifyURL *URL `toml:"notify-url"`
159}
···152 NodeID int `toml:"node-id"`
153 // Whether audit reports should be stored whenever an audit event occurs.
154 Collect bool `toml:"collect"`
155+ // If not empty, includes the principal's IP address in audit reports, with the value specifying
156+ // the source of the IP address. If the value is "X-Forwarded-For", the last item of the
157+ // corresponding header field (assumed to be comma-separated) is used. If the value is
158+ // "RemoteAddr", the connecting host's address is used. Any other value is disallowed.
159+ IncludeIPs string `toml:"include-ip"`
160 // Endpoint to notify with a `GET /<notify-url>?<id>` whenever an audit event occurs.
161 NotifyURL *URL `toml:"notify-url"`
162}
···9 "fmt"
10 "io"
11 "maps"
12- "net"
13 "net/http"
14 "net/url"
15 "os"
···802803func ServePages(w http.ResponseWriter, r *http.Request) {
804 r = r.WithContext(WithPrincipal(r.Context()))
805- if config.Audit.IncludeIPs {
806- if ipAddress, _, err := net.SplitHostPort(r.RemoteAddr); err == nil {
807- GetPrincipal(r.Context()).IpAddress = proto.String(ipAddress)
808- }
809 }
810 // We want upstream health checks to be done as closely to the normal flow as possible;
811 // any intentional deviation is an opportunity to miss an issue that will affect our
···9 "fmt"
10 "io"
11 "maps"
012 "net/http"
13 "net/url"
14 "os"
···801802func ServePages(w http.ResponseWriter, r *http.Request) {
803 r = r.WithContext(WithPrincipal(r.Context()))
804+ if config.Audit.IncludeIPs != "" {
805+ GetPrincipal(r.Context()).IpAddress = proto.String(r.RemoteAddr)
00806 }
807 // We want upstream health checks to be done as closely to the normal flow as possible;
808 // any intentional deviation is an opportunity to miss an issue that will affect our