A lot of file transfer updates

This commit is contained in:
WolverinDEV
2020-05-13 11:32:08 +02:00
parent 1a2dd4a008
commit 90b1646876
45 changed files with 1989 additions and 2806 deletions
+43 -3
View File
@@ -7,6 +7,7 @@
using namespace ts::server;
using LocalFileServer = file::LocalFileProvider;
using LocalVirtualFileServer = file::LocalVirtualFileServer;
EVP_PKEY* ssl_generate_key() {
auto key = std::unique_ptr<EVP_PKEY, decltype(&EVP_PKEY_free)>(EVP_PKEY_new(), ::EVP_PKEY_free);
@@ -81,7 +82,7 @@ LocalFileServer::LocalFileProvider() : file_system_{}, file_transfer_{this->file
LocalFileServer::~LocalFileProvider() {}
bool LocalFileServer::initialize(std::string &error, const std::shared_ptr<pipes::SSL::Options>& ssl_options) {
if(!this->file_system_.initialize(error, "file-root/"))
if(!this->file_system_.initialize(error, "files/"))
return false;
@@ -89,7 +90,7 @@ bool LocalFileServer::initialize(std::string &error, const std::shared_ptr<pipes
{
auto binding = std::make_shared<transfer::NetworkBinding>();
binding->hostname = "localhost";
binding->hostname = "0.0.0.0";
auto& iaddr = *(sockaddr_in*) &binding->address;
iaddr.sin_family = AF_INET;
@@ -116,6 +117,45 @@ file::filesystem::AbstractProvider &LocalFileServer::file_system() {
return this->file_system_;
}
file::transfer::AbstractProvider & LocalFileServer::file_transfer() {
file::transfer::AbstractProvider &LocalFileServer::file_transfer() {
return this->file_transfer_;
}
std::string file::LocalFileProvider::file_base_path() const {
return this->file_system_.root_path();
}
std::shared_ptr<file::VirtualFileServer> LocalFileServer::register_server(ServerId server_id) {
auto server = this->find_virtual_server(server_id);
if(server) return server;
server = std::make_shared<file::LocalVirtualFileServer>(server_id, std::to_string(server_id));
{
std::lock_guard slock{this->servers_mutex};
this->servers_.push_back(server);
}
return server;
}
void LocalFileServer::unregister_server(ServerId server_id) {
auto server_unique_id = std::to_string(server_id);
std::lock_guard slock{this->servers_mutex};
auto it = std::find_if(this->servers_.begin(), this->servers_.end(), [&](const std::shared_ptr<VirtualFileServer>& server) {
return server->unique_id() == server_unique_id;
});
if(it == this->servers_.end()) return;
this->servers_.erase(it);
}
void LocalVirtualFileServer::max_networking_upload_bandwidth(int64_t value) {
VirtualFileServer::max_networking_upload_bandwidth(value);
this->upload_throttle.set_max_bandwidth(value);
}
void LocalVirtualFileServer::max_networking_download_bandwidth(int64_t value) {
VirtualFileServer::max_networking_download_bandwidth(value);
this->download_throttle.set_max_bandwidth(value);
}