MCPcopy
hub / github.com/mitmproxy/mitmproxy / updateModes

Function updateModes

web/src/js/ducks/modes/utils.ts:29–50  ·  view source on GitHub ↗
(_, thunkAPI)

Source from the content-addressed store, hash-verified

27 * Async thunk to update modes based on current UI state.
28 */
29export async function updateModes(_, thunkAPI) {
30 const modes = thunkAPI.getState().modes;
31 const activeModes: string[] = [
32 ...modes.regular.filter(isActiveMode).map(getRegularSpec),
33 ...modes.local.filter(isActiveMode).map(getLocalSpec),
34 ...modes.wireguard.filter(isActiveMode).map(getWireguardSpec),
35 ...modes.reverse.filter(isActiveMode).map(getReverseSpec),
36 ...modes.transparent.filter(isActiveMode).map(getTransparentSpec),
37 ...modes.socks.filter(isActiveMode).map(getSocksSpec),
38 ...modes.upstream.filter(isActiveMode).map(getUpstreamSpec),
39 ...modes.dns.filter(isActiveMode).map(getDnsSpec),
40 //add new modes here
41 ];
42 const response = await fetchApi.put("/options", {
43 mode: activeModes,
44 });
45 if (response.status === 200) {
46 return;
47 } else {
48 throw new Error(await response.text());
49 }
50}
51
52export function createModeUpdateThunk<T>(type: string) {
53 return createAppAsyncThunk<void, { server: ModeState; value: T }>(

Callers 1

utilsSpec.tsxFile · 0.90

Calls 4

mapMethod · 0.45
filterMethod · 0.45
putMethod · 0.45
textMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…