[GH-ISSUE #746] Get flow info from JS Context in the Scripting #740

Open
opened 2026-03-03 19:21:30 +03:00 by kerem · 1 comment
Owner

Originally created by @NghiaTranUIT on GitHub (Dec 30, 2020).
Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/746

Originally assigned to: @NghiaTranUIT on GitHub.

Description

Currently, we can print out the data of the context object by using console.log(context). For instance,

// context (readonly)
{
    "scriptName": "<String> Your Script Name",
    "matchingRule": "<String> Your Matching Rule",
    "matchingMethod": "<String> Method",
    "isEnableOnRequest": "Bool",
    "isEnableOnResponse": "Bool",
    "filePath": "<String> Script path"
}

However, it lacks the flow data, such as ID, Remote Device IP, Nickname, Client Path, or Client/Remote Address. They're useful if some users need them to write their logic.

For example, change the host if the request comes from a particular remote device.

if (context.remoteDeviceIP == "192.168.0.101") {
   request.host = "localhost"
}

Acceptance Criteria

  • Add a few useful information of the flow to the context object
Originally created by @NghiaTranUIT on GitHub (Dec 30, 2020). Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/746 Originally assigned to: @NghiaTranUIT on GitHub. ### Description Currently, we can print out the data of the `context` object by using `console.log(context)`. For instance, ``` // context (readonly) { "scriptName": "<String> Your Script Name", "matchingRule": "<String> Your Matching Rule", "matchingMethod": "<String> Method", "isEnableOnRequest": "Bool", "isEnableOnResponse": "Bool", "filePath": "<String> Script path" } ``` However, it lacks the flow data, such as ID, Remote Device IP, Nickname, Client Path, or Client/Remote Address. They're useful if some users need them to write their logic. For example, change the host if the request comes from a particular remote device. ``` if (context.remoteDeviceIP == "192.168.0.101") { request.host = "localhost" } ``` ### Acceptance Criteria - Add a few useful information of the flow to the context object
Author
Owner

@NghiaTranUIT commented on GitHub (Dec 31, 2020):

Done with https://proxyman.s3.us-east-2.amazonaws.com/beta/Proxyman_2.15.2_Add_More_Info_Scripting_Context.dmg

[onResponse] with Request ID=51
{
"scriptName": "Log Context",
"flow": {
"serverPort": "443",
"serverIpAddress": "104.18.230.83",
"clientIpAddress": "192.168.0.102",
"remoteDeviceName": "iPhone XR",
"remoteDeviceIP": "192.168.0.102",
"id": "51",
"clientPath": null,
"clientPort": "51494",
"clientName": null
},
"isEnableOnResponse": true,
"matchingMethod": "ANY",
"matchingRule": "https://api.producthunt.com/v2/graphql",
"filePath": "/Users/nghiatran/Library/Application Support/com.proxyman.NSProxy/scripts/EA0E187E.js",
"isEnableOnRequest": true
}
<!-- gh-comment-id:752860496 --> @NghiaTranUIT commented on GitHub (Dec 31, 2020): Done with https://proxyman.s3.us-east-2.amazonaws.com/beta/Proxyman_2.15.2_Add_More_Info_Scripting_Context.dmg ``` [onResponse] with Request ID=51 { "scriptName": "Log Context", "flow": { "serverPort": "443", "serverIpAddress": "104.18.230.83", "clientIpAddress": "192.168.0.102", "remoteDeviceName": "iPhone XR", "remoteDeviceIP": "192.168.0.102", "id": "51", "clientPath": null, "clientPort": "51494", "clientName": null }, "isEnableOnResponse": true, "matchingMethod": "ANY", "matchingRule": "https://api.producthunt.com/v2/graphql", "filePath": "/Users/nghiatran/Library/Application Support/com.proxyman.NSProxy/scripts/EA0E187E.js", "isEnableOnRequest": true } ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/Proxyman#740
No description provided.