diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2021-07-20 18:27:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-20 18:27:43 +0200 |
commit | 7f8d1e44eeba4156c0a258b6a1af47cb0a7e2d80 (patch) | |
tree | 16215733e543353c2bd5efd1dcf89c7879e2ad3d /server.go | |
parent | Fixed handling of UTF8 chars in filter value (#9) (diff) | |
download | ldap-7f8d1e44eeba4156c0a258b6a1af47cb0a7e2d80.tar ldap-7f8d1e44eeba4156c0a258b6a1af47cb0a7e2d80.tar.gz ldap-7f8d1e44eeba4156c0a258b6a1af47cb0a7e2d80.tar.bz2 ldap-7f8d1e44eeba4156c0a258b6a1af47cb0a7e2d80.tar.lz ldap-7f8d1e44eeba4156c0a258b6a1af47cb0a7e2d80.tar.xz ldap-7f8d1e44eeba4156c0a258b6a1af47cb0a7e2d80.tar.zst ldap-7f8d1e44eeba4156c0a258b6a1af47cb0a7e2d80.zip |
Diffstat (limited to 'server.go')
-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 } } } |