# @vercel/wireguard

Wireguard client packaged as an npm module.

## Usage

> **Note**
> This package currently only supports the Linux platform as it is intended to be used in Vercel Serverless Functions.

**Import**

```typescript
import { wireguard } from '@vercel/wireguard';
```

**`socks-proxy-agent`**

```typescript
import { SocksProxyAgent } from 'socks-proxy-agent';

const proxy = await wireguard();
const agent = new SocksProxyAgent();
```

**Configuration**

All properties are optional, the following values are the defaults.

```typescript
/**
 * The return value is the local proxy URL, which in this case
 * would be `socks5://localhost:25344`.
 */
const proxy = await wireguard({
  /**
   * The client configuration, this is
   * used to specify options for the local proxy server.
   */
  client: {
    /**
     * The local port on which to expose the proxy.
     */
    port: 25344,

    /**
     * The private key to use when handshaking with
     * the remote Wireguard server.
     */
    privateKey: process.env.WIREGUARD_CLIENT_PRIVATE_KEY
  },

  /**
   * The path where the generated Wireguard configuration
   * file should be written.
   */
  configuration: '/tmp/wireguard.conf',

  /**
   * The server configuration, this is
   * used to specify options for the remote
   * Wireguard server.
   */
  server: {
    /**
     * The host of the remote Wireguard server, can be
     * and IP address or a DNS name.
     */
    host: process.env.WIREGUARD_SERVER_HOST,

    /**
     * The port on which the remote Wireguard server is
     * listening on.
     */
    port: 4343,

    /**
     * The public key of the remote Wireguard server, used
     * when handshaking.
     */
    publicKey: process.env.WIREGUARD_SERVER_PUBLIC_KEY,
  }
});
```
