diff --git a/README.md b/README.md index e68a2cf..a97da2e 100644 --- a/README.md +++ b/README.md @@ -34,9 +34,9 @@ Configuration is done in a JSON formatted file specified with the `-config` flag #### Drivers -Chihaya is designed to remain agnostic about the choice of data storage. Out of the box, we provide only the necessary drivers to run Chihaya in public mode ("memory" for tracker and "noop" for backend). If you're interested in creating a new driver, check out the section on [customizing chihaya]. +Chihaya is designed to remain agnostic about the choice of data storage. Out of the box, we provide only the necessary drivers to run Chihaya in public mode ("memory" for tracker and "noop" for backend). If you're interested in creating a new driver, check out the section on [customizing Chihaya]. -[customizing chihaya]: https://github.com/chihaya/chihaya#customizing-chihaya +[customizing Chihaya]: #customizing-chihaya ## Developing Chihaya diff --git a/http/tracker.go b/http/tracker.go index 6c571c1..5de8cfd 100644 --- a/http/tracker.go +++ b/http/tracker.go @@ -9,7 +9,6 @@ import ( "net" "net/http" "strconv" - "strings" "github.com/julienschmidt/httprouter" @@ -156,8 +155,11 @@ func requestedIP(q *query.Query, r *http.Request, cfg *config.NetConfig) (v4, v6 return } - if idx := strings.LastIndex(r.RemoteAddr, ":"); idx != -1 { - if v4, v6, done = getIPs(r.RemoteAddr[0:idx], v4, v6, cfg); done { + var host string + host, _, err = net.SplitHostPort(r.RemoteAddr) + + if err != nil && host != "" { + if v4, v6, done = getIPs(host, v4, v6, cfg); done { return } }