mirror of
https://github.com/transmission/transmission
synced 2025-01-01 12:35:22 +00:00
f14e741052
* fix: pass-large-object-by-reference-to-const warning Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0Gz8ze7dx8i2lkKEvq\&open\=AX0Gz8ze7dx8i2lkKEvq * fix: use-std-array-instead-of-C-array warning Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0L8qcgUnpKTxYiu5B-\&open\=AX0L8qcgUnpKTxYiu5B- * fix: extract-assignment-from-expression Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0L8qcgUnpKTxYiu5CH\&open\=AX0L8qcgUnpKTxYiu5CH * fix: move-include-directives-to-top Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0L8qlYUnpKTxYiu5CQ\&open\=AX0L8qlYUnpKTxYiu5CQ * fix: use-init-statement Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0L8qcgUnpKTxYiu5CK\&open\=AX0L8qcgUnpKTxYiu5CK * fix: use-init-statement Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0WPlmBwxvzFbF6whWh\&open\=AX0WPlmBwxvzFbF6whWh * fix: ensure-move-constructor-is-noexcept https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0WPlWzwxvzFbF6whWU\&open\=AX0WPlWzwxvzFbF6whWU * fix: use-init-statement Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0bZP20jI_aUyxGBxCD\&open\=AX0bZP20jI_aUyxGBxCD * fix: replace-redundant-type-with-auto Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0bZP0rjI_aUyxGBxCB\&open\=AX0bZP0rjI_aUyxGBxCB * fix: make-parameter-const Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0gkQqqPDVGqE4PY-io\&open\=AX0gkQqqPDVGqE4PY-io * fix: use-init-statement https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0rARJbfJ-O-YIDS9xM\&open\=AX0rARJbfJ-O-YIDS9xM * fix: use-init-statement Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0WPlmBwxvzFbF6whWh\&open\=AX0WPlmBwxvzFbF6whWh * fix: explicitly-delete-copy-ctor Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0gkQr6PDVGqE4PY-i4\&open\=AX0gkQr6PDVGqE4PY-i4 * fix: use-init-statement Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0bZP9wjI_aUyxGBxCF\&open\=AX0bZP9wjI_aUyxGBxCF
114 lines
3 KiB
C++
114 lines
3 KiB
C++
/*
|
|
* This file Copyright (C) 2008-2014 Mnemosyne LLC
|
|
*
|
|
* It may be used under the GNU GPL versions 2 or 3
|
|
* or any future license endorsed by Mnemosyne LLC.
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#ifndef __TRANSMISSION__
|
|
#error only libtransmission should #include this header.
|
|
#endif
|
|
|
|
#include <list>
|
|
#include <string>
|
|
#include <string_view>
|
|
|
|
#include <zlib.h>
|
|
|
|
#include <event2/buffer.h>
|
|
#include <event2/event.h>
|
|
#include <event2/http.h>
|
|
#include <event2/http_struct.h> /* TODO: eventually remove this */
|
|
|
|
#include "transmission.h"
|
|
|
|
#include "net.h"
|
|
|
|
struct tr_variant;
|
|
|
|
class tr_rpc_server
|
|
{
|
|
public:
|
|
tr_rpc_server(tr_session* session, tr_variant* settings);
|
|
~tr_rpc_server();
|
|
|
|
tr_rpc_server(tr_rpc_server&) = delete;
|
|
tr_rpc_server(tr_rpc_server&&) = delete;
|
|
tr_rpc_server& operator=(tr_rpc_server&) = delete;
|
|
tr_rpc_server& operator=(tr_rpc_server&&) = delete;
|
|
|
|
z_stream stream = {};
|
|
|
|
std::list<std::string> hostWhitelist;
|
|
std::list<std::string> whitelist;
|
|
std::string salted_password;
|
|
std::string username;
|
|
std::string whitelistStr;
|
|
std::string url;
|
|
|
|
struct tr_address bindAddress;
|
|
|
|
struct event* start_retry_timer = nullptr;
|
|
struct evhttp* httpd = nullptr;
|
|
tr_session* const session;
|
|
|
|
int antiBruteForceThreshold = 0;
|
|
int loginattempts = 0;
|
|
int start_retry_counter = 0;
|
|
|
|
tr_port port = 0;
|
|
|
|
bool isAntiBruteForceEnabled = false;
|
|
bool isEnabled = false;
|
|
bool isHostWhitelistEnabled = false;
|
|
bool isPasswordEnabled = false;
|
|
bool isStreamInitialized = false;
|
|
bool isWhitelistEnabled = false;
|
|
};
|
|
|
|
void tr_rpcSetEnabled(tr_rpc_server* server, bool isEnabled);
|
|
|
|
bool tr_rpcIsEnabled(tr_rpc_server const* server);
|
|
|
|
void tr_rpcSetPort(tr_rpc_server* server, tr_port port);
|
|
|
|
tr_port tr_rpcGetPort(tr_rpc_server const* server);
|
|
|
|
void tr_rpcSetUrl(tr_rpc_server* server, std::string_view url);
|
|
|
|
std::string const& tr_rpcGetUrl(tr_rpc_server const* server);
|
|
|
|
int tr_rpcSetTest(tr_rpc_server const* server, char const* whitelist, char** allocme_errmsg);
|
|
|
|
void tr_rpcSetWhitelistEnabled(tr_rpc_server* server, bool isEnabled);
|
|
|
|
bool tr_rpcGetWhitelistEnabled(tr_rpc_server const* server);
|
|
|
|
void tr_rpcSetWhitelist(tr_rpc_server* server, std::string_view whitelist);
|
|
|
|
std::string const& tr_rpcGetWhitelist(tr_rpc_server const* server);
|
|
|
|
void tr_rpcSetPassword(tr_rpc_server* server, std::string_view password);
|
|
|
|
std::string const& tr_rpcGetPassword(tr_rpc_server const* server);
|
|
|
|
void tr_rpcSetUsername(tr_rpc_server* server, std::string_view username);
|
|
|
|
std::string const& tr_rpcGetUsername(tr_rpc_server const* server);
|
|
|
|
void tr_rpcSetPasswordEnabled(tr_rpc_server* server, bool isEnabled);
|
|
|
|
bool tr_rpcIsPasswordEnabled(tr_rpc_server const* session);
|
|
|
|
bool tr_rpcGetAntiBruteForceEnabled(tr_rpc_server const* server);
|
|
|
|
void tr_rpcSetAntiBruteForceEnabled(tr_rpc_server* server, bool is_enabled);
|
|
|
|
int tr_rpcGetAntiBruteForceThreshold(tr_rpc_server const* server);
|
|
|
|
void tr_rpcSetAntiBruteForceThreshold(tr_rpc_server* server, int badRequests);
|
|
|
|
char const* tr_rpcGetBindAddress(tr_rpc_server const* server);
|