Fix splitting for IPv6 RemoteAddrs
This commit is contained in:
parent
4d906cf095
commit
dfc31495b7
2 changed files with 7 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue