From 8a74a0a622c739d4bd25f80a07d1fe7bd759f6c8 Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Tue, 8 Sep 2015 14:09:24 +0300 Subject: [PATCH] fixes for matching alias --- engine/aliases.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/engine/aliases.go b/engine/aliases.go index 587dd85ce..28ef8db6e 100644 --- a/engine/aliases.go +++ b/engine/aliases.go @@ -265,9 +265,6 @@ func (am *AliasHandler) GetReverseAlias(attr AttrReverseAlias, result *map[strin func (am *AliasHandler) GetMatchingAlias(attr AttrMatchingAlias, result *string) error { response := Alias{} - if attr.Destination == "" { - attr.Destination = utils.ANY - } if err := aliasService.GetAlias(Alias{ Direction: attr.Direction, Tenant: attr.Tenant, @@ -280,8 +277,15 @@ func (am *AliasHandler) GetMatchingAlias(attr AttrMatchingAlias, result *string) } // sort according to weight values := response.Values.GetWeightSlice() + if attr.Destination == "" || attr.Destination == utils.ANY { + for _, aliasHandler := range values { + for alias := range aliasHandler { + *result = alias + return nil + } + } + } // check destination ids - for _, p := range utils.SplitPrefix(attr.Destination, MIN_PREFIX_MATCH) { if x, err := cache2go.Get(utils.DESTINATION_PREFIX + p); err == nil { for _, aliasHandler := range values {