blob: 2dca228d953ab88fcc75e6c1e7e6c70cec57815b (
plain) (
blame)
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
|
// Copyright Epic Games, Inc. All Rights Reserved.
#include <zenhorde/hordeconfig.h>
namespace zen::horde {
bool
HordeConfig::Validate() const
{
if (ServerUrl.empty())
{
return false;
}
// Relay mode implies AES encryption
if (Mode == ConnectionMode::Relay && EncryptionMode != Encryption::AES)
{
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 (Str == "direct")
{
OutMode = ConnectionMode::Direct;
return true;
}
if (Str == "tunnel")
{
OutMode = ConnectionMode::Tunnel;
return true;
}
if (Str == "relay")
{
OutMode = ConnectionMode::Relay;
return true;
}
return false;
}
bool
FromString(Encryption& OutEnc, std::string_view Str)
{
if (Str == "none")
{
OutEnc = Encryption::None;
return true;
}
if (Str == "aes")
{
OutEnc = Encryption::AES;
return true;
}
return false;
}
} // namespace zen::horde
|