Files
amnezia-client/ipc/ipc.h
T

55 lines
1.1 KiB
C++
Raw Normal View History

2021-02-02 01:47:40 +03:00
#ifndef IPC_H
#define IPC_H
2021-02-03 15:42:36 +03:00
#include <QObject>
2021-02-02 01:47:40 +03:00
#include <QString>
2022-10-15 19:46:26 +03:00
#include "../client/utilities.h"
2022-08-10 22:15:00 +03:00
2021-02-02 01:47:40 +03:00
#define IPC_SERVICE_URL "local:AmneziaVpnIpcInterface"
namespace amnezia {
2021-02-03 15:42:36 +03:00
2022-08-10 22:15:00 +03:00
enum PermittedProcess {
OpenVPN,
Wireguard,
2024-03-27 11:02:34 +00:00
Tun2Socks,
2022-08-10 22:15:00 +03:00
CertUtil
};
inline QString permittedProcessPath(PermittedProcess pid)
{
if (pid == PermittedProcess::OpenVPN) {
return Utils::openVpnExecPath();
} else if (pid == PermittedProcess::Wireguard) {
2022-08-10 22:15:00 +03:00
return Utils::wireguardExecPath();
} else if (pid == PermittedProcess::CertUtil) {
2022-08-10 22:15:00 +03:00
return Utils::certUtilPath();
2024-03-27 11:02:34 +00:00
} else if (pid == PermittedProcess::Tun2Socks) {
return Utils::tun2socksPath();
2022-08-10 22:15:00 +03:00
}
return "";
2022-08-10 22:15:00 +03:00
}
2021-02-03 15:42:36 +03:00
inline QString getIpcServiceUrl() {
#ifdef Q_OS_WIN
return IPC_SERVICE_URL;
#else
return QString("/tmp/%1").arg(IPC_SERVICE_URL);
#endif
}
inline QString getIpcProcessUrl(int pid) {
#ifdef Q_OS_WIN
return QString("%1_%2").arg(IPC_SERVICE_URL).arg(pid);
#else
return QString("/tmp/%1_%2").arg(IPC_SERVICE_URL).arg(pid);
#endif
2021-02-02 01:47:40 +03:00
}
2021-02-03 15:42:36 +03:00
} // namespace amnezia
2021-02-02 01:47:40 +03:00
#endif // IPC_H