mirror of https://github.com/dirtbags/moth.git
Extract and use X-Forwarded-For headers in mothd logging
This commit is contained in:
parent
222ca1c760
commit
cf72f8f253
|
@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Include basic metadata in mothballs
|
- Include basic metadata in mothballs
|
||||||
- add_script_stream convenience function allows easy script addition to puzzle
|
- add_script_stream convenience function allows easy script addition to puzzle
|
||||||
- Autobuild Docker images to test buildability
|
- Autobuild Docker images to test buildability
|
||||||
|
- Extract and use X-Forwarded-For headers in mothd logging
|
||||||
### Fixed
|
### Fixed
|
||||||
- Handle cases where non-legacy puzzles don't have an `author` attribute
|
- Handle cases where non-legacy puzzles don't have an `author` attribute
|
||||||
- Handle YAML-formatted file and script lists as expected
|
- Handle YAML-formatted file and script lists as expected
|
||||||
|
|
|
@ -339,10 +339,18 @@ func (ctx *Instance) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) {
|
||||||
w: wOrig,
|
w: wOrig,
|
||||||
statusCode: new(int),
|
statusCode: new(int),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clientIP := r.Header.Get("X-Forwarded-For")
|
||||||
|
clientIP = strings.Split(clientIP, ", ")[0]
|
||||||
|
|
||||||
|
if clientIP == "" {
|
||||||
|
clientIP = r.RemoteAddr
|
||||||
|
}
|
||||||
|
|
||||||
ctx.mux.ServeHTTP(w, r)
|
ctx.mux.ServeHTTP(w, r)
|
||||||
log.Printf(
|
log.Printf(
|
||||||
"%s %s %s %d\n",
|
"%s %s %s %d\n",
|
||||||
r.RemoteAddr,
|
clientIP,
|
||||||
r.Method,
|
r.Method,
|
||||||
r.URL,
|
r.URL,
|
||||||
*w.statusCode,
|
*w.statusCode,
|
||||||
|
|
Loading…
Reference in New Issue