aboutsummaryrefslogtreecommitdiff
path: root/hotline/server.go
diff options
context:
space:
mode:
authorJeff Halter <868228+jhalter@users.noreply.github.com>2022-07-03 19:11:29 -0700
committerJeff Halter <868228+jhalter@users.noreply.github.com>2022-07-03 19:11:29 -0700
commitc1c44744fdbd3ddeec509efffba91011a4d49990 (patch)
treeecb4ebf0f0e33c56bc83bfd67c2143bf52a45924 /hotline/server.go
parent69af8ddbdff8e6d0dd551e9bdc72284469a86fc0 (diff)
Implement handing for "Refuse Private Chat" preference
Diffstat (limited to 'hotline/server.go')
-rw-r--r--hotline/server.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/hotline/server.go b/hotline/server.go
index 852b772..06a0695 100644
--- a/hotline/server.go
+++ b/hotline/server.go
@@ -48,10 +48,13 @@ type Server struct {
Clients map[uint16]*ClientConn
fileTransfers map[[4]byte]*FileTransfer
- Config *Config
- ConfigDir string
- Logger *zap.SugaredLogger
- PrivateChats map[uint32]*PrivateChat
+ Config *Config
+ ConfigDir string
+ Logger *zap.SugaredLogger
+
+ PrivateChatsMu sync.Mutex
+ PrivateChats map[uint32]*PrivateChat
+
NextGuestID *uint16
TrackerPassID [4]byte
Stats *Stats
@@ -698,15 +701,14 @@ func (s *Server) handleNewConnection(ctx context.Context, rwc io.ReadWriteCloser
}
func (s *Server) NewPrivateChat(cc *ClientConn) []byte {
- s.mux.Lock()
- defer s.mux.Unlock()
+ s.PrivateChatsMu.Lock()
+ defer s.PrivateChatsMu.Unlock()
randID := make([]byte, 4)
rand.Read(randID)
data := binary.BigEndian.Uint32(randID[:])
s.PrivateChats[data] = &PrivateChat{
- Subject: "",
ClientConn: make(map[uint16]*ClientConn),
}
s.PrivateChats[data].ClientConn[cc.uint16ID()] = cc