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:
Asim Aslam
2020-01-14 13:23:16 +00:00
committed by GitHub
parent b699d969e4
commit 1d311ab457
10 changed files with 308 additions and 41 deletions

View File

@@ -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