aboutsummaryrefslogtreecommitdiff
path: root/hotline/client_conn.go
diff options
context:
space:
mode:
authorJeff Halter <868228+jhalter@users.noreply.github.com>2022-06-20 20:14:32 -0700
committerJeff Halter <868228+jhalter@users.noreply.github.com>2022-06-20 20:14:32 -0700
commit7cd900d61edbd6d322db3cecb913adf574389320 (patch)
tree7da8ac3658fa4b6204330f1f9c980428b6a6fdc5 /hotline/client_conn.go
parentbb1e98842e35b3affaf94971e78c86f8b9547928 (diff)
Add initial support for resource and info forks
Diffstat (limited to 'hotline/client_conn.go')
-rw-r--r--hotline/client_conn.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/hotline/client_conn.go b/hotline/client_conn.go
index c1ae4e3..a8ace87 100644
--- a/hotline/client_conn.go
+++ b/hotline/client_conn.go
@@ -5,6 +5,7 @@ import (
"golang.org/x/crypto/bcrypt"
"io"
"math/big"
+ "sort"
)
type byClientID []*ClientConn
@@ -164,9 +165,9 @@ func (cc *ClientConn) Authorize(access int) bool {
return true
}
- accessBitmap := big.NewInt(int64(binary.BigEndian.Uint64(*cc.Account.Access)))
+ i := big.NewInt(int64(binary.BigEndian.Uint64(*cc.Account.Access)))
- return accessBitmap.Bit(63-access) == 1
+ return i.Bit(63-access) == 1
}
// Disconnect notifies other clients that a client has disconnected
@@ -222,3 +223,13 @@ func (cc *ClientConn) NewErrReply(t *Transaction, errMsg string) Transaction {
},
}
}
+
+// sortedClients is a utility function that takes a map of *ClientConn and returns a sorted slice of the values.
+// The purpose of this is to ensure that the ordering of client connections is deterministic so that test assertions work.
+func sortedClients(unsortedClients map[uint16]*ClientConn) (clients []*ClientConn) {
+ for _, c := range unsortedClients {
+ clients = append(clients, c)
+ }
+ sort.Sort(byClientID(clients))
+ return clients
+}