From d83ba7ff30600e208e2c4e25519e6747c5874fc3 Mon Sep 17 00:00:00 2001 From: Sude Date: Fri, 15 Nov 2024 19:31:40 +0200 Subject: [PATCH] Add option to select network interface for operations --- include/config.h | 1 + main.cpp | 1 + man/lgogdownloader.1 | 3 +++ src/util.cpp | 6 ++++++ 4 files changed, 11 insertions(+) diff --git a/include/config.h b/include/config.h index 804b8ea..f127135 100644 --- a/include/config.h +++ b/include/config.h @@ -222,6 +222,7 @@ struct CurlConfig curl_off_t iDownloadRate; long int iLowSpeedTimeout; long int iLowSpeedTimeoutRate; + std::string sInterface; }; class Config diff --git a/main.cpp b/main.cpp index 05466bc..fa8eb1a 100644 --- a/main.cpp +++ b/main.cpp @@ -292,6 +292,7 @@ int main(int argc, char *argv[]) ("check-free-space", bpo::value(&Globals::globalConfig.dlConf.bFreeSpaceCheck)->zero_tokens()->default_value(false), "Check for available free space before starting download") ("no-fast-status-check", bpo::value(&bNoFastStatusCheck)->zero_tokens()->default_value(false), "Don't use fast status check.\nMakes --status much slower but able to catch corrupted files by calculating local file hash for all files.") ("trust-api-for-extras", bpo::value(&Globals::globalConfig.bTrustAPIForExtras)->zero_tokens()->default_value(false), "Trust API responses for extras to be correct.") + ("interface", bpo::value(&Globals::globalConfig.curlConf.sInterface)->default_value(""), "Perform operations using a specified network interface") ; options_cli_no_cfg_hidden.add_options() diff --git a/man/lgogdownloader.1 b/man/lgogdownloader.1 index 27e5e3f..ca68e16 100644 --- a/man/lgogdownloader.1 +++ b/man/lgogdownloader.1 @@ -453,6 +453,9 @@ local file hash for all files. .TP \fB\-\-trust\-api\-for\-extras\fR Trust API responses for extras to be correct. +.TP +\fB\-\-interface\fR arg +Perform operations using a specified network interface .SS "Experimental:" .TP \fB\-\-galaxy\-install\fR arg diff --git a/src/util.cpp b/src/util.cpp index 2a5cc2a..2c7352e 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -817,6 +817,12 @@ void Util::CurlHandleSetDefaultOptions(CURL* curlhandle, const CurlConfig& conf) if (!conf.sCACertPath.empty()) curl_easy_setopt(curlhandle, CURLOPT_CAINFO, conf.sCACertPath.c_str()); + + if (!conf.sInterface.empty()) + { + curl_easy_setopt(curlhandle, CURLOPT_DNS_INTERFACE, conf.sInterface.c_str()); + curl_easy_setopt(curlhandle, CURLOPT_INTERFACE, conf.sInterface.c_str()); + } } std::string Util::CurlHandleGetInfoString(CURL* curlhandle, CURLINFO info)