Added IP and Browser string to submit routines
This commit is contained in:
parent
fefd6dbdce
commit
4d3a84b6b3
@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"html/template"
|
||||
"net/http"
|
||||
"net"
|
||||
"qurl/qurl"
|
||||
"qurl/static"
|
||||
"qurl/storage"
|
||||
@ -53,6 +54,12 @@ func (ctx *SubmitHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
URL: u,
|
||||
Created: time.Now(),
|
||||
}
|
||||
if h, _, err := net.SplitHostPort(r.RemoteAddr); err == nil && h != "" {
|
||||
q.IP = net.ParseIP(h)
|
||||
}
|
||||
if b := r.Header.Get("User-Agent"); b != "" {
|
||||
q.Browser = b
|
||||
}
|
||||
|
||||
err := q.CheckValid()
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user