mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-10-09 20:26:15 -08:00
support basic functions in frontend 1. create/del network 2. inspect network running status
16 lines
412 B
TypeScript
16 lines
412 B
TypeScript
import { IPv4, IPv6 } from 'ip-num/IPNumber'
|
|
import { 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),
|
|
)
|
|
}
|