diff options
| author | Victor Tseng <[email protected]> | 2023-05-16 23:54:31 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-05-16 23:54:31 +0800 |
| commit | e0cdaf91aa6d7ab98e84350f2f28fb3a4f86a585 (patch) | |
| tree | a210524e5270e969707e1f29d9625a4b0233409c /src | |
| parent | f8d1e8c0f5355abb7c5d8094a7e6cc6c9568c859 (diff) | |
parse sing-box `processPath` into `process` (#37)
clash-api for sing-box use `processPath` field which is the full-path of the captured process.
- On Windows: `\Device\HarddiskVolume3\Path\To\Program.exe`
- On Linux: `/path/to/program (username)`
grab the last part of the full path and render as `process`.
Diffstat (limited to 'src')
| -rw-r--r-- | src/api/connections.ts | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/api/connections.ts b/src/api/connections.ts index a9b8eaf..fd0901b 100644 --- a/src/api/connections.ts +++ b/src/api/connections.ts @@ -29,6 +29,7 @@ export type ConnectionItem = { destinationPort: string; host: string; process?: string; + processPath?: string; sniffHost?: string; }; upload: number; @@ -50,6 +51,14 @@ function appendData(s: string) { let o: ConnectionsData; try { o = JSON.parse(s); + o.connections.forEach(conn => { + let m = conn.metadata; + if (m.process == null) { + if (m.processPath != null) { + m.process = m.processPath.replace(/^.*[/\\](.*)$/, "$1"); + } + } + }); } catch (err) { // eslint-disable-next-line no-console console.log('JSON.parse error', JSON.parse(s)); |
