Permalink
Browse files

Stricter cvar restrictions

  • Loading branch information...
mbasaglia committed Nov 14, 2015
1 parent 1c11a0a commit 875ced772a57c2d951f15c0b731d906eb008e070
View
@@ -106,4 +106,23 @@ namespace Cvar {
std::string GetCvarTypeName<std::string>() {
return "text";
}
std::string SerializeCvarValue(std::size_t value) {
return std::to_string(value);
}
template<>
std::string GetCvarTypeName<std::size_t>() {
return "uint";
}
bool ParseCvarValue(Str::StringRef value, std::size_t& result) {
if ( value.empty() || !Str::cisdigit(value[0]) )
{
return false;
}
result = std::stoul(value);
return true;
}
}
View
@@ -227,6 +227,11 @@ namespace Cvar {
std::string SerializeCvarValue(std::string value);
template<>
std::string GetCvarTypeName<std::string>();
std::string SerializeCvarValue(std::size_t value);
template<>
std::string GetCvarTypeName<std::size_t>();
bool ParseCvarValue(Str::StringRef value, std::size_t& result);
// Engine calls available everywhere
@@ -30,25 +30,31 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "CryptoChallenge.h"
static Cvar::Cvar<int> cvar_server_challenge_timeout(
static Cvar::Range<Cvar::Cvar<int>> cvar_server_challenge_timeout(
"server.rcon.challenge.timeout",
"Timeout (in seconds) of a rcon challenge",
Cvar::NONE,
5
5,
1,
std::numeric_limits<int>::max()
);
static Cvar::Cvar<int> cvar_server_challenge_length(
static Cvar::Range<Cvar::Cvar<std::size_t>> cvar_server_challenge_length(
"server.rcon.challenge.length",
"Length in bytes of the challenge data (The hexadecimal representation will be twice as long",
Cvar::NONE,
8
8,
1,
Crypto::Data().max_size()
);
static Cvar::Cvar<int> cvar_server_challenge_count(
static Cvar::Range<Cvar::Cvar<std::size_t>> cvar_server_challenge_count(
"server.rcon.challenge.count",
"Maximum number of active challenges kept in memory",
Cvar::NONE,
1024
1024,
1,
std::deque<Challenge>().max_size()
);
Challenge::Duration Challenge::Timeout()
@@ -110,18 +110,19 @@ static Cvar::Cvar<std::string> cvar_server_rcon_password(
""
);
static Cvar::Cvar<int> cvar_server_rcon_secure(
static Cvar::Range<Cvar::Cvar<int>> cvar_server_rcon_secure(
"server.rcon.secure",
"How secure the Rcon protocol should be: "
"0: Allow unencrypted rcon, "
"1: Require encryption, "
"2: Require encryption and challege check",
Cvar::NONE,
0
0,
0,
2
);
/*
=============================================================================
@@ -964,7 +965,6 @@ void SVC_SecureRemoteCommand( netadr_t from, const Cmd::Args& args )
}
}
// TODO: Cvars for all the settable properties, maybe it could use Cvar::PopulateInfoMap
static void SVC_RconInfo( netadr_t from, const Cmd::Args& )
{
int duration_seconds = std::chrono::duration_cast<std::chrono::seconds>(Challenge::Timeout()).count();

0 comments on commit 875ced7

Please sign in to comment.