UNPKG

wireguard-tools.js

Version:

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

61 lines (60 loc) 1.89 kB
/// <reference types="node" /> import { WgConfig } from "./wginterface"; export interface QuickConfig extends WgConfig { DNS?: string[]; } export declare function parse(config: string | Buffer): QuickConfig; export declare function stringify({ portListen, privateKey, publicKey, Address, DNS, peers }: QuickConfig): string; /** * Create and Manipulate interface Configs */ export declare class WgQuick extends Map<string, QuickConfig["peers"][string]> { private _privateKey; /** * Set private key to interface */ set privateKey(key: string); /** * Get private key from interface config */ get privateKey(): string | undefined; private _publicKey; /** * Set public key to interface */ set publicKey(key: string); /** * Get public key from interface config */ get publicKey(): string | undefined; private _portListen; /** Get port to listen, 0 less a 65535 */ set portListen(port: number); get portListen(): number; private _Address; get Address(): string[]; set Address(addr: string[]); private _DNS; get DNS(): string[]; set DNS(dns: string[]); constructor(config?: QuickConfig); /** * Generate peer base keys and return public key to set remaining of config's. * @param preshareKey - Generate peer with Preshared key */ set(preshareKey?: boolean): Promise<string>; /** * Generate keys and return Promise with all Public keys generated * @param keys - Keys to generate * @param preshareKey - Peers with preshared key */ set(keys: number, preshareKey?: boolean): Promise<string[]>; /** * Set peer config * @param key - Peer public key * @param value - Peer config */ set(key: string, value: QuickConfig["peers"][string]): this; toJSON(): QuickConfig; toString(): string; }