-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Satisfactory support (#645)
* feat: Added Satisfactory Protocol and Support * fix: Reordering Alphabetically * Further Updates based on Feedback * Removed Duplicate Code * Adding rejectUnauthorized option for Satisfactory * Move rejectUnauthorized back to Protocol * Adding Doc Notes for Satisfactory * Made Docs Clearer
- Loading branch information
Showing
5 changed files
with
103 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import Core from './core.js' | ||
|
||
export default class satisfactory extends Core { | ||
constructor () { | ||
super() | ||
|
||
// Don't use the tcp ping probing | ||
this.usedTcp = true | ||
|
||
} | ||
|
||
async run (state) { | ||
|
||
/** | ||
* 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' | ||
} | ||
|
||
let headers = { | ||
'Content-Type': 'application/json' | ||
} | ||
|
||
/** | ||
* Satisfactory servers unless specified use self-signed certificates for the HTTPS API. | ||
* Because of this we default the `rejectUnauthorized` flag to `false` unless set. | ||
* For more information see GAMES_LIST.md | ||
*/ | ||
if (!this.options.rejectUnauthorized) this.options.rejectUnauthorized = false | ||
|
||
let tokenRequestResponse = await this.queryInfo(tokenRequestJson, headers) | ||
|
||
headers.Authorization = `Bearer ${tokenRequestResponse.data.authenticationToken}` | ||
|
||
let queryResponse = await this.queryInfo(queryJson, headers) | ||
|
||
/** | ||
* Satisfactory API cannot pull Server Name at the moment, see QA and vote for fix here | ||
* https://questions.satisfactorygame.com/post/66ebebad772a987f4a8b9ef8 | ||
*/ | ||
|
||
state.numplayers = queryResponse.data.serverGameState.numConnectedPlayers | ||
state.maxplayers = queryResponse.data.serverGameState.playerLimit | ||
state.raw = queryResponse | ||
|
||
} | ||
|
||
async queryInfo (json, headers) { | ||
|
||
const url = `https://${this.options.host}:${this.options.port}/api/v1/` | ||
|
||
this.logger.debug(`POST: ${url}`) | ||
|
||
const response = await this.request({ | ||
url, | ||
json, | ||
headers, | ||
method: 'POST', | ||
responseType: 'json', | ||
https: { | ||
minVersion: 'TLSv1.2', | ||
rejectUnauthorized: this.options.rejectUnauthorized | ||
} | ||
}) | ||
|
||
if (response.data == null) { | ||
throw new Error('Unable to retrieve data from server') | ||
} else { | ||
return response | ||
} | ||
} | ||
} |