mirror of
https://github.com/tribufu/node-gamedig
synced 2026-05-06 07:07:33 +00:00
feat(games/satisfactory): pass optional token, make http query not required (#653)
* feat: let the user provide a token to skip PasswordlessLogin * feat: make querying the HTTP api not required * docs: add to changelog, note query priority * fix: passing rejectUnauthorized as arg made it string, ignoring its value
This commit is contained in:
parent
5b1da1ad71
commit
f5899fd54d
4 changed files with 33 additions and 21 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
## 5.X.Y
|
## 5.X.Y
|
||||||
* Feat: Replaced `punycode` package usage with `url.domainToASCII` (#630).
|
* Feat: Replaced `punycode` package usage with `url.domainToASCII` (#630).
|
||||||
* Feat: World of Padman (2007) - Added support (#636)
|
* Feat: World of Padman (2007) - Added support (#636)
|
||||||
* Feat: Satisfactory - Added support (By @Smidy13 #645, #652)
|
* Feat: Satisfactory - Added support (By @Smidy13 #645, #652, #653)
|
||||||
* Feat: Update Soldat protocol (#642)
|
* Feat: Update Soldat protocol (#642)
|
||||||
* Feat: TOXIKK (2016) - Added support (#641)
|
* Feat: TOXIKK (2016) - Added support (#641)
|
||||||
* Feat: Renegade X (2014) - Added support (#643)
|
* Feat: Renegade X (2014) - Added support (#643)
|
||||||
|
|
|
||||||
|
|
@ -521,8 +521,12 @@ Palworld support can be unstable, the devs mention the api is currently experime
|
||||||
To query Palworld servers, the `RESTAPIEnabled` setting must be `True` in the configuration file, and you need to pass the `username` (currently always `admin`) and the `adminpassword` (from the server config) as the `password` parameter.
|
To query Palworld servers, the `RESTAPIEnabled` setting must be `True` in the configuration file, and you need to pass the `username` (currently always `admin`) and the `adminpassword` (from the server config) as the `password` parameter.
|
||||||
|
|
||||||
### <a name="satisfactory"></a>Satisfactory
|
### <a name="satisfactory"></a>Satisfactory
|
||||||
Satisfactory servers unless specified use self-signed certificates for the HTTPS API. If you are using a self-signed certificate you will need to set the `rejectUnauthorized` flag in options to `false` in order to connect.
|
Satisfactory servers unless specified use self-signed certificates for the HTTPS API. If you are using proper-signed certificates you will need to set the `rejectUnauthorized` flag in options to `true` to ensure a secured query.
|
||||||
For more information on setting a user certificate refer to the [Satisfactory Dedicated server/HTTPS API wiki documentation](https://satisfactory.wiki.gg/wiki/Dedicated_servers/HTTPS_API).
|
For more information on setting a user certificate refer to the [Satisfactory Dedicated server/HTTPS API wiki documentation](https://satisfactory.wiki.gg/wiki/Dedicated_servers/HTTPS_API).
|
||||||
|
|
||||||
|
One can also provide an authentication token via the `token` option to skip the `PasswordlessLogin` query.
|
||||||
|
|
||||||
|
The query is done via the lightweight query option but also safely tries to utilize the HTTP one.
|
||||||
|
|
||||||
### <a name="soldat"></a>Soldat
|
### <a name="soldat"></a>Soldat
|
||||||
Requires `Allow_Download` and `Logging` to be `1` in the server config.
|
Requires `Allow_Download` and `Logging` to be `1` in the server config.
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import Minimist from 'minimist'
|
||||||
import { GameDig } from './../lib/index.js'
|
import { GameDig } from './../lib/index.js'
|
||||||
|
|
||||||
const argv = Minimist(process.argv.slice(2), {
|
const argv = Minimist(process.argv.slice(2), {
|
||||||
boolean: ['pretty', 'debug', 'givenPortOnly', 'requestRules', 'requestPlayers', 'requestRulesRequired', 'requestPlayersRequired', 'stripColors', 'portCache', 'noBreadthOrder', 'checkOldIDs'],
|
boolean: ['pretty', 'debug', 'givenPortOnly', 'requestRules', 'requestPlayers', 'requestRulesRequired', 'requestPlayersRequired', 'stripColors', 'portCache', 'noBreadthOrder', 'checkOldIDs', 'rejectUnauthorized'],
|
||||||
string: ['guildId', 'serverId', 'listenUdpPort', 'ipFamily', 'token'],
|
string: ['guildId', 'serverId', 'listenUdpPort', 'ipFamily', 'token'],
|
||||||
default: {
|
default: {
|
||||||
stripColors: true,
|
stripColors: true,
|
||||||
|
|
|
||||||
|
|
@ -28,22 +28,15 @@ export default class satisfactory extends Core {
|
||||||
const nameLength = response.int(2)
|
const nameLength = response.int(2)
|
||||||
state.name = response.part(nameLength).toString('utf-8')
|
state.name = response.part(nameLength).toString('utf-8')
|
||||||
|
|
||||||
/**
|
try {
|
||||||
* To get information about the Satisfactory game server, you need to first obtain a client authenticationToken.
|
await this.doHttpApiQueries(state)
|
||||||
* https://satisfactory.wiki.gg/wiki/Dedicated_servers/HTTPS_API
|
} catch (e) {
|
||||||
*/
|
this.logger.debug('HTTP API query failed.')
|
||||||
|
this.logger.debug(e)
|
||||||
const tokenRequestJson = {
|
|
||||||
function: 'PasswordlessLogin',
|
|
||||||
data: {
|
|
||||||
MinimumPrivilegeLevel: 'Client'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const queryJson = {
|
|
||||||
function: 'QueryServerState'
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async doHttpApiQueries (state) {
|
||||||
const headers = {
|
const headers = {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
|
|
@ -55,11 +48,26 @@ export default class satisfactory extends Core {
|
||||||
*/
|
*/
|
||||||
if (!this.options.rejectUnauthorized) this.options.rejectUnauthorized = false
|
if (!this.options.rejectUnauthorized) this.options.rejectUnauthorized = false
|
||||||
|
|
||||||
const tokenRequestResponse = await this.queryInfo(tokenRequestJson, headers)
|
let token = this.options.token
|
||||||
|
if (!token) {
|
||||||
|
const tokenRequestJson = {
|
||||||
|
function: 'PasswordlessLogin',
|
||||||
|
data: {
|
||||||
|
MinimumPrivilegeLevel: 'Client'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const { data: queryResponse } = await this.queryInfo(queryJson, {
|
const response = await this.queryInfo(tokenRequestJson, headers)
|
||||||
|
token = response.authenticationToken
|
||||||
|
}
|
||||||
|
|
||||||
|
const queryJson = {
|
||||||
|
function: 'QueryServerState'
|
||||||
|
}
|
||||||
|
|
||||||
|
const queryResponse = await this.queryInfo(queryJson, {
|
||||||
...headers,
|
...headers,
|
||||||
Authorization: `Bearer ${tokenRequestResponse.data.authenticationToken}`
|
Authorization: `Bearer ${token}`
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -92,7 +100,7 @@ export default class satisfactory extends Core {
|
||||||
if (response.data == null) {
|
if (response.data == null) {
|
||||||
throw new Error('Unable to retrieve data from server')
|
throw new Error('Unable to retrieve data from server')
|
||||||
} else {
|
} else {
|
||||||
return response
|
return response.data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue