func extraneousAddresses(cfg *conf.Config) []string { added := cfg.SourceAddresses() addedMap := make(map[string]bool) for _, ip := range added { addedMap[ip] = true } cur := currentAddresses() var extra []string for _, ip := range cur { if addedMap[ip] && !keepAddressRe.MatchString(ip) { extra = append(extra, ip) } } debugf("extraneous interface addresses: %v", extra) return extra }
func missingAddresses(cfg *conf.Config) []string { current := currentAddresses() wanted := cfg.SourceAddresses() curMap := make(map[string]bool) for _, ip := range current { curMap[ip] = true } var missing []string for _, ip := range wanted { if !curMap[ip] { missing = append(missing, ip) } } debugf("missing local addresses: %v", missing) return missing }