MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / classifyLine

Function classifyLine

graph-ui/tools/net-deny-gate.mjs:129–154  ·  view source on GitHub ↗
(line)

Source from the content-addressed store, hash-verified

127 * empfaengt, er sendet nichts nach draussen.
128 */
129export function classifyLine(line) {
130 if (!/\s(TCP|UDP)\s/.test(line)) { return null; }
131 const nameStart = line.search(/\s(TCP|UDP)\s/);
132 const rest = line.slice(nameStart).trim();
133 const protocol = rest.startsWith('TCP') ? 'TCP' : 'UDP';
134 const address = rest.slice(3).trim().replace(/\s*\(.*\)\s*$/, '').trim();
135 const arrow = address.indexOf('->');
136 if (arrow === -1) { return null; }
137
138 const localPart = address.slice(0, arrow);
139 const remotePart = address.slice(arrow + 2);
140 const remote = splitHostPort(remotePart);
141 const command = line.trim().split(/\s+/)[0];
142 const pid = Number(line.trim().split(/\s+/)[1]);
143
144 return {
145 protocol,
146 command,
147 pid: Number.isFinite(pid) ? pid : null,
148 local: localPart.trim(),
149 remote: remotePart.trim(),
150 remoteHost: remote.host,
151 remotePort: remote.port,
152 loopback: isLoopbackHost(remote.host),
153 };
154}
155
156// ------------------------------------------------------------------ Main ----
157

Callers 3

onceFunction · 0.90
sampleOnceFunction · 0.85

Calls 2

splitHostPortFunction · 0.85
isLoopbackHostFunction · 0.85

Tested by

no test coverage detected