Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ _This is an early WIP with a few hours gone in to both the extension and the gam
| Show File Push Notifications | `bitburner.showPushSuccessNotification` | If true, this will show a notification/toast when a file has been successfully pushed to the game. Errors will always show. | `false` |
| Show File Watcher Enabled Notifications | `bitburner.showFileWatcherEnabledNotification` | If true, this will show a notification/toast whenever the File Watcher is enabled and/or the extension configuration scriptRoot has changed. Errors will always show. | `false` |
| Game Authentication Token | `bitburner.authToken` | The auth token that the game generates, needed for you to be able to push files in to your game client. See [#authentication](#authentication) section below. | (No Default) |
| Game remote host | `bitburner.hostname` | Specify the host name of the game. | `localhost` |
| Game remote port | `bitburner.port` | Specify the port of the game. | `9990` |

## Pushing Files

Expand All @@ -40,6 +42,10 @@ The token will ultimately end up in the workspace configuration (See your worksp
- Use the command palette (CTRL/CMD + SHIFT + P) and select `Bitburner: Add Auth Token`.
- Paste the Auth Token copied via the games context menu in to the input box.

#### Allow remote connections:

By default, the game listens only on *localhost*. To allow connections from remote host or from a WSL container, you have to edit the `config.json` file and define the `host` parameter to `0.0.0.0`.

### Push through the context menu

- Right Click in the VSCode Editor (Your source code) and choose 'Bitburner: Push file to game'
Expand Down
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@
"bitburner.authToken": {
"type": "string",
"description": "Token generated by the game client to allow file pushes."
},
"bitburner.hostname": {
"type": "string",
"default": "localhost",
"description": "The hostname of the game client."
},
"bitburner.port": {
"type": "number",
"default": "9990",
"description": "The port of the game client."
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions src/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ let fwEnabled;

// TODO: Refactor this user config to combined 'extension/user config' with better internal API/structure
/**
* @type {{ scriptRoot: string, fwEnabled: boolean, showPushSuccessNotification: boolean, showFileWatcherEnabledNotification: boolean, authToken: string }}
* @type {{ scriptRoot: string, fwEnabled: boolean, showPushSuccessNotification: boolean, showFileWatcherEnabledNotification: boolean, authToken: string, hostname: string, port: number }}
*/
let sanitizedUserConfig;

Expand Down Expand Up @@ -271,8 +271,8 @@ const doPostRequestToBBGame = (payload) => {

const stringPayload = JSON.stringify(cleanPayload);
const options = {
hostname: BB_GAME_CONFIG.url,
port: BB_GAME_CONFIG.port,
hostname: sanitizedUserConfig.hostname,
port: sanitizedUserConfig.port,
path: BB_GAME_CONFIG.filePostURI,
method: `POST`,
headers: {
Expand Down Expand Up @@ -333,6 +333,8 @@ const sanitizeUserConfig = () => {
.get(`authToken`)
.replace(/^bearer/i, ``)
.trim(),
hostname: userConfig.get(`hostname`),
port: userConfig.get(`port`),
};
};

Expand All @@ -353,7 +355,7 @@ const showToast = (message, toastType = `information`, opts = { forceShow: false
if (!Object.keys(ToastTypes).includes(toastType)) {
return;
}
if (!sanitizedUserConfig.showPushSuccessNotification && !opts.forceShow && toastType !== `error`) {
if ((!sanitizedUserConfig || !sanitizedUserConfig.showPushSuccessNotification) && !opts.forceShow && toastType !== `error`) {
return;
}

Expand Down