mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-12-24 01:00:18 +01:00
Be more careful with host IPs which call /update. They are potentially IPv6. Fixes Issue #16.
This commit is contained in:
parent
34fa4564f2
commit
58a44c2d40
@ -96,15 +96,16 @@ func (tu *tileUpdater) checkIP(r *http.Request) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
var host []string
|
||||
if host = strings.SplitN(r.RemoteAddr, ":", 2); len(host) < 1 {
|
||||
idx := strings.LastIndex(r.RemoteAddr, ":")
|
||||
if idx < 0 {
|
||||
log.Printf("WARN: cannot extract host from '%s'.\n", r.RemoteAddr)
|
||||
return false
|
||||
}
|
||||
|
||||
var ip net.IP
|
||||
if ip = net.ParseIP(host[0]); ip == nil {
|
||||
log.Printf("WARN: cannot get IP for host '%s'.\n", host[0])
|
||||
host := strings.Trim(r.RemoteAddr[:idx], "[]")
|
||||
ip := net.ParseIP(host)
|
||||
if ip == nil {
|
||||
log.Printf("WARN: cannot get IP for host '%s'.\n", host)
|
||||
return false
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user