diff options
Diffstat (limited to '')
-rw-r--r-- | server.go | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -376,14 +376,20 @@ func sendPacket(conn net.Conn, packet *ber.Packet) error { // func routeFunc(dn string, funcNames []string) string { bestPick := "" + bestPickWeight := 0 + dnMatch := "," + strings.ToLower(dn) + var weight int for _, fn := range funcNames { - if strings.HasSuffix(dn, fn) { - l := len(strings.Split(bestPick, ",")) - if bestPick == "" { - l = 0 + if strings.HasSuffix(dnMatch, "," + fn) { + // empty string as 0, no-comma string 1 , etc + if fn == "" { + weight = 0 + } else { + weight = strings.Count(fn, ",") + 1 } - if len(strings.Split(fn, ",")) > l { + if weight > bestPickWeight { bestPick = fn + bestPickWeight = weight } } } |