Options
All
  • Public
  • Public/Protected
  • All
Menu

wireguard-tools

Index

Functions

Const checkWgIsInstalled

  • checkWgIsInstalled(): Promise<string>
  • Checks that Wireguard is installed and available in path at 'wg' and returns the version string.

    Will throw on Error if wg is not installed

    Returns Promise<string>

Const createPeerPairs

  • createPeerPairs(pairs: CreatePeerPairsOptions[]): void
  • Create peer pairs from more than one WgConfig object.

    Will add wgConfigs[0] as a peer in wgConfigs[1] and wgConfigs[1] as a peer in wgConfigs[0] etc. Will fail and error if

    Parameters

    • pairs: CreatePeerPairsOptions[]

    Returns void

Const generateConfigString

Const generateKeyPair

  • generateKeyPair(opts?: Options): Promise<{ preSharedKey: undefined | string; privateKey: string; publicKey: string }>
  • Generate a key pair using wg optionally also generate a PreSharedKey

    Parameters

    • Optional opts: Options

    Returns Promise<{ preSharedKey: undefined | string; privateKey: string; publicKey: string }>

Const getConfigObjectFromFile

  • getConfigObjectFromFile(opts: Options): Promise<Pick<WgConfigObject, "wgInterface" | "peers">>

Const getConfigStringFromFile

  • getConfigStringFromFile(opts: Options): Promise<string>

Const makeSureDirExists

  • makeSureDirExists(path: string): Promise<void>

Const makeSureFileExists

  • makeSureFileExists(path: string): Promise<void>

Const parseConfigString

  • parseConfigString(configString: string): Pick<WgConfigObject, "wgInterface" | "peers">
  • Parse a WireGuard config file (wg0.conf) into a WgConfig object for use in Javascript-land If no valid interface is found in the config, it will throw an error If a peer in the peers array is invalid, it will throw an error

    Parameters

    • configString: string

    Returns Pick<WgConfigObject, "wgInterface" | "peers">

Const writeConfig

  • writeConfig(opts: Options): Promise<void>
  • A helper for writing a config file using fs. Checks that the dir exists and creates it if not

    Parameters

    • opts: Options

    Returns Promise<void>

Generated using TypeDoc