0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 09:31:22 -05:00

feat: stabilize Deno.networkInterfaces() (#16451)

This commit is contained in:
Colin Ihrig 2022-11-09 07:29:24 -05:00 committed by GitHub
parent 9edcab524f
commit f946806868
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 41 deletions

View file

@ -332,6 +332,43 @@ declare namespace Deno {
*/
export function loadavg(): number[];
/**
* The information for a network interface returned from a call to
* {@linkcode Deno.networkInterfaces}.
*
* @category Network
*/
export interface NetworkInterfaceInfo {
/** The network interface name. */
name: string;
/** The IP protocol version. */
family: "IPv4" | "IPv6";
/** The IP address bound to the interface. */
address: string;
/** The netmask applied to the interface. */
netmask: string;
/** The IPv6 scope id or `null`. */
scopeid: number | null;
/** The CIDR range. */
cidr: string;
/** The MAC address. */
mac: string;
}
/**
* Returns an array of the network interface information.
*
* ```ts
* console.log(Deno.networkInterfaces());
* ```
*
* Requires `allow-sys` permission.
*
* @tags allow-sys
* @category Network
*/
export function networkInterfaces(): NetworkInterfaceInfo[];
/** Reflects the `NO_COLOR` environment variable at program start.
*
* When the value is `true`, the Deno CLI will attempt to not send color codes

View file

@ -314,45 +314,6 @@ declare namespace Deno {
swapFree: number;
}
/** **UNSTABLE**: New API, yet to be vetted.
*
* The information for a network interface returned from a call to
* {@linkcode Deno.networkInterfaces}.
*
* @category Network
*/
export interface NetworkInterfaceInfo {
/** The network interface name. */
name: string;
/** The IP protocol version. */
family: "IPv4" | "IPv6";
/** The IP address bound to the interface. */
address: string;
/** The netmask applied to the interface. */
netmask: string;
/** The IPv6 scope id or `null`. */
scopeid: number | null;
/** The CIDR range. */
cidr: string;
/** The MAC address. */
mac: string;
}
/** **UNSTABLE**: New API, yet to be vetted.
*
* Returns an array of the network interface information.
*
* ```ts
* console.log(Deno.networkInterfaces());
* ```
*
* Requires `allow-sys` permission.
*
* @tags allow-sys
* @category Network
*/
export function networkInterfaces(): NetworkInterfaceInfo[];
/** **UNSTABLE**: New API, yet to be vetted.
*
* Returns the user id of the Deno process on POSIX platforms. Returns `null`

View file

@ -121,13 +121,13 @@
unrefTimer: __bootstrap.timers.unrefTimer,
osRelease: __bootstrap.os.osRelease,
hostname: __bootstrap.os.hostname,
networkInterfaces: __bootstrap.os.networkInterfaces,
consoleSize: __bootstrap.tty.consoleSize,
};
__bootstrap.denoNsUnstable = {
DiagnosticCategory: __bootstrap.diagnostics.DiagnosticCategory,
systemMemoryInfo: __bootstrap.os.systemMemoryInfo,
networkInterfaces: __bootstrap.os.networkInterfaces,
gid: __bootstrap.os.gid,
uid: __bootstrap.os.uid,
listenDatagram: __bootstrap.net.listenDatagram,

View file

@ -190,7 +190,6 @@ fn op_os_release(state: &mut OpState) -> Result<String, AnyError> {
fn op_network_interfaces(
state: &mut OpState,
) -> Result<Vec<NetworkInterface>, AnyError> {
super::check_unstable(state, "Deno.networkInterfaces");
state
.borrow_mut::<Permissions>()
.sys