committed by
GitHub
3 changed files with 45 additions and 9 deletions
@ -0,0 +1,14 @@ |
|||
export function convertIntToIpAddress(int: number): string { |
|||
return `${int & 0xff}.${(int >> 8) & 0xff}.${(int >> 16) & 0xff}.${(int >> 24) & 0xff}`; |
|||
} |
|||
|
|||
export function convertIpAddressToInt(ip: string): number | null { |
|||
return ( |
|||
ip |
|||
.split(".") |
|||
.reverse() |
|||
.reduce((ipnum, octet) => { |
|||
return (ipnum << 8) + Number.parseInt(octet); |
|||
}, 0) >>> 0 |
|||
); |
|||
} |
|||
Loading…
Reference in new issue