gui use frontend-lib, fix memory leak (#467)

This commit is contained in:
Sijie.Sun
2024-11-10 23:03:40 +08:00
committed by GitHub
parent 88e6de9d7e
commit 4fc3ff8ce8
30 changed files with 868 additions and 2181 deletions

View File

@@ -1,6 +1,8 @@
import { addPluginListener } from '@tauri-apps/api/core'
import { prepare_vpn, start_vpn, stop_vpn } from 'tauri-plugin-vpnservice-api'
import type { Route } from '~/types/network'
import { NetworkTypes, Utils } from 'easytier-frontend-lib'
type Route = NetworkTypes.Route
const networkStore = useNetworkStore()
@@ -122,12 +124,17 @@ async function onNetworkInstanceChange() {
return
}
const virtual_ip = curNetworkInfo?.node_info?.virtual_ipv4
const virtual_ip = Utils.ipv4ToString(curNetworkInfo?.my_node_info?.virtual_ipv4.address)
if (!virtual_ip || !virtual_ip.length) {
await doStopVpn()
return
}
let network_length = curNetworkInfo?.my_node_info?.virtual_ipv4.network_length
if (!network_length) {
network_length = 24
}
const routes = getRoutesForVpn(curNetworkInfo?.routes)
const ipChanged = virtual_ip !== curVpnStatus.ipv4Addr

View File

@@ -1,6 +1,8 @@
import { invoke } from '@tauri-apps/api/core'
import { NetworkTypes } from 'easytier-frontend-lib'
import type { NetworkConfig, NetworkInstanceRunningInfo } from '~/types/network'
type NetworkConfig = NetworkTypes.NetworkConfig
type NetworkInstanceRunningInfo = NetworkTypes.NetworkInstanceRunningInfo
export async function parseNetworkConfig(cfg: NetworkConfig) {
return invoke<string>('parse_network_config', { cfg })

View File

@@ -1,15 +0,0 @@
import { IPv4, IPv6 } from 'ip-num/IPNumber'
import type { Ipv4Addr, Ipv6Addr } from '~/types/network'
export function num2ipv4(ip: Ipv4Addr) {
return IPv4.fromNumber(ip.addr)
}
export function num2ipv6(ip: Ipv6Addr) {
return IPv6.fromBigInt(
(BigInt(ip.part1) << BigInt(96))
+ (BigInt(ip.part2) << BigInt(64))
+ (BigInt(ip.part3) << BigInt(32))
+ BigInt(ip.part4),
)
}