1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
// Copyright Epic Games, Inc. All Rights Reserved.
#include <zencore/logging.h>
#include <zencore/string.h>
#include <zenhorde/hordeconfig.h>
namespace zen::horde {
bool
HordeConfig::Validate() const
{
if (ServerUrl.empty())
{
ZEN_WARN("Horde server URL is not configured");
return false;
}
// Relay mode implies AES encryption
if (Mode == ConnectionMode::Relay && EncryptionMode != Encryption::AES)
{
ZEN_WARN("Horde relay mode requires AES encryption, but encryption is set to '{}'", ToString(EncryptionMode));
return false;
}
return true;
}
const char*
ToString(ConnectionMode Mode)
{
switch (Mode)
{
case ConnectionMode::Direct:
return "direct";
case ConnectionMode::Tunnel:
return "tunnel";
case ConnectionMode::Relay:
return "relay";
}
return "direct";
}
const char*
ToString(Encryption Enc)
{
switch (Enc)
{
case Encryption::None:
return "none";
case Encryption::AES:
return "aes";
}
return "none";
}
bool
FromString(ConnectionMode& OutMode, std::string_view Str)
{
if (StrCaseCompare(Str, "direct") == 0)
{
OutMode = ConnectionMode::Direct;
return true;
}
if (StrCaseCompare(Str, "tunnel") == 0)
{
OutMode = ConnectionMode::Tunnel;
return true;
}
if (StrCaseCompare(Str, "relay") == 0)
{
OutMode = ConnectionMode::Relay;
return true;
}
ZEN_WARN("unrecognized Horde connection mode: '{}'", Str);
return false;
}
bool
FromString(Encryption& OutEnc, std::string_view Str)
{
if (StrCaseCompare(Str, "none") == 0)
{
OutEnc = Encryption::None;
return true;
}
if (StrCaseCompare(Str, "aes") == 0)
{
OutEnc = Encryption::AES;
return true;
}
ZEN_WARN("unrecognized Horde encryption mode: '{}'", Str);
return false;
}
} // namespace zen::horde
|