]> git.sesse.net Git - cubemap/blob - config.h
Add an example for a TLS port.
[cubemap] / config.h
1 #ifndef _CONFIG_H
2 #define _CONFIG_H
3
4 // Various routines that deal with parsing the configuration file.
5
6 #include <arpa/inet.h>
7 #include <netinet/in.h>
8 #include <stddef.h>
9 #include <string>
10 #include <vector>
11
12 struct StreamConfig {
13         std::string url;  // As seen by the client.
14         std::string src;  // Can be empty.
15         size_t backlog_size;
16         size_t prebuffering_bytes;
17         uint32_t pacing_rate;  // In bytes per second. Default is ~0U (no limit).
18         enum Encoding { STREAM_ENCODING_RAW = 0, STREAM_ENCODING_METACUBE };
19         Encoding encoding;
20         Encoding src_encoding;
21 };
22
23 struct UDPStreamConfig {
24         sockaddr_in6 dst;
25         std::string src;  // Can be empty.
26         uint32_t pacing_rate;  // In bytes per second. Default is ~0U (no limit).
27         int ttl;  // Default is -1 (use operating system default).
28         int multicast_iface_index;  // Default is -1 (use operating system default).
29 };
30
31 struct Gen204Config {
32         std::string url;  // As seen by the client.
33         std::string allow_origin;  // Can be empty.
34 };
35
36 struct AcceptorConfig {
37         sockaddr_in6 addr;
38
39         std::string certificate_chain, private_key;  // In PEM format.
40 };
41
42 struct LogConfig {
43         enum { LOG_TYPE_FILE, LOG_TYPE_CONSOLE, LOG_TYPE_SYSLOG } type;
44         std::string filename;
45 };
46
47 struct Config {
48         bool daemonize;
49         int num_servers;
50         std::vector<StreamConfig> streams;
51         std::vector<UDPStreamConfig> udpstreams;
52         std::vector<Gen204Config> pings;
53         std::vector<AcceptorConfig> acceptors;
54         std::vector<LogConfig> log_destinations;
55
56         std::string stats_file;  // Empty means no stats file.
57         int stats_interval;
58
59         std::string input_stats_file;  // Empty means no input stats file.
60         int input_stats_interval;
61
62         std::string access_log_file;  // Empty means no accses_log file.
63 };
64
65 // Parse and validate configuration. Returns false on error.
66 // <config> is taken to be empty (uninitialized) on entry.
67 bool parse_config(const std::string &filename, Config *config);
68
69 #endif  // !defined(_CONFIG_H)