mirror of
https://github.com/omltcat/dcs-lua-runner.git
synced 2025-11-10 15:49:49 +00:00
Release 1.1.7
This commit is contained in:
parent
5b0c62efb5
commit
07711a605a
@ -90,3 +90,9 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
|
||||
|
||||
### Fixed
|
||||
- Fix JSON to Lua table regex with escaped quotes.
|
||||
|
||||
## [1.1.7] - 2024-05-10
|
||||
|
||||
### Added
|
||||
- Integrate a detailed setup guide into extension.
|
||||
- Automatically show setup guide on first activation.
|
||||
65
INSTALL.md
Normal file
65
INSTALL.md
Normal file
@ -0,0 +1,65 @@
|
||||
# DCS Lua Runner Setup
|
||||
> This guide only shows automatically once.
|
||||
> You can open it anytime with command pallet "DCS Lua: Show Setup Guide".
|
||||
|
||||
**You need to setup the DCS Fiddle script before using this extension.**
|
||||
|
||||
We use a modified version of the DCS Fiddle script that adds optional authentication for remote access.
|
||||
It is still compatible with the [DCS Fiddle website](https://dcsfiddle.pages.dev/).
|
||||
|
||||
- If you find this extension useful, please star it on [**GitHub**](https://github.com/omltcat/dcs-lua-runner)
|
||||
- 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).
|
||||
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.
|
||||
- Create the `Scripts\Hooks` folder if it doesn't exist.
|
||||
|
||||
> **IMPORTANT:**
|
||||
The provided script is based on an earlier version that uses a custom JSON serialization module instead of the new DCS built-in json functions. To allow the extension to properly reconstruct the in-game Lua table, you should use the provided script.
|
||||
|
||||
See [**Remote Access**](#remote-access) below if you want to run code on a remote DCS server.
|
||||
|
||||
## De-sanitize Mission Scripting
|
||||
1. Go to your **DCS installation folder** (not Saved Games).
|
||||
2. Open `...\Scripts\MissionScripting.lua`.
|
||||
3. Find and comment out `'require'` and `'package'` lines
|
||||
|
||||
```diff
|
||||
do
|
||||
sanitizeModule('os')
|
||||
sanitizeModule('io')
|
||||
sanitizeModule('lfs')
|
||||
+ -- _G['require'] = nil
|
||||
_G['loadlib'] = nil
|
||||
+ -- _G['package'] = nil
|
||||
end
|
||||
```
|
||||
|
||||
## Remote Access
|
||||
|
||||
### 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.
|
||||
|
||||
```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.AUTH = true -- set to true to enable basic auth, recommended for public servers.
|
||||
FIDDLE.USERNAME = 'username'
|
||||
FIDDLE.PASSWORD = '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)
|
||||
```
|
||||
|
||||
### 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.
|
||||
|
||||
## 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).
|
||||
23
README.md
23
README.md
@ -2,9 +2,8 @@
|
||||
|
||||
A VS Code extension to run lua code in DCS World (on local or remote server, in mission or GUI environment). A reimplementation of the [DCS Fiddle](https://github.com/JonathanTurnock/dcsfiddle) web lua console. Allows for quick development and debugging of running scripted missions directly from the comfort of VS Code.
|
||||
|
||||
**IMPORTANT (new):**
|
||||
v1.1.6 reverts to providing an earlier version of dcs-fiddle-server.lua that comes with a custom JSON Serialization Module. The JSON-to-Lua conversion in this extension lavages this module to properly reconstruct the in-game Lua table.
|
||||
*YOU MUST UPDATE THE [dcs-fiddle-server.lua](https://github.com/omltcat/dcs-lua-runner/blob/master/src/hooks/dcs-fiddle-server.lua) FILE IN YOUR INSTALLATION TO TAKE ADVANTAGE OF THIS FEATURE.*
|
||||
- If you find this extension useful, please star it on [**GitHub**](https://github.com/omltcat/dcs-lua-runner)
|
||||
- Don't hesitate to report any problems, provide segguestions or request features using [**Issues**](https://github.com/omltcat/dcs-lua-runner/issues).
|
||||
|
||||

|
||||
|
||||
@ -18,20 +17,8 @@ v1.1.6 reverts to providing an earlier version of dcs-fiddle-server.lua that com
|
||||
- Display return value in output panel or as a file (for syntax highlight)
|
||||
- in either JSON or Lua table format.
|
||||
|
||||
## Requirements
|
||||
|
||||
### DCS Hooks Installation
|
||||
Install DCS Fiddle script the same way as the original web version, and de-sanitize mission scripting.
|
||||
[**Original instruction here**](https://dcsfiddle.pages.dev/docs)
|
||||
|
||||
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).
|
||||
|
||||
### Important
|
||||
If you want to run code on a remote DCS server, you need to expose its Fiddle port (12080 by default). This however, creates a security risk, as everyone can now inject lua code into your server.
|
||||
|
||||
It is recommended to install this [modified Fiddle script](src/hooks/dcs-fiddle-server.lua). It allows you configure a basic authentication at the beginning of the file.
|
||||
|
||||
For even better security, put the Fiddle port behind a reverse proxy with HTTPS.
|
||||
## Installation
|
||||
See [**INSTALL.md**](INSTALL.md).
|
||||
|
||||
## Extension Settings
|
||||
|
||||
@ -68,7 +55,7 @@ See [**changelog**](CHANGELOG.md).
|
||||
|
||||
|
||||
## Credits
|
||||
[**DCS Fiddle**](https://github.com/JonathanTurnock/dcsfiddle) by [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).
|
||||
|
||||
## License
|
||||
|
||||
|
||||
@ -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.6",
|
||||
"version": "1.1.7",
|
||||
"icon": "docs/img/icon.png",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -191,6 +191,10 @@
|
||||
{
|
||||
"command": "dcs-lua-runner.set-guiEnv-button",
|
||||
"title": "Env: Mission"
|
||||
},
|
||||
{
|
||||
"command": "dcs-lua-runner.show-setup-guide",
|
||||
"title": "DCS Lua: Show Setup Guide"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@ -116,6 +116,14 @@ function getCurrentFileLua() {
|
||||
}
|
||||
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
// context.globalState.update('firstRunDone', false);
|
||||
const isFirstRun = !context.globalState.get('firstRunDone');
|
||||
if (isFirstRun) {
|
||||
context.globalState.update('firstRunDone', true);
|
||||
const installMdPath = vscode.Uri.file(context.asAbsolutePath('INSTALL.md'));
|
||||
vscode.commands.executeCommand('markdown.showPreview', installMdPath);
|
||||
}
|
||||
|
||||
const config = vscode.workspace.getConfiguration('dcsLuaRunner');
|
||||
let outputChannel = vscode.window.createOutputChannel("DCS Lua Runner");
|
||||
|
||||
@ -191,6 +199,10 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
context.subscriptions.push(vscode.commands.registerCommand('dcs-lua-runner.set-missionEnv-button', () => updateSetting('runInMissionEnv', true)));
|
||||
context.subscriptions.push(vscode.commands.registerCommand('dcs-lua-runner.set-guiEnv', () => updateSetting('runInMissionEnv', false)));
|
||||
context.subscriptions.push(vscode.commands.registerCommand('dcs-lua-runner.set-guiEnv-button', () => updateSetting('runInMissionEnv', false)));
|
||||
context.subscriptions.push(vscode.commands.registerCommand('dcs-lua-runner.show-setup-guide', () => {
|
||||
const installMdPath = vscode.Uri.file(context.asAbsolutePath('INSTALL.md'));
|
||||
vscode.commands.executeCommand('markdown.showPreview', installMdPath);
|
||||
}));
|
||||
|
||||
// Update the 'luaFileActive' context when the active editor changes
|
||||
vscode.window.onDidChangeActiveTextEditor(editor => {
|
||||
@ -230,7 +242,8 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
{ label: 'DCS Lua: Set Run Code on Remote Server', command: 'dcs-lua-runner.set-remote' },
|
||||
{ label: 'DCS Lua: Set Run Code in Mission Environment', command: 'dcs-lua-runner.set-missionEnv' },
|
||||
{ label: 'DCS Lua: Set Run Code in GUI Environment', command: 'dcs-lua-runner.set-guiEnv' },
|
||||
{ label: 'DCS Lua: Open Settings', command: 'dcs-lua-runner.open-settings' }
|
||||
{ label: 'DCS Lua: Open Settings', command: 'dcs-lua-runner.open-settings' },
|
||||
{ label: 'DCS Lua: Show Setup Guide', command: 'dcs-lua-runner.show-setup-guide'}
|
||||
];
|
||||
vscode.window.showQuickPick(items).then(selection => {
|
||||
// the user picked an item from the list
|
||||
|
||||
@ -5,10 +5,10 @@ FIDDLE = {}
|
||||
|
||||
-- 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.AUTH = true -- set to true to enable basic auth, recommended for public servers.
|
||||
FIDDLE.USERNAME = 'username'
|
||||
FIDDLE.PASSWORD = 'password'
|
||||
FIDDLE.BIND_IP = '0.0.0.0' -- for remote access
|
||||
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)
|
||||
--[[
|
||||
Custom JSON Serialization Module that handles DCS' usage of integers as table keys such as {[1]=1, ["name"]="Enfield11", [2]=1, [3]=1} which is not valid json
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user