]> git.r.bdr.sh - rbdr/mobius/blobdiff - hotline/server.go
Fix "No Agreement" behavior for 1.2.3 clients
[rbdr/mobius] / hotline / server.go
index 41b9a97967021de4b97e3b709f90d9055bec45b9..0d66e08f1290f3adc4a54caa81b696474be8c39a 100644 (file)
@@ -653,8 +653,17 @@ func (s *Server) handleNewConnection(ctx context.Context, rwc io.ReadWriteCloser
        // Send user access privs so client UI knows how to behave
        c.Server.outbox <- *NewTransaction(tranUserAccess, c.ID, NewField(fieldUserAccess, *c.Account.Access))
 
-       // Show agreement to client
-       c.Server.outbox <- *NewTransaction(tranShowAgreement, c.ID, NewField(fieldData, s.Agreement))
+       // Accounts with accessNoAgreement do not receive the server agreement on login.  The behavior is different between
+       // client versions.  For 1.2.3 client, we do not send tranShowAgreement.  For other client versions, we send
+       // tranShowAgreement but with the NoServerAgreement field set to 1.
+       if c.Authorize(accessNoAgreement) {
+               // If client version is nil, then the client uses the 1.2.3 login behavior
+               if c.Version != nil {
+                       c.Server.outbox <- *NewTransaction(tranShowAgreement, c.ID, NewField(fieldNoServerAgreement, []byte{1}))
+               }
+       } else {
+               c.Server.outbox <- *NewTransaction(tranShowAgreement, c.ID, NewField(fieldData, s.Agreement))
+       }
 
        // 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) {