MCPcopy Create free account
hub / github.com/mitmproxy/mitmproxy / parseSpec

Function parseSpec

web/src/js/modes/index.ts:33–66  ·  view source on GitHub ↗
(full_spec: string)

Source from the content-addressed store, hash-verified

31}
32
33export const parseSpec = (full_spec: string): RawSpecParts => {
34 let [head, listenAt] = rpartition(full_spec, "@");
35
36 if (!head) {
37 head = listenAt;
38 listenAt = "";
39 }
40
41 const [name, data] = partition(head, ":");
42 let listen_host: string | undefined, listen_port: number | undefined;
43
44 if (listenAt) {
45 let port: string;
46 if (listenAt.includes(":")) {
47 [listen_host, port] = rpartition(listenAt, ":");
48 } else {
49 listen_host = "";
50 port = listenAt;
51 }
52 if (port) {
53 listen_port = parseInt(port, 10);
54 if (isNaN(listen_port) || listen_port < 0 || listen_port > 65535) {
55 throw new Error(`invalid port: ${port}`);
56 }
57 }
58 }
59 return {
60 full_spec,
61 name,
62 data,
63 listen_host,
64 listen_port,
65 };
66};

Callers 11

updateStateFunction · 0.90
updateStateFunction · 0.90
reverseSpec.tsFile · 0.90
indexSpec.tsFile · 0.90
regularSpec.tsFile · 0.90
socksSpec.tsFile · 0.90
wireguardSpec.tsFile · 0.90
localSpec.tsFile · 0.90
upstreamSpec.tsFile · 0.90
dnsSpec.tsFile · 0.90
transparentSpec.tsFile · 0.90

Calls 2

rpartitionFunction · 0.90
partitionFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…