#5657 Use SerialKey class in ServerArgs
This commit is contained in:
parent
88c59b4ca6
commit
99dbdc5eb3
|
@ -455,13 +455,9 @@ Server::switchScreen(BaseClientProxy* dst,
|
||||||
assert(dst != NULL);
|
assert(dst != NULL);
|
||||||
|
|
||||||
// if trial is expired, exit the process
|
// if trial is expired, exit the process
|
||||||
if (!m_args.m_serial.empty()) {
|
if (!m_args.m_serial.isExpired(std::time(0))) {
|
||||||
SerialKey serial(m_args.m_serial);
|
LOG((CLOG_ERR "trial is expired, aborting server"));
|
||||||
if (!serial.isValid(std::time(0))) {
|
exit(kExitSuccess);
|
||||||
LOG((CLOG_ERR "trial is expired, aborting server"));
|
|
||||||
exit(kExitSuccess);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
@ -897,7 +893,7 @@ Server::isSwitchOkay(BaseClientProxy* newScreen,
|
||||||
|
|
||||||
if (!preventSwitch && (
|
if (!preventSwitch && (
|
||||||
(this->m_switchNeedsShift && ((mods & KeyModifierShift) != KeyModifierShift)) ||
|
(this->m_switchNeedsShift && ((mods & KeyModifierShift) != KeyModifierShift)) ||
|
||||||
(this->m_switchNeedsControl && ((mods & KeyModifierControl) != KeyModifierControl)) ||
|
(this->m_switchNeedsControl && ((mods & KeyModifierControl) != KeyModifierControl)) ||
|
||||||
(this->m_switchNeedsAlt && ((mods & KeyModifierAlt) != KeyModifierAlt))
|
(this->m_switchNeedsAlt && ((mods & KeyModifierAlt) != KeyModifierAlt))
|
||||||
)) {
|
)) {
|
||||||
LOG((CLOG_DEBUG1 "need modifiers to switch"));
|
LOG((CLOG_DEBUG1 "need modifiers to switch"));
|
||||||
|
@ -2072,7 +2068,7 @@ Server::onFileChunkSending(const void* data)
|
||||||
assert(m_active != NULL);
|
assert(m_active != NULL);
|
||||||
|
|
||||||
// relay
|
// relay
|
||||||
m_active->fileChunkSending(chunk->m_chunk[0], &chunk->m_chunk[1], chunk->m_dataSize);
|
m_active->fileChunkSending(chunk->m_chunk[0], &chunk->m_chunk[1], chunk->m_dataSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -48,9 +48,6 @@ private:
|
||||||
|
|
||||||
#ifdef TEST_ENV
|
#ifdef TEST_ENV
|
||||||
private:
|
private:
|
||||||
FRIEND_TEST(SerialKeyTests, decode_empty_returnEmptyString);
|
|
||||||
FRIEND_TEST(SerialKeyTests, decode_invalidDigit_returnEmptyString);
|
|
||||||
FRIEND_TEST(SerialKeyTests, decode_validSerial_returnPlainText);
|
|
||||||
FRIEND_TEST(SerialKeyTests, parse_noParty_invalid);
|
FRIEND_TEST(SerialKeyTests, parse_noParty_invalid);
|
||||||
FRIEND_TEST(SerialKeyTests, parse_invalidPartsLenghth_invalid);
|
FRIEND_TEST(SerialKeyTests, parse_invalidPartsLenghth_invalid);
|
||||||
FRIEND_TEST(SerialKeyTests, parse_validV1Serial_valid);
|
FRIEND_TEST(SerialKeyTests, parse_validV1Serial_valid);
|
||||||
|
|
|
@ -71,7 +71,7 @@ ArgParser::parseServerArgs(ServerArgs& args, int argc, const char* const* argv)
|
||||||
DpiHelper::s_primaryHeightCenter = synergy::string::stringToSizeType(argv[++i]);
|
DpiHelper::s_primaryHeightCenter = synergy::string::stringToSizeType(argv[++i]);
|
||||||
}
|
}
|
||||||
else if (isArg(i, argc, argv, "", "--serial-key", 1)) {
|
else if (isArg(i, argc, argv, "", "--serial-key", 1)) {
|
||||||
args.m_serial = argv[++i];
|
args.m_serial = SerialKey(argv[++i]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, args.m_pname, argv[i], args.m_pname));
|
LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, args.m_pname, argv[i], args.m_pname));
|
||||||
|
@ -476,7 +476,7 @@ ArgParser::assembleCommand(std::vector<String>& argsArray, String ignoreArg, in
|
||||||
|
|
||||||
if (!result.empty()) {
|
if (!result.empty()) {
|
||||||
// remove the tail space
|
// remove the tail space
|
||||||
result = result.substr(0, result.size() - 1);
|
result = result.substr(0, result.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "synergy/ArgsBase.h"
|
#include "synergy/ArgsBase.h"
|
||||||
|
#include "shared/SerialKey.h"
|
||||||
|
|
||||||
class NetworkAddress;
|
class NetworkAddress;
|
||||||
class Config;
|
class Config;
|
||||||
|
@ -28,6 +29,6 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
String m_configFile;
|
String m_configFile;
|
||||||
String m_serial;
|
SerialKey m_serial;
|
||||||
Config* m_config;
|
Config* m_config;
|
||||||
};
|
};
|
||||||
|
|
|
@ -64,17 +64,3 @@ TEST(ServerArgsParsingTests, parseServerArgs_configArg_setConfigFile)
|
||||||
|
|
||||||
EXPECT_EQ("mock_configFile", serverArgs.m_configFile);
|
EXPECT_EQ("mock_configFile", serverArgs.m_configFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(ServerArgsParsingTests, parseServerArgs_serialArg_setSerial)
|
|
||||||
{
|
|
||||||
NiceMock<MockArgParser> argParser;
|
|
||||||
ON_CALL(argParser, parseGenericArgs(_, _, _)).WillByDefault(Invoke(server_stubParseGenericArgs));
|
|
||||||
ON_CALL(argParser, checkUnexpectedArgs()).WillByDefault(Invoke(server_stubCheckUnexpectedArgs));
|
|
||||||
ServerArgs serverArgs;
|
|
||||||
const int argc = 3;
|
|
||||||
const char* kSerialCmd[argc] = { "stub", "--serial-key", "mock_serial" };
|
|
||||||
|
|
||||||
argParser.parseServerArgs(serverArgs, argc, kSerialCmd);
|
|
||||||
|
|
||||||
EXPECT_EQ("mock_serial", serverArgs.m_serial);
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue