summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-11-01 20:58:10 +0100
committerCarl Hetherington <cth@carlh.net>2022-11-02 01:17:13 +0100
commit0d7d4fb3472a30f7706baab0703114ec32d5a2af (patch)
tree6b57993e0b3e899c62368f333378a8791ac800eb /src/lib
parent98a8b5835aca46d8abb6f59513a56648f2c234ba (diff)
Add passive mode option to TMS upload.
Disabling this fixes TMS upload with some FTP servers (reported on a Synology NAS).
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/config.cc4
-rw-r--r--src/lib/config.h9
-rw-r--r--src/lib/curl_uploader.cc3
3 files changed, 16 insertions, 0 deletions
diff --git a/src/lib/config.cc b/src/lib/config.cc
index 81daff5b6..6984c4064 100644
--- a/src/lib/config.cc
+++ b/src/lib/config.cc
@@ -94,6 +94,7 @@ Config::set_defaults ()
_servers.clear ();
_only_servers_encode = false;
_tms_protocol = FileTransferProtocol::SCP;
+ _tms_passive = true;
_tms_ip = "";
_tms_path = ".";
_tms_user = "";
@@ -325,6 +326,7 @@ try
_only_servers_encode = f.optional_bool_child ("OnlyServersEncode").get_value_or (false);
_tms_protocol = static_cast<FileTransferProtocol>(f.optional_number_child<int>("TMSProtocol").get_value_or(static_cast<int>(FileTransferProtocol::SCP)));
+ _tms_passive = f.optional_bool_child("TMSPassive").get_value_or(true);
_tms_ip = f.string_child ("TMSIP");
_tms_path = f.string_child ("TMSPath");
_tms_user = f.string_child ("TMSUser");
@@ -719,6 +721,8 @@ Config::write_config () const
root->add_child("OnlyServersEncode")->add_child_text (_only_servers_encode ? "1" : "0");
/* [XML] TMSProtocol Protocol to use to copy files to a TMS; 0 to use SCP, 1 for FTP. */
root->add_child("TMSProtocol")->add_child_text (raw_convert<string> (static_cast<int> (_tms_protocol)));
+ /* [XML] TMSPassive True to use PASV mode with TMS FTP connections. */
+ root->add_child("TMSPassive")->add_child_text(_tms_passive ? "1" : "0");
/* [XML] TMSIP IP address of TMS. */
root->add_child("TMSIP")->add_child_text (_tms_ip);
/* [XML] TMSPath Path on the TMS to copy files to. */
diff --git a/src/lib/config.h b/src/lib/config.h
index 1a11b4a41..9e84a120b 100644
--- a/src/lib/config.h
+++ b/src/lib/config.h
@@ -130,6 +130,10 @@ public:
return _tms_protocol;
}
+ bool tms_passive() const {
+ return _tms_passive;
+ }
+
/** @return The IP address of a TMS that we can copy DCPs to */
std::string tms_ip () const {
return _tms_ip;
@@ -629,6 +633,10 @@ public:
maybe_set (_tms_protocol, p);
}
+ void set_tms_passive(bool passive) {
+ maybe_set(_tms_passive, passive);
+ }
+
/** @param i IP address of a TMS that we can copy DCPs to */
void set_tms_ip (std::string i) {
maybe_set (_tms_ip, i);
@@ -1256,6 +1264,7 @@ private:
std::vector<std::string> _servers;
bool _only_servers_encode;
FileTransferProtocol _tms_protocol;
+ bool _tms_passive;
/** The IP address of a TMS that we can copy DCPs to */
std::string _tms_ip;
/** The path on a TMS that we should write DCPs to */
diff --git a/src/lib/curl_uploader.cc b/src/lib/curl_uploader.cc
index 6fe7aba14..9416a17fb 100644
--- a/src/lib/curl_uploader.cc
+++ b/src/lib/curl_uploader.cc
@@ -58,6 +58,9 @@ CurlUploader::CurlUploader (function<void (string)> set_status, function<void (f
curl_easy_setopt (_curl, CURLOPT_READDATA, this);
curl_easy_setopt (_curl, CURLOPT_USERNAME, Config::instance()->tms_user().c_str());
curl_easy_setopt (_curl, CURLOPT_PASSWORD, Config::instance()->tms_password().c_str());
+ if (!Config::instance()->tms_passive()) {
+ curl_easy_setopt(_curl, CURLOPT_FTPPORT, "-");
+ }
}