Embedded NATS Broker (#1110)
* if the address is produced by a default route don't hash it * embedded nats * fix url parsing * don't override help * add ready flag
This commit is contained in:
@@ -27,6 +27,29 @@ func isPrivateIP(ipAddr string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsLocal tells us whether an ip is local
|
||||
func IsLocal(addr string) bool {
|
||||
// extract the host
|
||||
host, _, err := net.SplitHostPort(addr)
|
||||
if err == nil {
|
||||
addr = host
|
||||
}
|
||||
|
||||
// check if its localhost
|
||||
if addr == "localhost" {
|
||||
return true
|
||||
}
|
||||
|
||||
// check against all local ips
|
||||
for _, ip := range IPs() {
|
||||
if addr == ip {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// Extract returns a real ip
|
||||
func Extract(addr string) (string, error) {
|
||||
// if addr specified then its returned
|
||||
|
Reference in New Issue
Block a user