mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-05-06 17:59:11 +00:00
a1bec48dc9
* fix android vpn permission grant * fix url input behaviour
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
import { invoke } from '@tauri-apps/api/core'
|
|
|
|
export async function ping(value: string): Promise<string | null> {
|
|
return await invoke<{ value?: string }>('plugin:vpnservice|ping', {
|
|
payload: {
|
|
value,
|
|
},
|
|
}).then((r) => (r.value ? r.value : null));
|
|
}
|
|
|
|
export interface InvokeResponse {
|
|
errorMsg?: string;
|
|
granted?: boolean;
|
|
}
|
|
|
|
export interface StartVpnRequest {
|
|
ipv4Addr?: string;
|
|
routes?: string[];
|
|
dns?: string;
|
|
disallowedApplications?: string[];
|
|
mtu?: number;
|
|
}
|
|
|
|
export interface VpnStatusResponse {
|
|
running: boolean;
|
|
ipv4Addr?: string;
|
|
routes?: string[];
|
|
dns?: string;
|
|
}
|
|
|
|
export async function prepare_vpn(): Promise<InvokeResponse | null> {
|
|
return await invoke<InvokeResponse>('plugin:vpnservice|prepare_vpn', {})
|
|
}
|
|
|
|
export async function start_vpn(request: StartVpnRequest): Promise<InvokeResponse | null> {
|
|
return await invoke<InvokeResponse>('plugin:vpnservice|start_vpn', {
|
|
...request,
|
|
})
|
|
}
|
|
|
|
export async function stop_vpn(): Promise<InvokeResponse | null> {
|
|
return await invoke<InvokeResponse>('plugin:vpnservice|stop_vpn', {})
|
|
}
|
|
|
|
export async function get_vpn_status(): Promise<VpnStatusResponse | null> {
|
|
return await invoke<VpnStatusResponse>('plugin:vpnservice|get_vpn_status', {})
|
|
}
|