Skip to content
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

feat: Add version as a top level field #532

Merged
merged 27 commits into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions protocols/armagetron.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ export default class armagetron extends Core {
state.raw.versionmin = this.readUInt(reader)
state.raw.versionmax = this.readUInt(reader)
state.raw.version = this.readString(reader)
state.version = state.raw.version
podrivo marked this conversation as resolved.
Show resolved Hide resolved
state.maxplayers = this.readUInt(reader)

delete state.raw.version

const players = this.readString(reader)
const list = players.split('\n')
for (const name of list) {
Expand Down
5 changes: 5 additions & 0 deletions protocols/asa.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ export default class asa extends Epic {
this.clientSecret = 'PP5UGxysEieNfSrEicaD1N2Bb3TdXuD7xHYcsdUHZ7s'
this.deploymentId = 'ad9a8feffb3b4b2ca315546f038c3ae2'
}

async run(state) {
await super.run(state)
state.version = state.raw.attributes.BUILDID_s + '.' + state.raw.attributes.MINORBUILDID_s
}
}
3 changes: 3 additions & 0 deletions protocols/ase.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ export default class ase extends Core {
state.raw.gametype = this.readString(reader)
state.map = this.readString(reader)
state.raw.version = this.readString(reader)
state.version = state.raw.version
podrivo marked this conversation as resolved.
Show resolved Hide resolved
state.password = this.readString(reader) === '1'
state.numplayers = parseInt(this.readString(reader))
state.maxplayers = parseInt(this.readString(reader))

delete state.raw.version

while (!reader.done()) {
const key = this.readString(reader)
if (!key) break
Expand Down
1 change: 1 addition & 0 deletions protocols/assettocorsa.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default class assettocorsa extends Core {
state.gamePort = serverInfo.port
state.raw.carInfo = carInfo.Cars
state.raw.serverInfo = serverInfo
state.version = state.raw.serverInfo.poweredBy
podrivo marked this conversation as resolved.
Show resolved Hide resolved

for (const car of carInfo.Cars) {
if (car.IsConnected) {
Expand Down
3 changes: 3 additions & 0 deletions protocols/battlefield.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ export default class battlefield extends Core {
const data = await this.query(socket, ['version'])
data.shift()
state.raw.version = data.shift()
state.version = state.raw.version

delete state.raw.version
}

{
Expand Down
1 change: 1 addition & 0 deletions protocols/doom3.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default class doom3 extends Core {
let reader = this.reader(body)
const protoVersion = reader.uint(4)
state.raw.protocolVersion = (protoVersion >> 16) + '.' + (protoVersion & 0xffff)
state.version = state.raw.protocolVersion

// some doom implementations send us a packet size here, some don't (etqw does this)
// we can tell if this is a packet size, because the third and fourth byte will be 0 (no packets are that massive)
Expand Down
1 change: 1 addition & 0 deletions protocols/eco.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ export default class eco extends Core {
state.gamePort = serverInfo.GamePort
state.players = serverInfo.OnlinePlayersNames?.map(name => ({ name, raw: {} })) || []
state.raw = serverInfo
state.version = state.raw.Version
}
}
1 change: 1 addition & 0 deletions protocols/factorio.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ export default class factorio extends Core {
state.players = players.map(player => ({ name: player, raw: {} }))

state.raw = serverInfo
state.version = state.raw.application_version.game_version + '.' + state.raw.application_version.build_version
}
}
3 changes: 3 additions & 0 deletions protocols/farmingsimulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ export default class farmingsimulator extends Core {
})

state.raw.version = serverInfo.attr('version')
state.version = state.raw.version

delete state.raw.version

// TODO: Add state.raw
}
Expand Down
3 changes: 3 additions & 0 deletions protocols/ffow.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default class ffow extends valve {
state.raw.gamemode = reader.string()
state.raw.description = reader.string()
state.raw.version = reader.string()
state.version = state.raw.version
state.gamePort = reader.uint(2)
state.numplayers = reader.uint(1)
state.maxplayers = reader.uint(1)
Expand All @@ -34,5 +35,7 @@ export default class ffow extends valve {
state.raw.round = reader.uint(1)
state.raw.maxrounds = reader.uint(1)
state.raw.timeleft = reader.uint(2)

delete state.raw.version
}
}
1 change: 1 addition & 0 deletions protocols/gamespy1.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export default class gamespy1 extends Core {
}

state.numplayers = state.players.length
state.version = state.raw.gamever
}

async sendPacket (type) {
Expand Down
1 change: 1 addition & 0 deletions protocols/gamespy3.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export default class gamespy3 extends Core {
if (state.raw.password === '1') state.password = true
if ('maxplayers' in state.raw) state.maxplayers = parseInt(state.raw.maxplayers)
if ('hostport' in state.raw) state.gamePort = parseInt(state.raw.hostport)
if ('gamever' in state.raw) state.version = state.raw.gamever

if ('' in state.raw.playerTeamInfo) {
for (const playerInfo of state.raw.playerTeamInfo['']) {
Expand Down
3 changes: 3 additions & 0 deletions protocols/geneshift.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@ export default class geneshift extends Core {
state.raw.mercs = !!parseInt(found[17])
// fields[18] is unknown? listen server?
state.raw.version = found[19]
state.version = state.raw.version

delete state.raw.version
}
}
1 change: 1 addition & 0 deletions protocols/mafia2mp.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default class mafia2mp extends Core {
state.numplayers = parseInt(this.readString(reader))
state.maxplayers = parseInt(this.readString(reader))
state.raw.gamemode = this.readString(reader)
state.version = state.raw.gamemode
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
Apparently this is a customizable field, but I've seen that it really is a version on some servers, so I guess it's fine, noting this just for future references.

state.password = !!reader.uint(1)
state.gamePort = this.options.port - 1

Expand Down
2 changes: 2 additions & 0 deletions protocols/minecraft.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export default class minecraft extends Core {
if (vanillaState.maxplayers) state.maxplayers = vanillaState.maxplayers
if (vanillaState.players.length) state.players = vanillaState.players
if (vanillaState.ping) this.registerRtt(vanillaState.ping)
if (vanillaState.raw.version) state.version = vanillaState.raw.version.name
}
if (gamespyState) {
if (gamespyState.name) state.name = gamespyState.name
Expand All @@ -93,6 +94,7 @@ export default class minecraft extends Core {
if (bedrockState.maxplayers) state.maxplayers = bedrockState.maxplayers
if (bedrockState.map) state.map = bedrockState.map
if (bedrockState.ping) this.registerRtt(bedrockState.ping)
if (bedrockState.raw.mcVersion) state.version = bedrockState.raw.mcVersion
}
// remove dupe spaces from name
state.name = state.name.replace(/\s+/g, ' ')
Expand Down
1 change: 1 addition & 0 deletions protocols/mumbleping.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default class mumbleping extends Core {
state.raw.versionMajor = reader.uint(1)
state.raw.versionMinor = reader.uint(1)
state.raw.versionPatch = reader.uint(1)
state.version = state.raw.versionMajor + '.' + state.raw.versionMinor + '.' + state.raw.versionPatch
podrivo marked this conversation as resolved.
Show resolved Hide resolved
reader.skip(8)
state.numplayers = reader.uint(4)
state.maxplayers = reader.uint(4)
Expand Down
3 changes: 3 additions & 0 deletions protocols/openttd.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export default class openttd extends Core {

state.name = reader.string()
state.raw.version = reader.string()
state.version = state.raw.version

delete state.raw.version

state.raw.language = this.decode(
reader.uint(1),
Expand Down
1 change: 1 addition & 0 deletions protocols/palworld.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ export default class palworld extends Epic {
await super.run(state)
state.name = state.raw.attributes.NAME_s
state.numplayers = state.raw.attributes.PLAYERS_l
state.version = state.raw.attributes.VERSION_S
}
}
3 changes: 3 additions & 0 deletions protocols/rfactor.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default class rfactor extends Core {
state.raw.ip = reader.part(4)
state.raw.size = reader.uint(2)
state.raw.version = reader.uint(2)
state.version = state.raw.version
state.raw.versionRaceCast = reader.uint(2)
state.gamePort = reader.uint(2)
state.raw.queryPort = reader.uint(2)
Expand All @@ -36,6 +37,8 @@ export default class rfactor extends Core {
reader.skip(3)
state.raw.vehicles = reader.string()

delete state.raw.version

state.password = !!(state.raw.packedSpecial & 2)
state.raw.raceCast = !!(state.raw.packedSpecial & 4)
state.raw.fixedSetups = !!(state.raw.packedSpecial & 16)
Expand Down
3 changes: 3 additions & 0 deletions protocols/samp.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export default class samp extends Core {
if (this.isVcmp) {
const consumed = reader.part(12)
state.raw.version = this.reader(consumed).string()
state.version = state.raw.version

delete state.raw.version
podrivo marked this conversation as resolved.
Show resolved Hide resolved
}
state.password = !!reader.uint(1)
state.numplayers = reader.uint(2)
Expand Down
3 changes: 3 additions & 0 deletions protocols/savage2.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ export default class savage2 extends Core {
state.raw.minplayers = reader.uint(1)
state.raw.gametype = reader.string()
state.raw.version = reader.string()
state.version = state.raw.version
state.raw.minlevel = reader.uint(1)

delete state.raw.version
}

stripColorCodes (str) {
Expand Down
7 changes: 6 additions & 1 deletion protocols/starmade.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ export default class starmade extends Core {
this.logger.debug('Received raw data array', data)

if (typeof data[0] === 'number') state.raw.infoVersion = data[0]
if (typeof data[1] === 'number') state.raw.version = data[1]
if (typeof data[1] === 'number') {
state.raw.version = data[1]
state.version = state.raw.version

delete state.raw.version
}
if (typeof data[2] === 'string') state.name = data[2]
if (typeof data[3] === 'string') state.raw.description = data[3]
if (typeof data[4] === 'number') state.raw.startTime = data[4]
Expand Down
1 change: 1 addition & 0 deletions protocols/teamspeak3.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default class teamspeak3 extends Core {
if ('virtualserver_name' in state.raw) state.name = state.raw.virtualserver_name
if ('virtualserver_maxclients' in state.raw) state.maxplayers = state.raw.virtualserver_maxclients
if ('virtualserver_clientsonline' in state.raw) state.numplayers = state.raw.virtualserver_clientsonline
if ('virtualserver_version' in state.raw) state.version = state.raw.virtualserver_version
}

{
Expand Down
1 change: 1 addition & 0 deletions protocols/theisleevrima.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ export default class theisleevrima extends Epic {
await super.run(state)
state.name = state.raw.attributes.SERVERNAME_s
state.map = state.raw.attributes.MAP_NAME_s
state.version = state.raw.attributes.SERVER_VERSION_s
}
}
3 changes: 3 additions & 0 deletions protocols/tribes1.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ export default class tribes1 extends Core {
state.raw.gametype = this.readString(reader)
const isStarsiege2009 = state.raw.gametype === 'Starsiege'
state.raw.version = this.readString(reader)
state.version = state.raw.version
state.name = this.readString(reader)

delete state.raw.version

if (isStarsiege2009) {
state.password = !!reader.uint(1)
state.raw.dedicated = !!reader.uint(1)
Expand Down
4 changes: 4 additions & 0 deletions protocols/valve.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ export default class valve extends Core {
state.raw.shipduration = reader.uint(1)
}
state.raw.version = reader.string()
state.version = state.raw.version

delete state.raw.version

const extraFlag = reader.uint(1)
if (extraFlag & 0x80) state.gamePort = reader.uint(2)
if (extraFlag & 0x10) state.raw.steamid = reader.uint(8).toString()
Expand Down
Loading