From 8eb43f95a6f11b6c256ff339399e9479898b4380 Mon Sep 17 00:00:00 2001 From: Jeff Halter <868228+jhalter@users.noreply.github.com> Date: Tue, 28 Jun 2022 21:49:48 -0700 Subject: Implement access controls for threaded news item deletion --- hotline/server.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'hotline/server.go') diff --git a/hotline/server.go b/hotline/server.go index ab61e81..392c8f3 100644 --- a/hotline/server.go +++ b/hotline/server.go @@ -43,12 +43,10 @@ const ( var nostalgiaVersion = []byte{0, 0, 2, 0x2c} // version ID used by the Nostalgia client type Server struct { - Port int - Accounts map[string]*Account - Agreement []byte - Clients map[uint16]*ClientConn - ThreadedNews *ThreadedNews - + Port int + Accounts map[string]*Account + Agreement []byte + Clients map[uint16]*ClientConn fileTransfers map[[4]byte]*FileTransfer Config *Config @@ -64,6 +62,9 @@ type Server struct { outbox chan Transaction mux sync.Mutex + threadedNewsMux sync.Mutex + ThreadedNews *ThreadedNews + flatNewsMux sync.Mutex FlatNews []byte @@ -342,14 +343,14 @@ func (s *Server) writeBanList() error { } func (s *Server) writeThreadedNews() error { - s.mux.Lock() - defer s.mux.Unlock() + s.threadedNewsMux.Lock() + defer s.threadedNewsMux.Unlock() out, err := yaml.Marshal(s.ThreadedNews) if err != nil { return err } - err = ioutil.WriteFile( + err = s.FS.WriteFile( filepath.Join(s.ConfigDir, "ThreadedNews.yaml"), out, 0666, -- cgit