Skip to content

Instantly share code, notes, and snippets.

@jheise
Last active June 4, 2022 15:53
Show Gist options
  • Save jheise/c1dcdc0a5adf8442d205000b302851f3 to your computer and use it in GitHub Desktop.
Save jheise/c1dcdc0a5adf8442d205000b302851f3 to your computer and use it in GitHub Desktop.
collecting useful intelligence from an http request in golang
type Record struct {
RemoteAddr string `json:"remoteaddr"`
Method string `json:"method"`
RequestURI string `json:"requesturi"`
Headers http.Header `json:"headers"`
UserAgent string `json:"UserAgent"`
PostForm url.Values `json:"postform"`
EventTime uint64 `json:"eventtime"`
HoneypotName string `json:"honeypotname"`
}
func GenerateRecord(r *http.Request) Record{
data := Record{}
data.RemoteAddr = r.RemoteAddr
data.Method = r.Method
data.RequestURI = r.RequestURI
data.Headers = r.Header
data.UserAgent = r.UserAgent()
r.ParseForm()
data.PostForm = r.PostForm
data.EventTime = uint64(time.Now().Unix())
return data
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment