]> git.r.bdr.sh - rbdr/mobius/blobdiff - hotline/server.go
Improve compatability of threaded news post and delete
[rbdr/mobius] / hotline / server.go
index bd15a2ecea697b8ed88a2e34c29e870b6866e034..d87ddb99ea121fd499695ad44c10ba6ab6ae74b1 100644 (file)
@@ -36,6 +36,10 @@ type requestCtx struct {
 var nostalgiaVersion = []byte{0, 0, 2, 0x2c} // version ID used by the Nostalgia client
 var frogblastVersion = []byte{0, 0, 0, 0xb9} // version ID used by the Frogblast 1.2.4 client
 
 var nostalgiaVersion = []byte{0, 0, 2, 0x2c} // version ID used by the Nostalgia client
 var frogblastVersion = []byte{0, 0, 0, 0xb9} // version ID used by the Frogblast 1.2.4 client
 
+var heildrun = []byte{0, 0x97}
+
+var obsessionVersion = []byte{0xbe, 0x00} // version ID used by the Obsession client
+
 type Server struct {
        Port          int
        Accounts      map[string]*Account
 type Server struct {
        Port          int
        Accounts      map[string]*Account
@@ -153,18 +157,18 @@ func (s *Server) sendTransaction(t Transaction) error {
 
        s.mux.Lock()
        client := s.Clients[uint16(clientID)]
 
        s.mux.Lock()
        client := s.Clients[uint16(clientID)]
+       s.mux.Unlock()
        if client == nil {
                return fmt.Errorf("invalid client id %v", *t.clientID)
        }
 
        if client == nil {
                return fmt.Errorf("invalid client id %v", *t.clientID)
        }
 
-       s.mux.Unlock()
-
        b, err := t.MarshalBinary()
        if err != nil {
                return err
        }
 
        b, err := t.MarshalBinary()
        if err != nil {
                return err
        }
 
-       if _, err := client.Connection.Write(b); err != nil {
+       _, err = client.Connection.Write(b)
+       if err != nil {
                return err
        }
 
                return err
        }
 
@@ -673,7 +677,8 @@ func (s *Server) handleNewConnection(ctx context.Context, rwc io.ReadWriteCloser
        }
 
        // Used simplified hotline v1.2.3 login flow for clients that do not send login info in tranAgreed
        }
 
        // Used simplified hotline v1.2.3 login flow for clients that do not send login info in tranAgreed
-       if c.Version == nil || bytes.Equal(c.Version, nostalgiaVersion) || bytes.Equal(c.Version, frogblastVersion) {
+       // TODO: figure out a generalized solution that doesn't require playing whack-a-mole for specific client versions
+       if c.Version == nil || bytes.Equal(c.Version, nostalgiaVersion) || bytes.Equal(c.Version, frogblastVersion) || bytes.Equal(c.Version, obsessionVersion) || bytes.Equal(c.Version, heildrun) {
                c.Agreed = true
                c.logger = c.logger.With("name", string(c.UserName))
                c.logger.Infow("Login successful", "clientVersion", fmt.Sprintf("%v", func() int { i, _ := byteToInt(c.Version); return i }()))
                c.Agreed = true
                c.logger = c.logger.With("name", string(c.UserName))
                c.logger.Infow("Login successful", "clientVersion", fmt.Sprintf("%v", func() int { i, _ := byteToInt(c.Version); return i }()))