/// import { BaseObject, StreamData } from '../structs'; export declare enum Commands { GET_DEVICE = 1, SET_DEVICE = 2 } export interface DeviceFlags { /** all current peers should be removed prior to adding the list below */ replacePeers?: true; __unknown?: number; } /** Parses the flags in a {@link DeviceFlags} bitmask */ export declare function parseDeviceFlags(r: number): DeviceFlags; /** Encodes a {@link DeviceFlags} bitmask */ export declare function formatDeviceFlags(x: DeviceFlags): number; /** exactly one of `ifindex` and `ifname` must be specified */ export interface Device extends BaseObject { ifindex?: number; ifname?: string; /** * exact length WG_KEY_LEN. * for SET_DEVICE, pass all zeros to remove. */ privateKey?: Buffer; /** [GET_DEVICE only] exact length WG_KEY_LEN. */ publicKey?: Buffer; /** [SET_DEVICE only] */ flags?: DeviceFlags; /** pass 0 to choose randomly. */ listenPort?: number; /** pass 0 to disable. */ fwmark?: number; peers?: Peer[]; } /** Parses the attributes of a {@link Device} object */ export declare function parseDevice(r: Buffer): Device; /** Encodes a {@link Device} object into a stream of attributes */ export declare function formatDevice(x: Device): StreamData; export interface PeerFlags { /** * the specified peer should not exist at the end of the operation, * rather than added/updated */ removeMe?: true; /** all current allowed IPs of this peer should be removed prior to adding `allowedIps` */ replaceAllowedIps?: true; /** the peer should only be set if it already exists */ updateOnly?: true; __unknown?: number; } /** Parses the flags in a {@link PeerFlags} bitmask */ export declare function parsePeerFlags(r: number): PeerFlags; /** Encodes a {@link PeerFlags} bitmask */ export declare function formatPeerFlags(x: PeerFlags): number; export interface Peer extends BaseObject { /** exact len WG_KEY_LEN. */ publicKey?: Buffer; /** exact len WG_KEY_LEN, pass all zeros to remove. */ presharedKey?: Buffer; /** [SET_DEVICE only] */ flags?: PeerFlags; /** struct sockaddr_in or struct sockaddr_in6 */ endpoint?: Buffer; /** pass 0 to disable. */ persistentKeepaliveInterval?: number; /** [GET_DEVICE only] struct __kernel_timespec */ lastHandshakeTime?: Buffer; /** [GET_DEVICE only] */ rxBytes?: bigint; /** [GET_DEVICE only] */ txBytes?: bigint; allowedIps?: AllowedIp[]; /** * should not be set or used at all by most users of this API, as the * most recent protocol will be used when this is unset. Otherwise, * must be set to 1. */ protocolVersion?: number; } /** Parses the attributes of a {@link Peer} object */ export declare function parsePeer(r: Buffer): Peer; /** Encodes a {@link Peer} object into a stream of attributes */ export declare function formatPeer(x: Peer): StreamData; export interface AllowedIp extends BaseObject { family?: number; /** struct in_addr or struct in6_addr */ ipaddr?: Buffer; cidrMask?: number; } /** Parses the attributes of a {@link AllowedIp} object */ export declare function parseAllowedIp(r: Buffer): AllowedIp; /** Encodes a {@link AllowedIp} object into a stream of attributes */ export declare function formatAllowedIp(x: AllowedIp): StreamData;