Skip to main content Link Search Menu Expand Document (external link)

WireguardPeer.ts overview

Wireguard peer schema definitions

Since v1.0.0


Exports Grouped by Category


Datatypes

WireguardPeer (class)

A wireguard peer configuration.

Example


    import * as Schema from "effect/Schema";
    import * as WireguardKey from "the-wireguard-effect/WireguardKey";

    import { WireguardPeer } from "the-wireguard-effect/WireguardPeer";

    const preshareKey = WireguardKey.generatePreshareKey();
    const { publicKey, privateKey: _privateKey } =
        WireguardKey.generateKeyPair();

    const peerSchemaInstantiation = Schema.decode(WireguardPeer)({
        PublicKey: publicKey,
        PresharedKey: preshareKey,
        Endpoint: "192.168.0.1:51820",
        AllowedIPs: new Set(["192.168.0.0/24"]),
        PersistentKeepalive: 20,
    });
    ```;

**Signature**

```ts
declare class WireguardPeer

Source

Since v1.0.0

Refinements

hasBidirectionalTraffic

Signature

declare const hasBidirectionalTraffic: (
  wireguardPeer: Schema.Schema.Type<(typeof WireguardPeer)["uapi"]>
) => Effect.Effect<boolean, never, never>

Source

Since v1.0.0

hasHandshakedRecently

Signature

declare const hasHandshakedRecently: (
  wireguardPeer: Schema.Schema.Type<(typeof WireguardPeer)["uapi"]>
) => Effect.Effect<boolean, never, never>

Source

Since v1.0.0

Schemas

WireguardUapiGetPeer (class)

See

  • https://www.wireguard.com/xplatform/

Signature

declare class WireguardUapiGetPeer

Source

Since v1.0.0

WireguardUapiSetPeer (class)

See

  • https://www.wireguard.com/xplatform/

Signature

declare class WireguardUapiSetPeer

Source

Since v1.0.0

Transformations

WireguardIniPeer (class)

A wireguard peer configuration encoded in INI format.

Example


    import * as Effect from "effect/Effect";
    import * as Function from "effect/Function";
    import * as Schema from "effect/Schema";
    import * as WireguardKey from "the-wireguard-effect/WireguardKey";
    import * as WireguardPeer from "the-wireguard-effect/WireguardPeer";

    const preshareKey = WireguardKey.generatePreshareKey();
    const { publicKey, privateKey: _privateKey } =
        WireguardKey.generateKeyPair();

    const peer = Schema.decode(WireguardPeer.WireguardPeer)({
        PublicKey: publicKey,
        PresharedKey: preshareKey,
        AllowedIPs: new Set(["192.168.0.0/24"]),
        Endpoint: "192.168.0.1:51820",
        PersistentKeepalive: 20,
    });

    const iniPeer = Function.pipe(
        peer,
        Effect.flatMap(Schema.encode(WireguardPeer.WireguardPeer)),
        Effect.flatMap(Schema.decode(WireguardPeer.WireguardIniPeer))
    );
    ```;

**See**

- `WireguardPeer`

**Signature**

```ts
declare class WireguardIniPeer

Source

Since v1.0.0