mirror of
https://github.com/sot-tech/mochi.git
synced 2026-06-12 07:43:32 -07:00
Fix splitting for IPv6 RemoteAddrs
This commit is contained in:
@@ -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
|
||||
|
||||
+5
-3
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user