diff --git a/CHANGELOG.md b/CHANGELOG.md
index fded028..43d7d0b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,7 +3,7 @@
## 5.X.Y
* Feat: Replaced `punycode` package usage with `url.domainToASCII` (#630).
* 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: TOXIKK (2016) - Added support (#641)
* Feat: Renegade X (2014) - Added support (#643)
diff --git a/GAMES_LIST.md b/GAMES_LIST.md
index 549aa56..7e87dc2 100644
--- a/GAMES_LIST.md
+++ b/GAMES_LIST.md
@@ -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.
### 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).
+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.
+
### Soldat
Requires `Allow_Download` and `Logging` to be `1` in the server config.
diff --git a/bin/gamedig.js b/bin/gamedig.js
index 20ea44b..aa2d319 100644
--- a/bin/gamedig.js
+++ b/bin/gamedig.js
@@ -6,7 +6,7 @@ import Minimist from 'minimist'
import { GameDig } from './../lib/index.js'
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'],
default: {
stripColors: true,
diff --git a/protocols/satisfactory.js b/protocols/satisfactory.js
index 905a45c..793fde2 100644
--- a/protocols/satisfactory.js
+++ b/protocols/satisfactory.js
@@ -28,22 +28,15 @@ export default class satisfactory extends Core {
const nameLength = response.int(2)
state.name = response.part(nameLength).toString('utf-8')
- /**
- * To get information about the Satisfactory game server, you need to first obtain a client authenticationToken.
- * https://satisfactory.wiki.gg/wiki/Dedicated_servers/HTTPS_API
- */
-
- const tokenRequestJson = {
- function: 'PasswordlessLogin',
- data: {
- MinimumPrivilegeLevel: 'Client'
- }
- }
-
- const queryJson = {
- function: 'QueryServerState'
+ try {
+ await this.doHttpApiQueries(state)
+ } catch (e) {
+ this.logger.debug('HTTP API query failed.')
+ this.logger.debug(e)
}
+ }
+ async doHttpApiQueries (state) {
const headers = {
'Content-Type': 'application/json'
}
@@ -55,11 +48,26 @@ export default class satisfactory extends Core {
*/
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,
- Authorization: `Bearer ${tokenRequestResponse.data.authenticationToken}`
+ Authorization: `Bearer ${token}`
})
/**
@@ -92,7 +100,7 @@ export default class satisfactory extends Core {
if (response.data == null) {
throw new Error('Unable to retrieve data from server')
} else {
- return response
+ return response.data
}
}
}