/*
* Copyright (c) 2025 Proton AG
*
* This file is part of ProtonVPN.
*
* ProtonVPN is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ProtonVPN is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ProtonVPN. If not, see .
*/
using System.IO;
using System.Net.Sockets;
using System.Threading;
using System.Threading.Tasks;
namespace ProtonVPN.Vpn.Management;
///
/// Interface to OpenVPN management interface.
///
public interface IManagementChannel
{
///
/// Connects to OpenVPN management interface using specified TCP port.
///
/// TCP port OpenVPN process is listening on.
/// Thrown if failed to connect to OpenVPN management socket.
Task Connect(int port);
///
/// Writes message to OpenVPN management interface.
///
/// Message to write.
/// Thrown if failed to write to OpenVPN management socket.
Task WriteLineAsync(string message, CancellationToken cancellationToken);
///
/// Reads current message from the OpenVPN management interface.
/// Returns NULL on the end of stream.
///
/// Current message. NULL if end of stream reached.
/// Thrown if failed to read from OpenVPN management socket.
Task ReadLineAsync(CancellationToken cancellationToken);
///
/// Disconnect from OpenVPN management interface.
///
void Disconnect();
}