asusroutermonitor
Version:
A library to interact with your ASUS router.
225 lines (224 loc) • 6 kB
TypeScript
import { HeadersInit } from 'node-fetch';
type UptimeResponse = {
since: Date;
uptime: number;
};
type MemoryUsage = {
mem_total: number;
mem_free: number;
mem_used: number;
};
type CPUUsage = {
cpu1_total: number;
cpu1_usage: number;
cpu2_total: number;
cpu2_usage: number;
};
declare enum ClientType {
DEVICE = 0,
UNK_1 = 1,
UNK_7 = 7,
UNK_18 = 18,
LINUX = 22,
ROUTER = 24,
UNK_34 = 34
}
declare enum IPMethod {
STATIC = "Manual",
DHCP = "Dhcp",
MANUAL = "Manual",
OFFLINE = "Offline"
}
declare enum OPMode {
NONE = 0,
WIRELESS_ROUTER = 1,
OP_RE_ITEM = 2,
OP_AP_ITEM = 3,
OP_MB_ITME = 4
}
declare enum WirelessBand {
None = 0,
"2_4GHZ" = 1,
"5GHZ" = 2
}
declare enum InternetMode {
ALLOW = "allow",
BLOCK = "block",
TIME = "time"
}
type ClientInfo = {
type: ClientType;
defaultType: ClientType;
name: string;
nickName: string;
ip: string;
mac: string;
from: string;
macRepeat: boolean;
isGateway: boolean;
isWebServer: boolean;
isPrinter: boolean;
isITunes: boolean;
dpiType: string;
dpiDevice: string;
vendor: string;
isWL: WirelessBand;
isGN: string;
isOnline: boolean;
ssid: string;
isLogin: boolean;
opMode: OPMode;
rssi: number;
curTx: number;
curRx: number;
totalTx: number;
totalRx: number;
wlConnectTime: string;
ipMethod: IPMethod;
ROG: boolean;
group: string;
callback: string;
keeparp: string;
qosLevel: string;
wtFast: boolean;
internetMode: InternetMode;
internetState: number;
amesh_isReClient: boolean;
amesh_papMac: string;
amesh_bind_mac: string;
amesh_bind_band: number;
};
type ClientFullInfo = {
clientList: ClientInfo[];
macList: string[];
clientAPILevel: number;
};
type Traffic = {
sent: number;
recv: number;
};
type WanStatus = {
status: number;
statusstr: string;
type: string;
ipaddr: string;
netmask: string;
gateway: string;
dns: string;
lease: number;
expires: number;
xtype: string;
xipaddr: string;
xnetmask: string;
xexpires: string;
};
type DHCPEntry = {
mac: string;
name: string;
};
export declare class RouterInfo {
url: string;
ip: string;
headers: HeadersInit | null;
/**
* Create the object and connect with the router
* @param {string} ip Router IP Address
*/
constructor(ip: string);
/**
* Authenticate with the router
* @param {string} ip Router IP Address
* @param {string} username Root username
* @param {string} password Root password
* @returns {boolean} Whether authentication was successful.
*/
authenticate(username: string, password: string): Promise<boolean>;
/**
* Private get method to execute a hook on the router and return the result
* @param {string} command Command to send to the router
* @returns {string|null} String result from the router or null
*/
private get;
/**
* Gets uptime of the router
* @returns {UptimeResponse|null} an object with since and uptime, or null.
*/
getUptime(): Promise<UptimeResponse | null>;
/**
* Get the uptime of the router in seconds
* @returns {number} Uptime in seconds
*/
getUptimeSecs(): Promise<number | null>;
/**
* Gets the memory usage of the router
* @returns {MemoryUsage|null} Memory usage in bytes or null
*/
getMemoryUsage(): Promise<MemoryUsage | null>;
/**
* Gets the CPU usage of the router
* @returns {CPUUsage|null} CPU usage or null
*/
getCPUUsage(): Promise<CPUUsage | null>;
/**
* Gets a full list of client information as well as the connected mac addresses and client api level.
* @returns {ClientFullInfo|null} List of client information or null
*/
getClientsFullInfo(): Promise<ClientFullInfo | null>;
/**
* Gets the total traffic since last restart in Megabits
* @returns {Traffic|null} Sent and received Megabits since last boot or null
*/
getTotalTraffic(): Promise<Traffic | null>;
/**
* Averages the network traffic over 2 seconds in Megabits
* @returns {Traffic|null} Current network traffic in Mbit/s
*/
getTraffic(): Promise<Traffic | null>;
/**
* Gets the status of the current WAN link
* @returns {WanStatus|null} Status information about the currnet WAN link or null
*/
getWanStatus(): Promise<WanStatus | null>;
/**
* Checks if the WAN link is connected
* @returns {boolean|null} Whether the WAN link is connected or null
*/
isWanOnline(): Promise<boolean | null>;
/**
* Gets the routers current settings
* @returns {Settings} The router settings
*/
getSettings(): Promise<any>;
/**
* Gets the IP address of the router
* @returns The IP address of the router
*/
getLanIPAddress(): Promise<string | null>;
/**
* Gets the netmask of the router
* @returns {string|null} Router netmask or null
*/
getLanNetmask(): Promise<string | null>;
/**
* Gets the ip address of the gateway for the LAN network
* @returns {string|null} IP address of the gateway
*/
getLanGateway(): Promise<string | null>;
/**
* Gets a list of DHCP leases
* @returns {DHCPEntry[]|null} List of DHCP entries or null
*/
getDHCPList(): Promise<DHCPEntry[] | null>;
/**
* Gets info on all currently online clients
* @returns {ClientInfo[]|null} Client info on all online clients or null
*/
getOnlineClients(): Promise<ClientInfo[] | null>;
/**
* Gets info on a single client
* @param clientMac MAC address of the requested client
* @returns {ClientInfo|null} The client info or null
*/
getClientInfo(clientMac: string): Promise<ClientInfo | null>;
}
export {};