UNPKG

wireguard-tools.js

Version:

Control your wireguard interface from node.js, not a wireguard-tools wrapper!

62 lines (61 loc) 2.28 kB
export declare const constants: { WG_B64_LENGTH: number; WG_LENGTH: number; MAX_NAME_LENGTH: number; driveVersion: string; }; export type WgConfig = { /** privateKey specifies a private key configuration */ privateKey?: string; /** publicKey specifies a public key configuration */ publicKey?: string; /** ListenPort specifies a device's listening port, 0 is random */ portListen?: number; /** FirewallMark specifies a device's firewall mark */ fwmark?: number; /** Interface IP address'es */ Address?: string[]; /** this option will remove all peers if `true` and add new peers */ replacePeers?: boolean; peers: { [peerPublicKey: string]: { /** Mark this peer to be removed, any changes remove this option */ removeMe?: boolean; /** Preshared key to peer */ presharedKey?: string; /** keepInterval specifies the persistent keepalive interval for this peer */ keepInterval?: number; /** Remote address or hostname to Wireguard connect or endpoint is the most recent source address used for communication by peer. */ endpoint?: string; /** ReceiveBytes indicates the number of bytes received from this peer. */ rxBytes?: number; /** TransmitBytes indicates the number of bytes transmitted to this peer. */ txBytes?: number; /** Last peer Handshake */ lastHandshake?: Date; /** AllowedIPs specifies a list of allowed IP addresses in CIDR notation (`0.0.0.0/0`, `::/0`) */ allowedIPs?: string[]; }; }; }; /** * Get Wireguard devices and locations */ export declare function listDevices(): Promise<{ from: "userspace" | "kernel"; name: string; path?: string; }[]>; export declare function deleteInterface(wgName: string): Promise<void>; /** * Set Wireguard config in interface * @param wgName - Interface name * @param config - Interface config */ export declare function setConfig(wgName: string, config: WgConfig): Promise<any>; /** * Get wireguard interface config * @param wgName - Interface name * @returns */ export declare function getConfig(wgName: string): Promise<any>;