@synet/net
Version:
Network abstraction layer for Synet. visit https://syntehtism.ai for more information.
82 lines (81 loc) • 2.5 kB
TypeScript
/**
* Main service for managing WireGuard operations
* Implements simplified error handling
*/
import type { Logger } from "@synet/logger";
import type { WireguardAdapter } from "../../domain/interfaces/wireguard-adapter.interface";
import type { WireguardKeys, InterfaceConfig, PeerConfig, PeerStatus } from "../../domain/entities/wireguard";
import type { Result } from "@synet/patterns";
export declare class WireguardService {
private readonly adapter;
private readonly logger?;
/**
* Creates a new instance of WireGuardService
* @param adapter The WireGuard adapter implementation to use
* @param logger Optional logger instance
*/
constructor(adapter: WireguardAdapter, logger?: Logger | undefined);
/**
* Get existing WireGuard keys
*/
getKeys(): Promise<Result<WireguardKeys | null>>;
/**
* Generate new WireGuard keys
*/
generateKeys(): Promise<Result<WireguardKeys>>;
/**
* Set up WireGuard interface
*/
setInterface(config: InterfaceConfig): Promise<Result<void>>;
/**
* Add a peer to the WireGuard interface
*/
addPeer(config: PeerConfig): Promise<Result<void>>;
removeInterface(): Promise<Result<void>>;
reloadInterface(): Promise<Result<void>>;
/**
* Remove a peer from the WireGuard interface
*/
destroy(): Promise<Result<void>>;
/**
* Remove a peer from the WireGuard interface
*/
removePeer(publicKey: string): Promise<Result<void>>;
/**
* Remove a peer from the WireGuard interface
*/
removeAllPeers(): Promise<Result<void>>;
/**
* Bring up the WireGuard interface
*/
bringUp(): Promise<Result<void>>;
/**
* Bring down the WireGuard interface
*/
bringDown(): Promise<Result<void>>;
/**
* Convenience method to configure and connect in one go
*/
connect(config: {
privateKey: string;
address: string;
peer: PeerConfig;
}): Promise<Result<void>>;
/**
* Convenience method to disconnect
*/
disconnect(peerPublicKey: string): Promise<Result<void>>;
status(): Promise<Result<void>>;
/**
* Get peer status
* @returns Result<void>
*/
peerStatus(publicKey: string): Promise<Result<PeerStatus | null>>;
listPeers(): Promise<Result<PeerStatus[] | null>>;
/**
* Remove all peers from the WireGuard interface
*/
private logInfo;
private logWarn;
private logError;
}