mirror of
https://github.com/omltcat/dcs-lua-runner.git
synced 2025-11-10 15:49:49 +00:00
Release 1.2
This commit is contained in:
parent
07711a605a
commit
0685084a3c
12
CHANGELOG.md
12
CHANGELOG.md
@ -2,8 +2,6 @@
|
||||
|
||||
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]
|
||||
|
||||
### Added
|
||||
@ -96,3 +94,13 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
|
||||
### Added
|
||||
- Integrate a detailed setup guide into extension.
|
||||
- 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).
|
||||
44
INSTALL.md
44
INSTALL.md
@ -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).
|
||||
|
||||
## 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`.
|
||||
- Generally this means `C:\Users\<USERNAME>\Saved Games`
|
||||
- `<DCS VERSION>` could be `DCS`, `DCS.openbeta`, `DCS.release_server`, etc.
|
||||
@ -43,23 +43,45 @@ end
|
||||
### 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.
|
||||
|
||||
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
|
||||
-- Configs:
|
||||
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.USERNAME = 'username'
|
||||
FIDDLE.PASSWORD = 'password'
|
||||
FIDDLE.USERNAME = 'username' -- set your username
|
||||
FIDDLE.PASSWORD = 'password' -- set your password
|
||||
FIDDLE.BYPASS_LOCAL = true -- allow requests to 127.0.0.1:12080 without auth.
|
||||
--- So DCS Fiddle website can still work.
|
||||
--- (Not a very secure implementation. Use at your own risk if your 12080 port is public)
|
||||
-- This local bypass allows DCS Fiddle website to still work.
|
||||
-- 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
|
||||
1. In VS Code, open command pallette (`Ctrl`+`Shift`+`P`) and type `DCS Lua: Open Runner Settings`.
|
||||
2. Set server address, port, username, and password accordingly.
|
||||
In VS Code - DCS Lua Runner Settings, set the following accordingly:
|
||||
- Server Address: `fiddle.example.com`
|
||||
- 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
|
||||
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).
|
||||
|
||||
@ -19,15 +19,19 @@ A VS Code extension to run lua code in DCS World (on local or remote server, in
|
||||
|
||||
## Installation
|
||||
See [**INSTALL.md**](INSTALL.md).
|
||||
|
||||
**YOU MUST SETUP THE DCS SCRIPT FOR THIS EXTENSION TO WORK.**
|
||||
## Extension Settings
|
||||
|
||||
This extension has the following settings:
|
||||
|
||||
- `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`.
|
||||
|
||||
- `serverPortGUI`: Override port of the remote DCS Fiddle for GUI environment.
|
||||
|
||||
- `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`.
|
||||
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.
|
||||
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.
|
||||
|
||||
- `returnDisplayFormat`: Display return value as JSON or Lua table. (Experimental feature, please report any issue.)
|
||||
@ -56,6 +59,7 @@ See [**changelog**](CHANGELOG.md).
|
||||
|
||||
## 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).
|
||||
Under MIT License, see [dcsfiddle](https://github.com/JonathanTurnock/dcsfiddle?tab=MIT-1-ov-file).
|
||||
|
||||
## License
|
||||
|
||||
|
||||
15
package.json
15
package.json
@ -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.",
|
||||
"license": "MIT",
|
||||
"publisher": "omltcat",
|
||||
"version": "1.1.7",
|
||||
"version": "1.2",
|
||||
"icon": "docs/img/icon.png",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -27,17 +27,26 @@
|
||||
"dcsLuaRunner.serverAddress": {
|
||||
"type": "string",
|
||||
"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": {
|
||||
"type": "number",
|
||||
"default": 12080,
|
||||
"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": {
|
||||
"type": "boolean",
|
||||
"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": {
|
||||
"type": "string",
|
||||
|
||||
@ -10,8 +10,12 @@ async function runLua(lua: string, outputChannel: vscode.OutputChannel, filename
|
||||
const returnDisplayFormat = config.get('returnDisplayFormat') === 'JSON' ? 'json' : 'lua' as string;
|
||||
const runCodeLocally = config.get('runCodeLocally') as boolean;
|
||||
const runInMissionEnv = config.get('runInMissionEnv') as boolean;
|
||||
const serverAddress = runCodeLocally ? '127.0.0.1' : config.get('serverAddress') as string;
|
||||
const serverPort = (runCodeLocally ? 12080 : config.get('serverPort') as number) + (runInMissionEnv ? 0 : 1);
|
||||
const serverAddressMission = runCodeLocally ? '127.0.0.1' : config.get('serverAddress') as string;
|
||||
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 authUsername = config.get('webAuthUsername') 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 runCodeLocally = config.get('runCodeLocally') as boolean;
|
||||
const runInMissionEnv = config.get('runInMissionEnv') as boolean;
|
||||
const runTarget = runCodeLocally ? 'local machine' : 'remote server';
|
||||
const runEnv = runInMissionEnv ? 'mission' : 'GUI';
|
||||
const serverAddress = runCodeLocally ? '127.0.0.1' : config.get('serverAddress') as string;
|
||||
const serverPort = (runCodeLocally ? 12080 : config.get('serverPort') as number) + (runInMissionEnv ? 0 : 1);
|
||||
const serverAddressMission = runCodeLocally ? '127.0.0.1' : config.get('serverAddress') as string;
|
||||
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') {
|
||||
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 {
|
||||
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 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) => {
|
||||
if (choice === 'Open Settings') {
|
||||
vscode.commands.executeCommand('workbench.action.openSettings', 'dcsLuaRunner');
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user