/** * Wireguard peer schema definitions * * @since 1.0.0 */ import type * as Brand from "effect/Brand"; import * as InternetSchemas from "effect-schemas/Internet"; import * as Duration from "effect/Duration"; import * as Effect from "effect/Effect"; import * as Option from "effect/Option"; import * as Schema from "effect/Schema"; import * as WireguardInternetSchemas from "./InternetSchemas.ts"; declare const WireguardPeer_base: import("@effect/experimental/VariantSchema").Class; /** * The collection of IPs/masks that will be accepted from this peer. If an * identical value already exists as part of a prior peer, the allowed IP * entry will be removed from that peer and added to this peer. */ readonly AllowedIPs: Schema.optionalWith, { nullable: true; default: () => Set; }>; /** * The value for this key is either IP:port for IPv4 or [IP]:port for IPv6 * or some.hostname.com:port for a hostname endpoint. The endpoint is * optional and, if not supplied, the remote peer must connect first (so * they should have the endpoint set to know where to connect to) and this * client will just send requests back to the remote peer's source IP and * port. */ readonly Endpoint: Schema.optionalWith; /** Lowercase hex-encoded public key of the new peer entry. */ readonly PublicKey: Schema.brand, "WireguardKey">; /** * The preshared key is optional and is a lowercase hex-encoded key. The * value may be an all zero string in the case of a set operation, in which * case it indicates that the preshared-key should be removed. */ readonly PresharedKey: Schema.optionalWith, "WireguardKey">, { nullable: true; as: "Option"; }>; /** The number of received bytes. */ readonly rxBytes: import("@effect/experimental/VariantSchema").Field<{ readonly uapi: typeof Schema.NumberFromString; }>; /** The number of transmitted bytes. */ readonly txBytes: import("@effect/experimental/VariantSchema").Field<{ readonly uapi: typeof Schema.NumberFromString; }>; /** * The number of seconds since the most recent handshake, expressed relative * to the Unix epoch. */ readonly lastHandshake: import("@effect/experimental/VariantSchema").Field<{ readonly uapi: Schema.transform>, typeof Schema.DateTimeUtcFromNumber>; }>; }, import("@effect/experimental/VariantSchema").ExtractFields<"json", { /** * The persistent keepalive interval in seconds, 0 disables it. The * difference between Option.none and Option.some(0) is important when * performing something like a config update operation on an interface * because Option.none will not include the keep alive setting in the update * request, so it will remain the same as it was before the update, whereas * Option.some(0) will disable the keep alive setting. */ readonly PersistentKeepalive: Schema.optionalWith; /** * The collection of IPs/masks that will be accepted from this peer. If an * identical value already exists as part of a prior peer, the allowed IP * entry will be removed from that peer and added to this peer. */ readonly AllowedIPs: Schema.optionalWith, { nullable: true; default: () => Set; }>; /** * The value for this key is either IP:port for IPv4 or [IP]:port for IPv6 * or some.hostname.com:port for a hostname endpoint. The endpoint is * optional and, if not supplied, the remote peer must connect first (so * they should have the endpoint set to know where to connect to) and this * client will just send requests back to the remote peer's source IP and * port. */ readonly Endpoint: Schema.optionalWith; /** Lowercase hex-encoded public key of the new peer entry. */ readonly PublicKey: Schema.brand, "WireguardKey">; /** * The preshared key is optional and is a lowercase hex-encoded key. The * value may be an all zero string in the case of a set operation, in which * case it indicates that the preshared-key should be removed. */ readonly PresharedKey: Schema.optionalWith, "WireguardKey">, { nullable: true; as: "Option"; }>; /** The number of received bytes. */ readonly rxBytes: import("@effect/experimental/VariantSchema").Field<{ readonly uapi: typeof Schema.NumberFromString; }>; /** The number of transmitted bytes. */ readonly txBytes: import("@effect/experimental/VariantSchema").Field<{ readonly uapi: typeof Schema.NumberFromString; }>; /** * The number of seconds since the most recent handshake, expressed relative * to the Unix epoch. */ readonly lastHandshake: import("@effect/experimental/VariantSchema").Field<{ readonly uapi: Schema.transform>, typeof Schema.DateTimeUtcFromNumber>; }>; }, true>, { readonly Endpoint?: { readonly natPort: number & Brand.Brand<"Port">; readonly listenPort: number & Brand.Brand<"Port">; readonly address: { readonly ip: string & Brand.Brand<"IPv4">; readonly family: "ipv4"; }; } | { readonly natPort: number & Brand.Brand<"Port">; readonly listenPort: number & Brand.Brand<"Port">; readonly address: { readonly ip: string & Brand.Brand<"IPv6">; readonly family: "ipv6"; }; } | { readonly natPort: number & Brand.Brand<"Port">; readonly listenPort: number & Brand.Brand<"Port">; readonly host: string; } | undefined; } & { readonly PersistentKeepalive: Option.Option; } & { readonly AllowedIPs: ReadonlySet; } & { readonly PublicKey: string & Brand.Brand<"WireguardKey">; } & { readonly PresharedKey: Option.Option>; }, Schema.Struct.Encoded; /** * The collection of IPs/masks that will be accepted from this peer. If an * identical value already exists as part of a prior peer, the allowed IP * entry will be removed from that peer and added to this peer. */ readonly AllowedIPs: Schema.optionalWith, { nullable: true; default: () => Set; }>; /** * The value for this key is either IP:port for IPv4 or [IP]:port for IPv6 * or some.hostname.com:port for a hostname endpoint. The endpoint is * optional and, if not supplied, the remote peer must connect first (so * they should have the endpoint set to know where to connect to) and this * client will just send requests back to the remote peer's source IP and * port. */ readonly Endpoint: Schema.optionalWith; /** Lowercase hex-encoded public key of the new peer entry. */ readonly PublicKey: Schema.brand, "WireguardKey">; /** * The preshared key is optional and is a lowercase hex-encoded key. The * value may be an all zero string in the case of a set operation, in which * case it indicates that the preshared-key should be removed. */ readonly PresharedKey: Schema.optionalWith, "WireguardKey">, { nullable: true; as: "Option"; }>; /** The number of received bytes. */ readonly rxBytes: import("@effect/experimental/VariantSchema").Field<{ readonly uapi: typeof Schema.NumberFromString; }>; /** The number of transmitted bytes. */ readonly txBytes: import("@effect/experimental/VariantSchema").Field<{ readonly uapi: typeof Schema.NumberFromString; }>; /** * The number of seconds since the most recent handshake, expressed relative * to the Unix epoch. */ readonly lastHandshake: import("@effect/experimental/VariantSchema").Field<{ readonly uapi: Schema.transform>, typeof Schema.DateTimeUtcFromNumber>; }>; }, true>>, never, { readonly Endpoint?: { readonly natPort: number & Brand.Brand<"Port">; readonly listenPort: number & Brand.Brand<"Port">; readonly address: { readonly ip: string & Brand.Brand<"IPv4">; readonly family: "ipv4"; }; } | { readonly natPort: number & Brand.Brand<"Port">; readonly listenPort: number & Brand.Brand<"Port">; readonly address: { readonly ip: string & Brand.Brand<"IPv6">; readonly family: "ipv6"; }; } | { readonly natPort: number & Brand.Brand<"Port">; readonly listenPort: number & Brand.Brand<"Port">; readonly host: string; } | undefined; } & { readonly PersistentKeepalive: Option.Option; } & { readonly AllowedIPs?: ReadonlySet; } & { readonly PublicKey: string & Brand.Brand<"WireguardKey">; } & { readonly PresharedKey: Option.Option>; }> & { readonly json: Schema.Struct<{ readonly PersistentKeepalive: Schema.optionalWith; readonly AllowedIPs: Schema.optionalWith, { nullable: true; default: () => Set; }>; readonly Endpoint: Schema.optionalWith; readonly PublicKey: Schema.brand, "WireguardKey">; readonly PresharedKey: Schema.optionalWith, "WireguardKey">, { nullable: true; as: "Option"; }>; }>; readonly uapi: Schema.Struct<{ readonly PersistentKeepalive: Schema.optionalWith; readonly AllowedIPs: Schema.optionalWith, { nullable: true; default: () => Set; }>; readonly Endpoint: Schema.optionalWith; readonly PublicKey: Schema.brand, "WireguardKey">; readonly PresharedKey: Schema.optionalWith, "WireguardKey">, { nullable: true; as: "Option"; }>; readonly rxBytes: typeof Schema.NumberFromString; readonly txBytes: typeof Schema.NumberFromString; readonly lastHandshake: Schema.transform>, typeof Schema.DateTimeUtcFromNumber>; }>; }; /** * A wireguard peer configuration. * * @since 1.0.0 * @category Datatypes * @example * ```ts * * 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, * }); * ```; */ export declare class WireguardPeer extends WireguardPeer_base { } declare const WireguardIniPeer_base: Schema.transformOrFail; /** * A wireguard peer configuration encoded in INI format. * * @since 1.0.0 * @category Transformations * @example * ```ts * * 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 {@link WireguardPeer} */ export declare class WireguardIniPeer extends WireguardIniPeer_base { } declare const WireguardUapiSetPeer_base: Schema.transformOrFail; /** * @since 1.0.0 * @category Schemas * @see https://www.wireguard.com/xplatform/ */ export declare class WireguardUapiSetPeer extends WireguardUapiSetPeer_base { } declare const WireguardUapiGetPeer_base: Schema.transformOrFail; readonly AllowedIPs: Schema.optionalWith, { nullable: true; default: () => Set; }>; readonly Endpoint: Schema.optionalWith; readonly PublicKey: Schema.brand, "WireguardKey">; readonly PresharedKey: Schema.optionalWith, "WireguardKey">, { nullable: true; as: "Option"; }>; readonly rxBytes: typeof Schema.NumberFromString; readonly txBytes: typeof Schema.NumberFromString; readonly lastHandshake: Schema.transform>, typeof Schema.DateTimeUtcFromNumber>; }>, never>; /** * @since 1.0.0 * @category Schemas * @see https://www.wireguard.com/xplatform/ */ export declare class WireguardUapiGetPeer extends WireguardUapiGetPeer_base { } /** * @since 1.0.0 * @category Refinements */ export declare const hasBidirectionalTraffic: (wireguardPeer: Schema.Schema.Type<(typeof WireguardPeer)["uapi"]>) => Effect.Effect; /** * @since 1.0.0 * @category Refinements */ export declare const hasHandshakedRecently: (wireguardPeer: Schema.Schema.Type<(typeof WireguardPeer)["uapi"]>) => Effect.Effect; export {}; //# sourceMappingURL=WireguardPeer.d.ts.map