mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-10-10 12:46:14 -08:00
Gather addresses and routes from running instances in the GUI for VpnService. Attach its single fd to the core shared TUN and refresh the VPN when instance configuration changes. Keep the FFI set_tun_fd call scoped to one instance and report attachment errors. Cover mobile configuration and reconciliation in GUI tests.
60 lines
1.6 KiB
TypeScript
60 lines
1.6 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;
|
|
ipv4Addrs?: string[];
|
|
routes?: string[];
|
|
dns?: string;
|
|
disallowedApplications?: string[];
|
|
mtu?: number;
|
|
}
|
|
|
|
export interface VpnStatusResponse {
|
|
running: boolean;
|
|
ipv4Addr?: string;
|
|
ipv4Addrs?: string[];
|
|
routes?: string[];
|
|
dns?: string;
|
|
}
|
|
|
|
export type VpnTileAction = 'start' | 'stop';
|
|
|
|
export interface VpnTileActionResponse {
|
|
action?: VpnTileAction;
|
|
}
|
|
|
|
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', {})
|
|
}
|
|
|
|
export async function consume_vpn_tile_action(): Promise<VpnTileActionResponse> {
|
|
return await invoke<VpnTileActionResponse>('plugin:vpnservice|consume_vpn_tile_action', {})
|
|
}
|