-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve migration to eosIDs #354
Improve migration to eosIDs #354
Conversation
Since last update all data necessary to identify a player comes in 2 logs within the same chain, so many previous loggers are deprecated. `JOIN_SUCCEEDED` is now used as an emit trigger because this is where we obtain the last piece of data for the log - `playerSuffix`.
As an added side effect, methods like `server.getAdminPermsBySteamID()` will only return data for admins that are currently in-game (because to map anyID onto eosID it needs player's data which is not persistent and is available only when a player is online).
Plugins that were not updated: 1. db-log SteamID is basically it's backbone. Migrading to EOS would require obtaining all steam -> EOS pairs, migrating databasesm etc. Maybe we could make a db-logV2 with new data and migration assisting tools so that anyone willing to migrate can do it in an assisted mode. 2. awn-api Not something that I use or know, left as is. 3. cbl-info Again, steamID seems to be it's backbone, I don't want to mess with a project that has maintainers that know ins and outs way better than me. Plugins that were partially updated: 1. discord-killfeed CBL integration is left untouched, other things are updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good overall, but some changes are required in my opinion.
squad-server/index.js
Outdated
@@ -353,16 +336,26 @@ export default class SquadServer extends EventEmitter { | |||
await this.logParser.watch(); | |||
} | |||
|
|||
// DEPRECATED FUNCTION |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be replaced with a more suitable jsdoc
/**
* @deprecated <optional message here>
*/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally don't like the approach of having a "unified" regex to match the IDs because it depends only on the hope of OWI not breaking things with typos or non-standard formats, which has already happened, an example is a log line which has Contoller
instead of Controller
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All suggestions are implemented apart from one: changing getAdminsWithPermission(perm)
to return players instead of IDs is not yet implemented. I'm all for implementing it, just want to make sure it is greenlit. Or, as a compromise, we could extend it to getAdminsWithPermission(perm, returnPlayers=false)
, that would allow for the new feature without potentially breaking custom plugins.
As for unified regex, I kindly disagree. master
implementation is prone to: changing ordering, extra spacing, lack of steamID (some regexes in master
were fixed to have steam as an optional but not all), renaming a key. This implementation will break only if delimiters are broken. Swapping, cloning, removing arbitrary k:v pairs, introducing new IDs, surrounding colons with spaces won't break it. Renaming a key will break things down the line but not the parser itself. And when OWI eventually breaks some output again - we can patch that specific item within it's parser, while everything else follows the same logic and is easy to remember.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm good with the new changes after my first review, and with keeping your implementation of the ID parser since you proved to have went through an analysis of all the side effects of both your implementation and the one currently on the master
branch.
squad-server/index.js
Outdated
@@ -218,7 +218,7 @@ export default class SquadServer extends EventEmitter { | |||
data.player = await this.getPlayerByEOSID(data.eosID); | |||
if (data.player) data.player.suffix = data.playerSuffix; | |||
|
|||
delete data.steamID; | |||
for (const k in data) if (k.endsWith('ID')) delete data[k]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be more specific:
for (const k in data) if (["steamID", "eosID"].includes(k)) delete data[k];
squad-server/index.js
Outdated
@@ -227,7 +227,7 @@ export default class SquadServer extends EventEmitter { | |||
this.logParser.on('PLAYER_DISCONNECTED', async (data) => { | |||
data.player = await this.getPlayerByEOSID(data.eosID); | |||
|
|||
delete data.steamID; | |||
for (const k in data) if (k.endsWith('ID')) delete data[k]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be more specific:
for (const k in data) if (["steamID", "eosID"].includes(k)) delete data[k];
squad-server/index.js
Outdated
} | ||
return ret; | ||
return anyIDsToPlayers(ret, this.players).map(player => player.eosID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
considering that this is a breaking change, and it also limits the functionality from getting ALL the admins to ONLY THE ONLINE admins, I would prefer this to be converted to returning an array of objects with both eosID and steamID optional parameters.
this should be further discussed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed on Discord with @Ulibos, the best choice appears to be a method that accepts an extra parameter to tune the output based on the needs.
A jsdoc would be a good fit for defining all the possible values for the extra parameter that I will just refer to as "output format parameter".
The output format parameter could be defined with the following jsdoc: @param {'steamID'|'eosID'|'any'|'player'}
and will return the output formatted as showed in the following example:
- steamID: The output stays the same as the current implementation. Example:
[ '01234567891234567', '01234567891234567' ]
- eosID: Example:
[ 'a1b2c3d4e5f6a7b8c9d1e2f3a4b5c6d7e8f9', 'a1b2c3d4e5f6a7b8c9d1e2f3a4b5c6d7e8f9' ]
- any: The eosID should be the preferred ID but include a fallback to steamID in case of missing eosID. Example
[ 'a1b2c3d4e5f6a7b8c9d1e2f3a4b5c6d7e8f9', '01234567891234567' ]
- player:
[ { name: 'example_name', eosID: 'a1b2c3d4e5f6a7b8c9d1e2f3a4b5c6d7e8f9', steamID: '01234567891234567', ... }, { name: 'example_name', eosID: 'a1b2c3d4e5f6a7b8c9d1e2f3a4b5c6d7e8f9', steamID: null|undefined, ... } ]
squad-server/index.js
Outdated
@@ -591,6 +585,7 @@ export default class SquadServer extends EventEmitter { | |||
); | |||
} | |||
|
|||
// DEPRECATED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be replaced with a more suitable jsdoc
/**
* @deprecated <optional message here>
*/
core/id-parser.js
Outdated
|
||
// main function intended for parsing `Online IDs:` body. Returns an | ||
// iterator that yields `{platform: id}` pairs. | ||
export const iterate = (idsStr) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be renamed to a more descriptive name such as iterateIDs
Additionally, the "Fix/" prefix is not appropriate in my opinion, and I would change it to "refactor!: " (see https://www.conventionalcommits.org/en/v1.0.0/) |
Flags added as needed. Let me know when good to push. |
Renamed main function, rewrote ID iterations, fixed a bug in `anyIDsToPlayers()` (wasn't eliminating duplicats in returned list), minor comments cleanup.
Status update here: #354 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm good with the new changes after my first review, and with keeping your implementation of the ID parser since you proved to have went through an analysis of all the side effects of both your implementation and the one currently on the master
branch.
1. `getAdminsWithPermission` now supports both legacy and new call conventions. 2. any-id.js is also refactored a bit (added `isPlayerID` function). 3. Minor JSDoc fixes.
New changes look good overall. The error handling of the new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsers will skip lines with `INVALID` Online IDs.
Summary
This PR completes migration to eosIDs for the tool (except for a couple plugins, more on that below).
Dependencies
This PR depends on #352 and lays foundation for #347
Changes
There are 5 commits:
oldPlayerInfo
on player list updates (was annoying me a bit during testing).* - caveats
Testing
All of this was tested several times with event capture to make sure data is consistent. In summary (but not in 1 last go) I have tested:
connecting, disconnecting, possess, unpossess, create squad, kill (self inflicted), warn, force swap, kick, ban.
Only thing I didn't test for sure is a teamkill. I also am not aware if I had at least 1 run where I didn't have a steamID, most likely not. But so far generalized parsers work correctly, I haven't seen any errors in logs or missing data. I have also tested:
getAdminPermsByAnyID()
,getAdminsWithPermission()
(both were tested forserver.admins
with steamID or eosID),getPlayerByAnyID()
for both types of IDs, rcon methods (warn()
,switchTeam()
,kick()
,ban()
).Caveats
Testing Plugins
I didn't test plugins. We don't use any default ones and we don't have the necessary setup, plus the ones I've edited have mostly trivial fixes. The one I've fixed only partially is discord-killfeed, I didn't touch it's CBL integration. The ones I didn't touch at all are: db-log, awn-api, cbl-info. Some of these are completely unknown to me, some are too dependent on steamID to fix them in this PR. For now they will work as they were before as long as players have steamIDs.
Admins IDs
For now, there is a potential issue with an admin having 2 sets of permissions, one for eosID and another for steamID. Current code won't be able to merge it (at the time of merging it doesn't have persistent mapping of player's IDs). Easily avoidable though by not intermixing two ID formats.
Another side-effect is that
getAdminsWithPermission()
will always return only those admins that have the permission AND are online (for at least 10 seconds). This happens because this method matches all existing IDs against all existing admin entries to convert them all to eosIDs.