@synet/net
Version:
Network abstraction layer for Synet. visit https://syntehtism.ai for more information.
52 lines (51 loc) • 2.13 kB
TypeScript
import type { ConfigurationRepository } from "../../domain/interfaces/configuration-repository.interface";
import type { InterfaceConfig, PeerConfig, WireguardInterface } from "../../domain/entities/wireguard";
import { Result } from "@synet/patterns";
import type { FileSystem } from "../filesystem/filesystem.interface";
import type { Logger } from "@synet/logger";
/**
* File-based implementation of ConfigurationRepository
* Saves and retrieves WireGuard configurations from .conf files
*/
export declare class FileConfigurationRepository implements ConfigurationRepository {
private readonly fileSystem;
private readonly configDir;
private readonly logger?;
constructor(fileSystem: FileSystem, configDir?: string, logger?: Logger | undefined);
private getConfigPath;
/**
* Parse a complete WireGuard configuration file
*/
private parseConfig;
/**
* Read and parse configuration file
*/
private readConfig;
/**
* Generate a complete WireGuard configuration file content
*/
private generateConfig;
/**
* Write configuration to file
*/
private writeConfig;
getInterfaceConfig(interfaceName: string): Promise<Result<InterfaceConfig | null>>;
saveInterfaceConfig(interfaceName: string, config: InterfaceConfig): Promise<Result<void>>;
/**
* Removes an entire interface configuration file
* @param interfaceName Name of the interface to remove
*/
removeInterfaceConfig(interfaceName: string): Promise<Result<void>>;
getPeers(interfaceName: string): Promise<Result<PeerConfig[]>>;
savePeer(interfaceName: string, newPeer: PeerConfig): Promise<Result<void>>;
removePeer(interfaceName: string, publicKey: string): Promise<Result<void>>;
getInterface(interfaceName: string): Promise<Result<WireguardInterface | null>>;
private parseInterfaceSection;
private parsePeerSections;
private generateInterfaceSection;
private generatePeerSection;
/**
* Remove all peers from an interface configuration
*/
removeAllPeers(interfaceName: string): Promise<Result<void>>;
}