Release 1.2

This commit is contained in:
omltcat 2024-05-11 23:22:53 -04:00
parent 07711a605a
commit 0685084a3c
6 changed files with 82 additions and 1096 deletions

View File

@ -2,8 +2,6 @@
All notable changes to the "dcs-lua-runner" extension will be documented in this file. All notable changes to the "dcs-lua-runner" extension will be documented in this file.
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
## [Unreleased] ## [Unreleased]
### Added ### Added
@ -96,3 +94,13 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
### Added ### Added
- Integrate a detailed setup guide into extension. - Integrate a detailed setup guide into extension.
- Automatically show setup guide on first activation. - Automatically show setup guide on first activation.
## [1.2.0] - 2024-05-11
### Added
- Option to configure remote GUI environment address and port separately from mission environment for better HTTPS reverse proxy support. (PLEASE USE A REVERSE PROXY ON REMOTE SERVER FOR SECURITY!)
### Changed
- Integrated Setup guide now includes instructions to help setting up a reverse proxy.
- Message displayed upon switching settings now includes protocol info (http/https).
- Move dcs-fiddle-server.lua script to an [external repository](https://github.com/omltcat/dcs-snippets/blob/master/Scripts/Hooks/dcs-fiddle-server.lua).

View File

@ -11,7 +11,7 @@ It is still compatible with the [DCS Fiddle website](https://dcsfiddle.pages.dev
- Don't hesitate to report any problems, provide segguestions or request features using [**Issues**](https://github.com/omltcat/dcs-lua-runner/issues). - Don't hesitate to report any problems, provide segguestions or request features using [**Issues**](https://github.com/omltcat/dcs-lua-runner/issues).
## Hook Script ## Hook Script
1. Download [**dcs-fiddle-server.lua**](https://github.com/omltcat/dcs-lua-runner/blob/master/src/hooks/dcs-fiddle-server.lua). 1. Download [**dcs-fiddle-server.lua**](https://github.com/omltcat/dcs-snippets/blob/master/Scripts/Hooks/dcs-fiddle-server.lua).
2. Save to `%USERPROFILE%\Saved Games\<DCS VERSION>\Scripts\Hooks`. 2. Save to `%USERPROFILE%\Saved Games\<DCS VERSION>\Scripts\Hooks`.
- Generally this means `C:\Users\<USERNAME>\Saved Games` - Generally this means `C:\Users\<USERNAME>\Saved Games`
- `<DCS VERSION>` could be `DCS`, `DCS.openbeta`, `DCS.release_server`, etc. - `<DCS VERSION>` could be `DCS`, `DCS.openbeta`, `DCS.release_server`, etc.
@ -43,23 +43,45 @@ end
### Script Configuration ### Script Configuration
If you want to run code on a remote DCS server, you need to expose the FIDDLE PORT to 0.0.0.0 by modifying the beginning of the `dcs-fiddle-server.lua` file. If you want to run code on a remote DCS server, you need to expose the FIDDLE PORT to 0.0.0.0 by modifying the beginning of the `dcs-fiddle-server.lua` file.
It is highly recommended that you also set up the basic authentication, otherwise anyone can inject lua code into your server. For best security, also put the FIDDLE PORT behind a reverse proxy with HTTPS.
It is highly recommended that you also set up the basic authentication, otherwise anyone can inject lua code into your server. For best security, also put the FIDDLE PORT behind a reverse proxy with HTTPS (see [below](#reverse-proxy)).
```lua ```lua
-- Configs:
FIDDLE.PORT = 12080 -- keep this at 12080 if you also want to use the DCS Fiddle website. FIDDLE.PORT = 12080 -- keep this at 12080 if you also want to use the DCS Fiddle website.
FIDDLE.BIND_IP = '0.0.0.0' -- for remote access FIDDLE.BIND_IP = '0.0.0.0' -- Use '0.0.0.0' for remote access, default is '127.0.0.1'
FIDDLE.AUTH = true -- set to true to enable basic auth, recommended for public servers. FIDDLE.AUTH = true -- set to true to enable basic auth, recommended for public servers.
FIDDLE.USERNAME = 'username' FIDDLE.USERNAME = 'username' -- set your username
FIDDLE.PASSWORD = 'password' FIDDLE.PASSWORD = 'password' -- set your password
FIDDLE.BYPASS_LOCAL = true -- allow requests to 127.0.0.1:12080 without auth. FIDDLE.BYPASS_LOCAL = true -- allow requests to 127.0.0.1:12080 without auth.
--- So DCS Fiddle website can still work. -- This local bypass allows DCS Fiddle website to still work.
--- (Not a very secure implementation. Use at your own risk if your 12080 port is public) -- It uses host header to determine if the request is local.
-- This is not the most secure method and can be spoofed, so use at your own risk.
-- Use a reverse proxy for best security.
```
#### VS Code Settings
Open command pallette (`Ctrl`+`Shift`+`P`) and type `DCS Lua: Open Runner Settings`.
You need to set:
- Server Address: IP of the DCS server
- Web Auth Username: same as `FIDDLE.USERNAME`
- Web Auth Password: same as `FIDDLE.PASSWORD`
### Reverse Proxy
The `dcs-fiddle-server.lua` script separates mission/GUI environment based on ports. By default the GUI env is automatically on the next port of mission env (12080-12081). When using a HTTPS reverse proxy, you can map the two ports to different subdomains, e.g.:
```
https://fiddle.example.com/ -> http://dcs-server-ip:12080/
https://fiddle-gui.example.com/ -> http://dcs-server-ip:12081/
``` ```
### VS Code Settings In VS Code - DCS Lua Runner Settings, set the following accordingly:
1. In VS Code, open command pallette (`Ctrl`+`Shift`+`P`) and type `DCS Lua: Open Runner Settings`. - Server Address: `fiddle.example.com`
2. Set server address, port, username, and password accordingly. - Server Address GUI: `fiddle-gui.example.com`
- Server Port: `443`
- Server Port GUI: `443`
- Use Https: `true`
- Web Auth Username: same as `FIDDLE.USERNAME`
- Web Auth Password: same as `FIDDLE.PASSWORD`
## Credits ## Credits
All credits of this scripts and its API implementations go to the original authors [JonathanTurnock](https://github.com/JonathanTurnock) and [john681611](https://github.com/john681611). All credits of this scripts and its API implementations go to the original authors [JonathanTurnock](https://github.com/JonathanTurnock) and [john681611](https://github.com/john681611).
Under MIT License, see [dcsfiddle](https://github.com/JonathanTurnock/dcsfiddle?tab=MIT-1-ov-file).

View File

@ -19,15 +19,19 @@ A VS Code extension to run lua code in DCS World (on local or remote server, in
## Installation ## Installation
See [**INSTALL.md**](INSTALL.md). See [**INSTALL.md**](INSTALL.md).
**YOU MUST SETUP THE DCS SCRIPT FOR THIS EXTENSION TO WORK.**
## Extension Settings ## Extension Settings
This extension has the following settings: This extension has the following settings:
- `serverAddress`: Remote DCS server address. It can be an IP address or a domain. - `serverAddress`: Remote DCS server address. It can be an IP address or a domain.
- `serverAddressGUI`: Override remote DCS server address for GUI environment.
- `serverPort`: Port of the remote DCS Fiddle. Default is `12080`. - `serverPort`: Port of the remote DCS Fiddle. Default is `12080`.
- `serverPortGUI`: Override port of the remote DCS Fiddle for GUI environment.
- `useHttps`: Specifies whether the server is behind a HTTPS reverse proxy. - `useHttps`: Specifies whether the server is behind a HTTPS reverse proxy.
If this is set to `true`, you should also change the `dcsLuaRunner.serverPort` to `443`. If this is set to `true`, you should also change the `dcsLuaRunner.serverPort` to `443`.
Default is `false`. Default is `false`.
@ -44,7 +48,6 @@ This setting can be quickly changed with the buttons on the upper-right of a lua
- `runInMissionEnv`: Specifies whether to execute in mission or GUI Scripting Environment. - `runInMissionEnv`: Specifies whether to execute in mission or GUI Scripting Environment.
This setting can be quickly changed with the buttons on the upper-right of a lua file. This setting can be quickly changed with the buttons on the upper-right of a lua file.
**NEW:**
- `returnDisplay`: Wether to use output panel or file (which supports syntax highlight) to display return value. - `returnDisplay`: Wether to use output panel or file (which supports syntax highlight) to display return value.
- `returnDisplayFormat`: Display return value as JSON or Lua table. (Experimental feature, please report any issue.) - `returnDisplayFormat`: Display return value as JSON or Lua table. (Experimental feature, please report any issue.)
@ -56,6 +59,7 @@ See [**changelog**](CHANGELOG.md).
## Credits ## Credits
All credits of this scripts and its API implementations go to the original authors [JonathanTurnock](https://github.com/JonathanTurnock) and [john681611](https://github.com/john681611). All credits of this scripts and its API implementations go to the original authors [JonathanTurnock](https://github.com/JonathanTurnock) and [john681611](https://github.com/john681611).
Under MIT License, see [dcsfiddle](https://github.com/JonathanTurnock/dcsfiddle?tab=MIT-1-ov-file).
## License ## License

View File

@ -4,7 +4,7 @@
"description": "Quickly run lua code in DCS World (local or remote server). A reimplementation of the DCS Fiddle lua console in VS Code.", "description": "Quickly run lua code in DCS World (local or remote server). A reimplementation of the DCS Fiddle lua console in VS Code.",
"license": "MIT", "license": "MIT",
"publisher": "omltcat", "publisher": "omltcat",
"version": "1.1.7", "version": "1.2",
"icon": "docs/img/icon.png", "icon": "docs/img/icon.png",
"repository": { "repository": {
"type": "git", "type": "git",
@ -27,17 +27,26 @@
"dcsLuaRunner.serverAddress": { "dcsLuaRunner.serverAddress": {
"type": "string", "type": "string",
"default": "", "default": "",
"description": "Remote DCS server address (IP or domain)." "description": "Remote DCS server address (IP or domain). See setup guide if you are using a HTTPS reverse proxy."
},
"dcsLuaRunner.serverAddressGUI": {
"type": "string",
"description": "Override remote GUI env address. For example, you can put both endpoints behind a HTTPS reverse proxy with different subdomains. Their ports should both be 443."
}, },
"dcsLuaRunner.serverPort": { "dcsLuaRunner.serverPort": {
"type": "number", "type": "number",
"default": 12080, "default": 12080,
"description": "Remote DCS Fiddle port for mission env. GUI env will automatically be on the next port (12081 by default)." "description": "Remote DCS Fiddle port for mission env. GUI env will automatically be on the next port (12081 by default)."
}, },
"dcsLuaRunner.serverPortGUI": {
"type": "number",
"default": 12081,
"description": "Overide remote GUI env port. For example, you can put both endpoints behind a HTTPS reverse proxy with different subdomains. Their ports should both be 443."
},
"dcsLuaRunner.useHttps": { "dcsLuaRunner.useHttps": {
"type": "boolean", "type": "boolean",
"default": false, "default": false,
"description": "Set if server is behind a HTTPS reverse proxy. You should also change server port accordingly (443)." "description": "Set if the remote server is behind a HTTPS reverse proxy. You should also change both ports accordingly (443)."
}, },
"dcsLuaRunner.webAuthUsername": { "dcsLuaRunner.webAuthUsername": {
"type": "string", "type": "string",

View File

@ -10,8 +10,12 @@ async function runLua(lua: string, outputChannel: vscode.OutputChannel, filename
const returnDisplayFormat = config.get('returnDisplayFormat') === 'JSON' ? 'json' : 'lua' as string; const returnDisplayFormat = config.get('returnDisplayFormat') === 'JSON' ? 'json' : 'lua' as string;
const runCodeLocally = config.get('runCodeLocally') as boolean; const runCodeLocally = config.get('runCodeLocally') as boolean;
const runInMissionEnv = config.get('runInMissionEnv') as boolean; const runInMissionEnv = config.get('runInMissionEnv') as boolean;
const serverAddress = runCodeLocally ? '127.0.0.1' : config.get('serverAddress') as string; const serverAddressMission = runCodeLocally ? '127.0.0.1' : config.get('serverAddress') as string;
const serverPort = (runCodeLocally ? 12080 : config.get('serverPort') as number) + (runInMissionEnv ? 0 : 1); const serverAddressGUI = (runCodeLocally || !config.get('serverAddressGUI')) ? serverAddressMission : config.get('serverAddressGUI') as string;
const serverAddress = runInMissionEnv ? serverAddressMission : serverAddressGUI;
const serverPortMission = runCodeLocally ? 12080 : config.get('serverPort') as number
const serverPortGUI = (runCodeLocally || !config.get('serverPortGUI')) ? (serverPortMission + 1) : config.get('serverPortGUI') as number;
const serverPort = runInMissionEnv ? serverPortMission : serverPortGUI;
const useHttps = runCodeLocally ? false : config.get('useHttps') as boolean; const useHttps = runCodeLocally ? false : config.get('useHttps') as boolean;
const authUsername = config.get('webAuthUsername') as string; const authUsername = config.get('webAuthUsername') as string;
const authPassword = config.get('webAuthPassword') as string; const authPassword = config.get('webAuthPassword') as string;
@ -162,21 +166,26 @@ export function activate(context: vscode.ExtensionContext) {
const config = vscode.workspace.getConfiguration('dcsLuaRunner'); const config = vscode.workspace.getConfiguration('dcsLuaRunner');
const runCodeLocally = config.get('runCodeLocally') as boolean; const runCodeLocally = config.get('runCodeLocally') as boolean;
const runInMissionEnv = config.get('runInMissionEnv') as boolean; const runInMissionEnv = config.get('runInMissionEnv') as boolean;
const runTarget = runCodeLocally ? 'local machine' : 'remote server';
const runEnv = runInMissionEnv ? 'mission' : 'GUI'; const runEnv = runInMissionEnv ? 'mission' : 'GUI';
const serverAddress = runCodeLocally ? '127.0.0.1' : config.get('serverAddress') as string; const serverAddressMission = runCodeLocally ? '127.0.0.1' : config.get('serverAddress') as string;
const serverPort = (runCodeLocally ? 12080 : config.get('serverPort') as number) + (runInMissionEnv ? 0 : 1); const serverAddressGUI = (runCodeLocally || !config.get('serverAddressGUI')) ? serverAddressMission : config.get('serverAddressGUI') as string;
const serverAddress = runInMissionEnv ? serverAddressMission : serverAddressGUI;
const serverPortMission = runCodeLocally ? 12080 : config.get('serverPort') as number
const serverPortGUI = (runCodeLocally || !config.get('serverPortGUI')) ? (serverPortMission + 1) : config.get('serverPortGUI') as number;
const serverPort = runInMissionEnv ? serverPortMission : serverPortGUI;
const useHttps = runCodeLocally ? false : config.get('useHttps') as boolean;
const protocol = useHttps ? 'https' : 'http';
if (config.get('returnDisplay') === 'Console Output') { if (config.get('returnDisplay') === 'Console Output') {
outputChannel.show(true); outputChannel.show(true);
outputChannel.appendLine(`[DCS] Settings: Run code in ${runEnv} environment on ${runTarget} (${serverAddress}:${serverPort}).`); outputChannel.appendLine(`[DCS] Settings: Run code in ${runEnv} environment on ${protocol}://${serverAddress}:${serverPort}.`);
} else { } else {
vscode.window.showInformationMessage(`Run code in ${runEnv} environment on ${serverAddress}:${serverPort}`); vscode.window.showInformationMessage(`Run code in ${runEnv} environment on ${protocol}://${serverAddress}:${serverPort}`);
} }
}; };
const updateSetting = async (setting: string, targetState: boolean) => { const updateSetting = async (setting: string, targetState: boolean) => {
const config = vscode.workspace.getConfiguration('dcsLuaRunner'); const config = vscode.workspace.getConfiguration('dcsLuaRunner');
if (setting === 'runCodeLocally' && targetState === false && config.get('serverAddress') === '') { if (setting === 'runCodeLocally' && targetState === false && !config.get('serverAddress')) {
vscode.window.showErrorMessage('Remote DCS server address not set.', 'Open Settings').then((choice) => { vscode.window.showErrorMessage('Remote DCS server address not set.', 'Open Settings').then((choice) => {
if (choice === 'Open Settings') { if (choice === 'Open Settings') {
vscode.commands.executeCommand('workbench.action.openSettings', 'dcsLuaRunner'); vscode.commands.executeCommand('workbench.action.openSettings', 'dcsLuaRunner');

File diff suppressed because it is too large Load Diff