-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHttpServerConfigProtocol.cc
More file actions
88 lines (77 loc) · 2.28 KB
/
HttpServerConfigProtocol.cc
File metadata and controls
88 lines (77 loc) · 2.28 KB
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
/*
* Copyright (C) 2021 Frank Mertens.
*
* Distribution and use is allowed under the terms of the GNU General Public License version 3
* (see CoreComponents/LICENSE-gpl-3.0).
*
*/
#include <cc/HttpServerConfigProtocol>
#include <cc/HttpLoggingServiceRegistry>
#include <cc/TlsServerOptionsPrototype>
#include <cc/MetaProtocolState>
#include <cc/Process>
namespace cc {
class NodePrototype: public MetaPrototype
{
public:
explicit NodePrototype(const MetaProtocol &protocol):
MetaPrototype{"Node", protocol}
{
bool superUser = Process::isSuperUser();
establish("address", "*");
establish("port", superUser ? List<long>{80, 443} : List<long>{8080, 4443});
establish("family", "");
establish("tls", false);
establish("user", "");
establish("group", "");
establish("version", "ccnode");
establish("daemon", false);
establish("daemon-name", "ccnode");
establish("pid-file", "");
establish("concurrency",
#ifdef NDEBUG
256
#else
16
#endif
);
establish("service-window", 30);
establish("connection-limit", 32);
establish("connection-timeout", 10.);
establish("security", TlsServerOptionsPrototype{}.as<MetaPrototype>());
establish("error-log", HttpLoggingServiceRegistry{}.loggingProtocol());
establish("access-log", HttpLoggingServiceRegistry{}.loggingProtocol());
}
};
struct HttpServerConfigProtocol::State: public MetaProtocol::State
{
State():
nodeProtocol_{New{}},
configPrototype_{nodeProtocol_}
{
define(configPrototype_);
}
MetaProtocol nodeProtocol_;
NodePrototype configPrototype_;
};
HttpServerConfigProtocol::HttpServerConfigProtocol()
{
initOnce<State>();
}
MetaObject HttpServerConfigProtocol::configPrototype() const
{
return me().configPrototype_;
}
void HttpServerConfigProtocol::registerService(const MetaPrototype &configPrototype)
{
me().nodeProtocol_.define(configPrototype);
}
HttpServerConfigProtocol::State &HttpServerConfigProtocol::me()
{
return Object::me.as<State>();
}
const HttpServerConfigProtocol::State &HttpServerConfigProtocol::me() const
{
return Object::me.as<State>();
}
} // namespace cc