Options
All
  • Public
  • Public/Protected
  • All
Menu

vscode-proxy

vscode-proxy

Latest Release Installs Rating

Runs TCP proxies with additional trace support in Visual Studio Code.

Donate

Table of contents

  1. Install
  2. Demos
  3. How to use
  4. Documentation

Install []

Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter:

ext install vscode-proxy

Or search for things like vscode-proxy in your editor.

Demos

Tracing

Demo Tracing

How to use []

Settings []

Open (or create) your settings.json in your .vscode subfolder of your workspace.

Add a tcp.proxy section and one or more proxies:

{
    "tcp.proxy": {
        "80": {
            "autoStart": true,
            "name": "My HTTP proxy",
            "to": 8080,
            "outputFormat": "http"
        }
    }
}
Name Description
hexWidth The width for binary data in hex view. Default: 16
openAfterTrace Default value that indicates if traces should be opened in new tab after trace has been finished or not. Default: (true)
outputFormat Default output format for traces. Possible values are ascii, http, json and text. Default: text
proxies One or more proxies to register.
writeToOutput Default value for writing trace entries to output or not. Default: (false)

Proxies []

The following example registers a proxy at port 80 and sends all data to 8080.

{
    "tcp.proxy": {
        "80": {
            "autoStart": true,
            "name": "My HTTP proxy",
            "description": "A proxy for my HTTP server",
            "to": 8080,
            "outputFormat": "http"
        }
    }
}
Name Description
autoStart Start proxy on startup or not. Default: (false)
chunkHandler The path to the script that handles a chunk.
chunkHandlerOptions Additional options for the chunk handler.
chunkHandlerState Initial state value for the chunk handler.
description An additional description for the proxy.
name The name of the proxy.
openAfterTrace Open traces in new tab after trace has been finished or not. Default: (true)
outputFormat Output format for traces. Possible values are ascii, http, json and text. Default: text
receiveChunksFrom The custom list of targets (s. to) from where to send answers back to the source / client or (true) or (false) to enable/disable that feature. Default: First target.
traceHandler The path to the script that handles a (new) trace entry.
traceHandlerOptions Additional options for the trace handler.
traceHandlerState Initial state value for the trace handler.
traceWriter The path to the script that writes a trace list, when tracing is stopped.
traceWriterOptions Additional options for the trace writer.
traceWriterState Initial state value for the trace writer.
to The destination port(s) or address(es).
writeToOutput Write trace entries to output or not. Default: (false)
Chunk handlers []
exports.handleChunk = function(args) {
    // this function is executed synchronous

    // you can update `args.chunk` property with new
    // data, which should be send to the target
    // 
    // (undefined) or (null) will NOT send data to the target

    // you can also access any NodeJS API
    // provided by Visual Studio Code
    // and the modules shipped with that extension
    // (s. https://github.com/mkloubert/vscode-proxy/blob/master/package.json)
};

args uses the ChunkHandlerModuleExecutorArguments interface.

Trace handlers []
exports.handleTrace = function(args) {
    // this function is executed synchronous

    // you can also access any NodeJS API
    // provided by Visual Studio Code
    // and the modules shipped with that extension
    // (s. https://github.com/mkloubert/vscode-proxy/blob/master/package.json)
};

args uses the TraceHandlerModuleExecutorArguments interface.

Trace writers []
exports.writeTrace = function(args) {
    // this function can be executed asynchronous
    // via a promise

    // the final trace list is stored
    // in 'args.trace' array
    for (let i = 0; i < args.trace.length; i++) {
        // s. https://mkloubert.github.io/vscode-proxy/interfaces/_contracts_.traceentry.html
        let currentTraceEntry = args.trace[i];

        //TODO
    }

    // you can also access any NodeJS API
    // provided by Visual Studio Code
    // and the modules shipped with that extension
    // (s. https://github.com/mkloubert/vscode-proxy/blob/master/package.json)
};

args uses the TraceWriterModuleExecutorArguments interface.

Commands []

Press F1 to open the list of commands and enter one of the following commands:

Name Description ID
Proxy: Start / stop Starts or stops one or more proxies. extension.proxy.startStop
Proxy: Trace Starts or stops tracing one or more proxies. extension.proxy.trace

Documentation []

The full API documentation can be found here.

Generated using TypeDoc