aboutsummaryrefslogtreecommitdiff
path: root/hotline/server.go
diff options
context:
space:
mode:
authorJeff Halter <868228+jhalter@users.noreply.github.com>2023-01-21 11:37:55 -0800
committerJeff Halter <868228+jhalter@users.noreply.github.com>2023-01-21 11:37:55 -0800
commit2f8472fa4149074981f30b5bd181851768eab637 (patch)
treee3a998183f09da9825a32a6bc5e29c026bdfc960 /hotline/server.go
parentb4d84cd8dc5e3d3bdbe84072bf5129ea2bcc3e49 (diff)
Fix regression in 1.5 login behavior
Diffstat (limited to 'hotline/server.go')
-rw-r--r--hotline/server.go35
1 files changed, 21 insertions, 14 deletions
diff --git a/hotline/server.go b/hotline/server.go
index b17102e..3e4ba2f 100644
--- a/hotline/server.go
+++ b/hotline/server.go
@@ -664,21 +664,28 @@ func (s *Server) handleNewConnection(ctx context.Context, rwc io.ReadWriteCloser
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
- // TODO: figure out a generalized solution that doesn't require playing whack-a-mole for specific client versions
- 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 }()))
+ // If the client has provided a username as part of the login, we can infer that it is using the 1.2.3 login
+ // flow and not the 1.5+ flow.
+ if len(c.UserName) != 0 {
+ // Add the client username to the logger. For 1.5+ clients, we don't have this information yet as it comes as
+ // part of tranAgreed
+ c.logger = c.logger.With("name", string(c.UserName))
- for _, t := range c.notifyOthers(
- *NewTransaction(
- tranNotifyChangeUser, nil,
- NewField(fieldUserName, c.UserName),
- NewField(fieldUserID, *c.ID),
- NewField(fieldUserIconID, c.Icon),
- NewField(fieldUserFlags, c.Flags),
- ),
- ) {
- c.Server.outbox <- t
+ c.logger.Infow("Login successful", "clientVersion", "Not sent (probably 1.2.3)")
+
+ // Notify other clients on the server that the new user has logged in. For 1.5+ clients we don't have this
+ // information yet, so we do it in tranAgreed instead
+ for _, t := range c.notifyOthers(
+ *NewTransaction(
+ tranNotifyChangeUser, nil,
+ NewField(fieldUserName, c.UserName),
+ NewField(fieldUserID, *c.ID),
+ NewField(fieldUserIconID, c.Icon),
+ NewField(fieldUserFlags, c.Flags),
+ ),
+ ) {
+ c.Server.outbox <- t
+ }
}
c.Server.Stats.ConnectionCounter += 1