diff --git a/PROTOCOL.md b/PROTOCOL.md index 2fad172..bb02a98 100644 --- a/PROTOCOL.md +++ b/PROTOCOL.md @@ -22,11 +22,11 @@ Clients must send a register command, reset command or login command before send - Register an account. A valid email address must be provided. - Usernames must contain at least one non-numeric character. -- `registerjson ` +- `registerjson ` - Register an account and enable JSON formatted responses. - All client applications should use the `registerjson` command to register, as JSON formatted responses are more easily parsed by computers. - - The name of the client must be specified. + - The client field is specified as follows: `example-client-v1.2.3/en` - Aliases: `rj` - `resetpassword ` @@ -37,11 +37,11 @@ formatted responses are more easily parsed by computers. - Log in. A random username is assigned when none is provided. - Usernames must contain at least one non-numeric character. -- `loginjson [username] [password]` +- `loginjson [username] [password]` - Log in and enable JSON formatted responses. - All client applications should use the `loginjson` command to log in, as JSON formatted responses are more easily parsed by computers. - - The name of the client must be specified. + - The client field is specified as follows: `example-client-v1.2.3/en` - Aliases: `lj` - `password ` diff --git a/pkg/server/client.go b/pkg/server/client.go index 74f1e07..b49408b 100644 --- a/pkg/server/client.go +++ b/pkg/server/client.go @@ -347,18 +347,32 @@ func logClientRead(msg []byte) { } func legacyClient(clientName []byte) bool { + // Strip language. + slash := bytes.IndexByte(clientName, '/') + if slash != -1 { + clientName = clientName[:slash] + } + + // Split by hyphens. split := bytes.Split(clientName, []byte("-")) if len(split) == 0 { return true - } else if !bytes.Equal(split[0], []byte("boxcars")) { + } + + // Only Boxcars requires legacy support. + if !bytes.Equal(split[0], []byte("boxcars")) { return false } + + // Parse version information. last := split[len(split)-1] lastSplit := bytes.Split(last, []byte(".")) if len(lastSplit) != 3 { return true } major, minor := parseInt(lastSplit[0]), parseInt(lastSplit[1]) + + // Boxcars releases before v1.4.0 require legacy support. return major < 1 || (major == 1 && minor < 4) }