mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-24 02:00:24 +07:00
feat: linux <-> conan features
This commit is contained in:
+11
-3
@@ -231,12 +231,20 @@ else()
|
||||
qt_finalize_target(${PROJECT})
|
||||
endif()
|
||||
|
||||
install(TARGETS ${PROJECT} DESTINATION ".")
|
||||
install(FILES $<TARGET_RUNTIME_DLLS:${PROJECT}> DESTINATION ".")
|
||||
install(TARGETS ${PROJECT}
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
COMPONENT client
|
||||
)
|
||||
install(FILES $<TARGET_RUNTIME_DLLS:${PROJECT}>
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
COMPONENT client
|
||||
)
|
||||
|
||||
qt_generate_deploy_qml_app_script(
|
||||
TARGET ${PROJECT}
|
||||
OUTPUT_SCRIPT QT_DEPLOY_SCRIPT
|
||||
NO_UNSUPPORTED_PLATFORM_ERROR
|
||||
)
|
||||
install(SCRIPT ${QT_DEPLOY_SCRIPT})
|
||||
install(SCRIPT ${QT_DEPLOY_SCRIPT}
|
||||
COMPONENT client
|
||||
)
|
||||
|
||||
@@ -80,7 +80,7 @@ bool WireguardUtilsLinux::addInterface(const InterfaceConfig& config) {
|
||||
|
||||
QDir appPath(QCoreApplication::applicationDirPath());
|
||||
QStringList wgArgs = {"-f", "amn0"};
|
||||
m_tunnel.start(appPath.filePath("../../client/bin/amneziawg-go"), wgArgs);
|
||||
m_tunnel.start(appPath.filePath("amneziawg-go"), wgArgs);
|
||||
if (!m_tunnel.waitForStarted(WG_TUN_PROC_TIMEOUT)) {
|
||||
logger.error() << "Unable to start tunnel process due to timeout";
|
||||
m_tunnel.kill();
|
||||
|
||||
+1
-17
@@ -259,15 +259,7 @@ bool Utils::killProcessByName(const QString &name)
|
||||
|
||||
QString Utils::openVpnExecPath()
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
return Utils::executable("openvpn/openvpn", true);
|
||||
#elif defined Q_OS_LINUX
|
||||
// We have service that runs OpenVPN on Linux. We need to make same
|
||||
// path for client and service.
|
||||
return Utils::executable("../../client/bin/openvpn", true);
|
||||
#else
|
||||
return Utils::executable("/openvpn", true);
|
||||
#endif
|
||||
return Utils::executable("openvpn", true);
|
||||
}
|
||||
|
||||
QString Utils::wireguardExecPath()
|
||||
@@ -295,15 +287,7 @@ QString Utils::certUtilPath()
|
||||
|
||||
QString Utils::tun2socksPath()
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
return Utils::executable("tun2socks", true);
|
||||
#elif defined Q_OS_LINUX
|
||||
// We have service that runs OpenVPN on Linux. We need to make same
|
||||
// path for client and service.
|
||||
return Utils::executable("../../client/bin/tun2socks", true);
|
||||
#else
|
||||
return Utils::executable("/tun2socks", true);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.layout import basic_layout
|
||||
from conan.tools.files import get, collect_libs
|
||||
from conan.tools.gnu import Autotools, AutotoolsToolchain, PkgConfigDeps, AutotoolsDeps
|
||||
from conan.errors import ConanInvalidConfiguration
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
class LibcapNg(ConanFile):
|
||||
name = "libcap-ng"
|
||||
version = "0.9.2"
|
||||
settings = "build_type", "compiler", "os", "arch"
|
||||
options = {
|
||||
"shared": [True, False]
|
||||
}
|
||||
default_options = {
|
||||
"shared": False
|
||||
}
|
||||
|
||||
def layout(self):
|
||||
basic_layout(self, src_folder="src")
|
||||
|
||||
def validate(self):
|
||||
if self.settings.os != "Linux":
|
||||
ConanInvalidConfiguration(f"{self.name} v{self.version} is available only on Linux")
|
||||
|
||||
def requirements(self):
|
||||
self.tool_requires("automake/1.16.5")
|
||||
self.tool_requires("libtool/2.4.7")
|
||||
self.tool_requires("pkgconf/2.5.1")
|
||||
|
||||
def source(self):
|
||||
get(self, f"https://github.com/stevegrubb/libcap-ng/archive/refs/tags/v{self.version}.zip",
|
||||
sha256="9c8847f9732f8ee161faf5bebad44cc6f614a8199f3d8dcb2014290b4acedc18", strip_root=True)
|
||||
|
||||
def generate(self):
|
||||
pkgconf = PkgConfigDeps(self)
|
||||
pkgconf.generate()
|
||||
tc = AutotoolsToolchain(self)
|
||||
if self.options.shared:
|
||||
tc.configure_args.extend(["--enable-shared", "--disable-static"])
|
||||
else:
|
||||
tc.configure_args.extend(["--disable-shared", "--enable-static"])
|
||||
tc.generate()
|
||||
deps = AutotoolsDeps(self)
|
||||
deps.generate()
|
||||
|
||||
def build(self):
|
||||
Path(self.source_folder, "NEWS").touch(exist_ok=True)
|
||||
autotools = Autotools(self)
|
||||
autotools.autoreconf()
|
||||
autotools.configure()
|
||||
autotools.make()
|
||||
|
||||
def package(self):
|
||||
autotools = Autotools(self)
|
||||
autotools.install()
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.libs = collect_libs(self)
|
||||
@@ -28,17 +28,22 @@ class Openvpn(ConanFile):
|
||||
def build_requirements(self):
|
||||
if self._is_windows:
|
||||
self.tool_requires("cmake/[>=3.14 <4]")
|
||||
self.tool_requires("pkgconf/2.5.1")
|
||||
else:
|
||||
self.tool_requires("libtool/2.4.7")
|
||||
self.tool_requires("automake/1.16.5")
|
||||
|
||||
if self.settings.os == "Linux" or self._is_windows:
|
||||
self.tool_requires("pkgconf/2.5.1")
|
||||
|
||||
def requirements(self):
|
||||
self.requires("openssl/[>=1.1.0]", visible=False)
|
||||
self.requires("lz4/[>=1.7.1]", visible=False)
|
||||
self.requires("lzo/2.10", visible=False)
|
||||
if self._is_windows:
|
||||
self.requires("tap-windows6/[*]")
|
||||
if self.settings.os == "Linux":
|
||||
self.requires("libnl/3.9.0")
|
||||
self.requires("libcap-ng/0.9.2")
|
||||
|
||||
def source(self):
|
||||
get(self, f"https://github.com/OpenVPN/openvpn/archive/refs/tags/v{self.version}.zip",
|
||||
@@ -55,6 +60,10 @@ class Openvpn(ConanFile):
|
||||
def generate(self):
|
||||
self._patch_sources()
|
||||
|
||||
if self.settings.os == "Linux" or self._is_windows:
|
||||
pkgconf = PkgConfigDeps(self)
|
||||
pkgconf.generate()
|
||||
|
||||
if self._is_windows:
|
||||
tc = CMakeToolchain(self)
|
||||
applink_include_path = os.path.join(self.export_sources_folder, "include").replace("\\", "/")
|
||||
@@ -66,10 +75,10 @@ class Openvpn(ConanFile):
|
||||
tc.generate()
|
||||
deps = CMakeDeps(self)
|
||||
deps.generate()
|
||||
pkgconf = PkgConfigDeps(self)
|
||||
pkgconf.generate()
|
||||
else:
|
||||
tc = AutotoolsToolchain(self)
|
||||
tc.configure_args.extend(["--disable-shared", "--enable-static"])
|
||||
tc.configure_args.append("--disable-plugins")
|
||||
tc.generate()
|
||||
deps = AutotoolsDeps(self)
|
||||
deps.generate()
|
||||
|
||||
@@ -308,7 +308,7 @@ target_compile_definitions(${PROJECT} PRIVATE "MZ_$<UPPER_CASE:${MZ_PLATFORM_NAM
|
||||
find_package(amnezia-xray-bindings REQUIRED)
|
||||
target_link_libraries(${PROJECT} PRIVATE amnezia::xray-bindings)
|
||||
|
||||
find_package(openssl REQUIRED)
|
||||
find_package(OpenSSL REQUIRED)
|
||||
target_link_libraries(${PROJECT} PRIVATE OpenSSL::SSL OpenSSL::Crypto)
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
@@ -365,7 +365,10 @@ add_custom_command(
|
||||
$<TARGET_FILE_DIR:${PROJECT}>
|
||||
COMMAND_EXPAND_LISTS
|
||||
)
|
||||
install(DIRECTORY "${CMAKE_SOURCE_DIR}/deploy/data/${DEPLOY_PLATFORM_PATH}/" DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
install(DIRECTORY "${CMAKE_SOURCE_DIR}/deploy/data/${DEPLOY_PLATFORM_PATH}/"
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
COMPONENT ${PROJECT}
|
||||
)
|
||||
|
||||
# install non-linked dependencies
|
||||
if (WIN32)
|
||||
@@ -391,9 +394,12 @@ list(APPEND BLOBS ${GEOSITE_DAT_PATH} ${GEOIP_DAT_PATH})
|
||||
add_custom_command(TARGET ${PROJECT} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${BLOBS}
|
||||
$<TARGET_FILE_DIR:${PROJECT}>
|
||||
"$<TARGET_FILE_DIR:${PROJECT}>"
|
||||
)
|
||||
install(FILES ${BLOBS}
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
COMPONENT service
|
||||
)
|
||||
install(FILES ${BLOBS} DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
# install drivers
|
||||
if (WIN32)
|
||||
@@ -403,7 +409,10 @@ if (WIN32)
|
||||
"${TAP_WINDOWS6_BIN}"
|
||||
"$<TARGET_FILE_DIR:${PROJECT}>/tap"
|
||||
)
|
||||
install(DIRECTORY "${TAP_WINDOWS6_BIN}/" DESTINATION "${CMAKE_INSTALL_BINDIR}/tap")
|
||||
install(DIRECTORY "${TAP_WINDOWS6_BIN}/"
|
||||
DESTINATION "${CMAKE_INSTALL_BINDIR}/tap"
|
||||
COMPONENT service
|
||||
)
|
||||
|
||||
find_package(win-split-tunnel REQUIRED)
|
||||
add_custom_command(TARGET ${PROJECT} POST_BUILD
|
||||
@@ -411,16 +420,27 @@ if (WIN32)
|
||||
"${WIN_SPLIT_TUNNEL_BIN}"
|
||||
"$<TARGET_FILE_DIR:${PROJECT}>"
|
||||
)
|
||||
install(DIRECTORY "${WIN_SPLIT_TUNNEL_BIN}/" DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
install(DIRECTORY "${WIN_SPLIT_TUNNEL_BIN}/"
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
COMPONENT service
|
||||
)
|
||||
endif()
|
||||
|
||||
# install target
|
||||
install(TARGETS ${PROJECT} DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
install(FILES $<TARGET_RUNTIME_DLLS:${PROJECT}> DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
install(TARGETS ${PROJECT}
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
COMPONENT service
|
||||
)
|
||||
install(FILES $<TARGET_RUNTIME_DLLS:${PROJECT}>
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
COMPONENT service
|
||||
)
|
||||
|
||||
qt_generate_deploy_app_script(
|
||||
TARGET ${PROJECT}
|
||||
OUTPUT_SCRIPT QT_DEPLOY_SCRIPT
|
||||
NO_UNSUPPORTED_PLATFORM_ERROR
|
||||
)
|
||||
install(SCRIPT ${QT_DEPLOY_SCRIPT})
|
||||
install(SCRIPT ${QT_DEPLOY_SCRIPT}
|
||||
COMPONENT service
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user