summaryrefslogtreecommitdiffstats
path: root/server.go
diff options
context:
space:
mode:
Diffstat (limited to 'server.go')
-rw-r--r--server.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/server.go b/server.go
index 3576475..24b1e77 100644
--- a/server.go
+++ b/server.go
@@ -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
}
}
}