Skip to content

Commit

Permalink
增加系统代理的配置 (yaklang#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
VillanCh authored Jul 30, 2022
1 parent 555d85b commit 6cd7509
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 56 deletions.
2 changes: 2 additions & 0 deletions app/protos/grpc.proto
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,12 @@ message GetKeyResult {

message SetSystemProxyRequest {
string HttpProxy = 1;
bool Enable = 2;
}

message GetSystemProxyResult {
string CurrentProxy = 1;
bool Enable = 2;
}

message GetExecBatchYakScriptUnfinishedTaskByUidRequest {
Expand Down
80 changes: 42 additions & 38 deletions app/renderer/src/main/src/pages/MainOperator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import "./GlobalClass.scss"
import "./GlobalClass.scss"
import {loginOut, refreshToken} from "@/utils/login"
import {setRemoteValue} from "@/utils/kv"
import {showConfigSystemProxyForm} from "@/utils/ConfigSystemProxy";

const {ipcRenderer} = window.require("electron")
const MenuItem = Menu.Item
Expand Down Expand Up @@ -176,7 +177,7 @@ export interface MenuItemType {

const Main: React.FC<MainProp> = (props) => {
const [engineStatus, setEngineStatus] = useState<"ok" | "error">("ok")
const [status, setStatus] = useState<{addr: string; isTLS: boolean}>()
const [status, setStatus] = useState<{ addr: string; isTLS: boolean }>()
const [collapsed, setCollapsed] = useState(false)
const [hideMenu, setHideMenu] = useState(false)

Expand Down Expand Up @@ -230,7 +231,7 @@ const Main: React.FC<MainProp> = (props) => {
// Fetch User Defined Plugins
ipcRenderer
.invoke("GetAllMenuItem", {})
.then((data: {Groups: MenuItemGroup[]}) => {
.then((data: { Groups: MenuItemGroup[] }) => {
setMenuItems(data.Groups)
})
.catch((e: any) => failed("Update Menu Item Failed"))
Expand All @@ -249,7 +250,7 @@ const Main: React.FC<MainProp> = (props) => {
if (item.key === Route.GeneralModule) {
const extraMenus: MenuDataProps[] = data.Data.map((i) => {
return {
icon: <EllipsisOutlined />,
icon: <EllipsisOutlined/>,
key: `plugin:${i.Id}`,
label: i.ScriptName
} as unknown as MenuDataProps
Expand Down Expand Up @@ -632,7 +633,7 @@ const Main: React.FC<MainProp> = (props) => {

// 加载补全
useEffect(() => {
ipcRenderer.invoke("GetYakitCompletionRaw").then((data: {RawJson: Uint8Array}) => {
ipcRenderer.invoke("GetYakitCompletionRaw").then((data: { RawJson: Uint8Array }) => {
const completionJson = Buffer.from(data.RawJson).toString("utf8")
setCompletions(JSON.parse(completionJson) as CompletionTotal)
// success("加载 Yak 语言自动补全成功 / Load Yak IDE Auto Completion Finished")
Expand All @@ -657,7 +658,8 @@ const Main: React.FC<MainProp> = (props) => {
.catch((e: any) => {
setEngineStatus("error")
})
.finally(() => {})
.finally(() => {
})
}
let id = setInterval(updateEngineStatus, 3000)
return () => {
Expand All @@ -667,7 +669,8 @@ const Main: React.FC<MainProp> = (props) => {
}
}, [])

useHotkeys("Ctrl+Alt+T", () => {})
useHotkeys("Ctrl+Alt+T", () => {
})

useEffect(() => {
ipcRenderer.invoke("query-latest-notification").then((e: string) => {
Expand All @@ -685,7 +688,7 @@ const Main: React.FC<MainProp> = (props) => {
title: "Notification",
content: (
<>
<MDEditor.Markdown source={e} />
<MDEditor.Markdown source={e}/>
</>
)
})
Expand Down Expand Up @@ -765,7 +768,8 @@ const Main: React.FC<MainProp> = (props) => {
setBugList(res ? JSON.parse(res) : [])
setBugTestShow(true)
})
.catch(() => {})
.catch(() => {
})
}
if (type === 2) {
const filter = pageCache.filter((item) => item.route === Route.PoC)
Expand Down Expand Up @@ -893,11 +897,11 @@ const Main: React.FC<MainProp> = (props) => {
<Col span={8}>
<Space>
<div style={{marginLeft: 18, textAlign: "center", height: 60}}>
<Image src={YakLogoBanner} preview={false} width={130} style={{marginTop: 6}} />
<Image src={YakLogoBanner} preview={false} width={130} style={{marginTop: 6}}/>
</div>
<Divider type={"vertical"} />
<YakVersion />
<YakitVersion />
<Divider type={"vertical"}/>
<YakVersion/>
<YakitVersion/>
{!hideMenu && (
<Button
style={{marginLeft: 4, color: "#207ee8"}}
Expand All @@ -906,7 +910,7 @@ const Main: React.FC<MainProp> = (props) => {
onClick={(e) => {
setCollapsed(!collapsed)
}}
icon={collapsed ? <MenuUnfoldOutlined /> : <MenuFoldOutlined />}
icon={collapsed ? <MenuUnfoldOutlined/> : <MenuFoldOutlined/>}
/>
)}
<Button
Expand All @@ -916,18 +920,18 @@ const Main: React.FC<MainProp> = (props) => {
onClick={(e) => {
updateMenuItems()
}}
icon={<ReloadOutlined />}
icon={<ReloadOutlined/>}
/>
</Space>
</Col>
<Col span={16} style={{textAlign: "right", paddingRight: 28}}>
<PerformanceDisplay />
<RiskStatsTag professionalMode={true} />
<PerformanceDisplay/>
<RiskStatsTag professionalMode={true}/>
<Space>
{/* {status?.isTLS ? <Tag color={"green"}>TLS:通信已加密</Tag> : <Tag color={"red"}>通信未加密</Tag>} */}
{status?.addr && <Tag color={"geekblue"}>{status?.addr}</Tag>}
{/* <Tag color={engineStatus === "ok" ? "green" : "red"}>Yak 引擎状态:{engineStatus}</Tag> */}
<ReversePlatformStatus />
<ReversePlatformStatus/>
<Dropdown
forceRender={true}
overlay={
Expand Down Expand Up @@ -960,7 +964,7 @@ const Main: React.FC<MainProp> = (props) => {
width: 800,
content: (
<div style={{width: 800}}>
<ConfigGlobalReverse />
<ConfigGlobalReverse/>
</div>
)
})
Expand All @@ -969,11 +973,11 @@ const Main: React.FC<MainProp> = (props) => {
<Button type={"link"}>配置全局反连</Button>
{/*<ConfigGlobalReverseButton/>*/}
</Menu.Item>
{/*<Menu.Item key={"config-system-proxy"} onClick={() => {*/}
{/* showConfigSystemProxyForm()*/}
{/*}}>*/}
{/* <Button type={"link"}>配置系统代理</Button>*/}
{/*</Menu.Item>*/}
<Menu.Item key={"config-system-proxy"} onClick={() => {
showConfigSystemProxyForm()
}}>
<Button type={"link"}>配置系统代理</Button>
</Menu.Item>
<Menu.Item key={"config-menu"} onClick={() => showConfigMenuItems()}>
<Button type={"link"}>配置菜单栏</Button>
</Menu.Item>
Expand All @@ -982,18 +986,18 @@ const Main: React.FC<MainProp> = (props) => {
onClick={() => {
const m = showModal({
title: "配置私有域",
content: <ConfigPrivateDomain onClose={() => m.destroy()} />
content: <ConfigPrivateDomain onClose={() => m.destroy()}/>
})
return m
}}
>
<Button type={"link"}>配置私有域</Button>   
<Button type={"link"}>配置私有域</Button>
</Menu.Item>
</Menu>
}
trigger={["click"]}
>
<Button icon={<SettingOutlined />}>配置</Button>
<Button icon={<SettingOutlined/>}>配置</Button>
</Dropdown>
{userInfo.isLogin ? (
<div>
Expand Down Expand Up @@ -1030,7 +1034,7 @@ const Main: React.FC<MainProp> = (props) => {
<Button
type={"link"}
danger={true}
icon={<PoweroffOutlined />}
icon={<PoweroffOutlined/>}
onClick={() => {
if (winCloseFlag) {
setWinCloseShow(true)
Expand Down Expand Up @@ -1083,15 +1087,15 @@ const Main: React.FC<MainProp> = (props) => {
}
return (
<Menu.SubMenu
icon={<EllipsisOutlined />}
icon={<EllipsisOutlined/>}
key={i.Group}
title={i.Group}
>
{i.Items.map((item) => {
if (item.YakScriptId > 0) {
return (
<MenuItem
icon={<EllipsisOutlined />}
icon={<EllipsisOutlined/>}
key={`plugin:${item.Group}:${item.YakScriptId}`}
>
<Text ellipsis={{tooltip: true}}>
Expand All @@ -1102,7 +1106,7 @@ const Main: React.FC<MainProp> = (props) => {
}
return (
<MenuItem
icon={<EllipsisOutlined />}
icon={<EllipsisOutlined/>}
key={`batch:${item.Group}:${item.Verbose}:${item.MenuItemId}`}
>
<Text ellipsis={{tooltip: true}}>
Expand Down Expand Up @@ -1219,7 +1223,7 @@ const Main: React.FC<MainProp> = (props) => {
</>
}
>
<EditOutlined className='main-container-cion' />
<EditOutlined className='main-container-cion'/>
</Popover>
<CloseOutlined
className='main-container-cion'
Expand Down Expand Up @@ -1293,7 +1297,7 @@ const Main: React.FC<MainProp> = (props) => {
]}
>
<div style={{height: 40}}>
<ExclamationCircleOutlined style={{fontSize: 22, color: "#faad14"}} />
<ExclamationCircleOutlined style={{fontSize: 22, color: "#faad14"}}/>
<span style={{fontSize: 18, marginLeft: 15}}>提示</span>
</div>
<p style={{fontSize: 15, marginLeft: 37}}>
Expand Down Expand Up @@ -1346,12 +1350,12 @@ const Main: React.FC<MainProp> = (props) => {
setBugTestValue(
value
? [
{
filter: option?.filter,
key: option?.key,
title: option?.title
}
]
{
filter: option?.filter,
key: option?.key,
title: option?.title
}
]
: []
)
}}
Expand Down
18 changes: 13 additions & 5 deletions app/renderer/src/main/src/pages/mitm/MITMServerHijacking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
Alert,
Button,
Checkbox,
Col,
Col, Dropdown, Menu,
Modal,
notification,
PageHeader,
Expand Down Expand Up @@ -37,6 +37,7 @@ import {ExtractExecResultMessage} from "@/components/yakitLogSchema";
import {showDrawer, showModal} from "@/utils/showModal";
import {saveABSFileToOpen} from "@/utils/openWebsite";
import {MITMResponse} from "@/pages/mitm/MITMPage";
import {showConfigSystemProxyForm} from "@/utils/ConfigSystemProxy";

type MITMStatus = "hijacking" | "hijacked" | "idle";
const {Text} = Typography;
Expand Down Expand Up @@ -450,7 +451,7 @@ export const MITMServerHijacking: React.FC<MITMServerHijackingProp> = (props) =>
})
}}
>
匹配/标记/替换
标记 / 替换流量规则
</Button>
})

Expand All @@ -472,7 +473,7 @@ export const MITMServerHijacking: React.FC<MITMServerHijackingProp> = (props) =>
</>
});
}}
>过滤器</Button>
>过滤劫持流量</Button>
})

const handleAutoForward = useMemoizedFn((e: "manual" | "log" | "passive") => {
Expand Down Expand Up @@ -521,9 +522,16 @@ export const MITMServerHijacking: React.FC<MITMServerHijackingProp> = (props) =>
style={{marginRight: 0, paddingRight: 0, paddingTop: 0, paddingBottom: 8}}
extra={
<Space>
<Button onClick={() => {
showConfigSystemProxyForm(`${host === "0.0.0.0" ? "127.0.0.1" : host}:${port}`)
}}>系统代理</Button>
<ChromeLauncherButton host={host} port={port}/>
{contentReplacer()}
{setFilter()}
<Dropdown overlay={<Space direction={"vertical"}>
{contentReplacer()}
{setFilter()}
</Space>}>
<Button type={"link"}>过滤 / 替换流量</Button>
</Dropdown>
{downloadCert()}
<Button danger={true} type={"link"}
onClick={() => {
Expand Down
Loading

0 comments on commit 6cd7509

Please sign in to comment.