@synet/net
Version:
Network abstraction layer for Synet. visit https://syntehtism.ai for more information.
84 lines (83 loc) • 2.84 kB
TypeScript
/**
* Interface that defines the contract for WireGuard adapters
* With simplified error handling
*/
import type { Result } from "@synet/patterns";
import type { WireguardKeys, InterfaceConfig, PeerConfig, PeerStatus } from "../entities/wireguard";
export interface WireguardAdapter {
/**
* Get existing WireGuard keys
* @returns Result containing keys if found, null otherwise
*/
getKeys(): Promise<Result<WireguardKeys | null>>;
/**
* Generate new WireGuard keys
* @returns Result containing the new keys
*/
generateKeys(): Promise<Result<WireguardKeys>>;
/**
* Set up WireGuard interface with the given configuration
* @param config Interface configuration
* @returns Result indicating success or failure
*/
setInterface(config: InterfaceConfig): Promise<Result<void>>;
/**
* Remove the WireGuard interface
* @returns Result indicating success or failure
*/
removeInterface(): Promise<Result<void>>;
/**
* Remove all peers from the WireGuard interface
* @returns Result indicating success or failure
*/
removeAllPeers(): Promise<Result<void>>;
/**
* Reload the WireGuard configuration
* @returns Result indicating success or failure
*/
reload(): Promise<Result<void>>;
/**
*
* Add a peer to the WireGuard interface
* @param config Peer configuration
* @returns Result indicating success or failure
*/
addPeer(config: PeerConfig): Promise<Result<void>>;
/**
* Remove a peer from the WireGuard interface
* @param publicKey Public key of the peer to remove
* @returns Result indicating success or failure
*/
removePeer(publicKey: string): Promise<Result<void>>;
/**
* Bring up the WireGuard interface
* @returns Result indicating success or failure
*/
bringUp(): Promise<Result<void>>;
/**
* Bring down the WireGuard interface
* @returns Result indicating success or failure
*/
bringDown(): Promise<Result<void>>;
/**
* Get the status of the WireGuard interface
* @returns Result containing the status information
*/
status: () => Promise<Result<void>>;
/**
* Get the status of a specific peer
* @param publicKey Public key of the peer
* @returns Result containing the peer status information
*/
peerStatus: (publickKey: string) => Promise<Result<PeerStatus | null>>;
/**
* List all peers in the WireGuard interface
* @returns Result containing an array of peers
*/
listPeers(): Promise<Result<PeerStatus[] | null>>;
/**
* Get the public key of the WireGuard interface
* @returns Result containing the public key if found, null otherwise
*/
getInterfaceName?(): Promise<Result<string>>;
}