gateway: Reject endpoint pointing to local gateway (#4310)

Show an error when the user enters an endpoint url pointing
to the gateway server itself.
This commit is contained in:
Anis Elleuch
2017-05-17 06:13:29 +02:00
committed by Harshavardhana
parent 59b3e0b79b
commit 542f7ae42c
4 changed files with 212 additions and 11 deletions

View File

@@ -127,14 +127,10 @@ func NewEndpoint(arg string) (Endpoint, error) {
return Endpoint{}, fmt.Errorf("empty or root path is not supported in URL endpoint")
}
// Get IPv4 address of the host.
hostIPs, err := getHostIP4(host)
isLocal, err = isLocalHost(host)
if err != nil {
return Endpoint{}, err
}
// If intersection of two IP sets is not empty, then the host is local host.
isLocal = !localIP4.Intersection(hostIPs).IsEmpty()
} else {
u = &url.URL{Path: path.Clean(arg)}
isLocal = true