-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathsettings.h
106 lines (86 loc) · 3.12 KB
/
settings.h
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
96
97
98
99
100
101
102
103
104
105
106
/*
This file is part of FlashMQ (https://www.flashmq.org)
Copyright (C) 2021-2023 Wiebe Cazemier
FlashMQ is free software: you can redistribute it and/or modify
it under the terms of The Open Software License 3.0 (OSL-3.0).
See LICENSE for license details.
*/
#ifndef SETTINGS_H
#define SETTINGS_H
#include <memory>
#include <list>
#include <limits>
#include "mosquittoauthoptcompatwrap.h"
#include "listener.h"
#include "network.h"
#include "bridgeconfig.h"
#define ABSOLUTE_MAX_PACKET_SIZE 268435455
enum class RetainedMessagesMode
{
Enabled,
Downgrade,
Drop,
DisconnectWithError
};
enum class SharedSubscriptionTargeting
{
RoundRobin,
SenderHash
};
class Settings
{
friend class ConfigFileParser;
AuthOptCompatWrap authOptCompatWrap;
std::unordered_map<std::string, std::string> flashmqpluginOpts;
std::list<std::shared_ptr<BridgeConfig>> bridges;
void checkUniqueBridgeNames() const;
public:
// Actual config options with their defaults.
std::string pluginPath;
std::string logPath;
bool quiet = false;
bool allowUnsafeClientidChars = false;
bool allowUnsafeUsernameChars = false;
bool pluginSerializeInit = false;
bool pluginSerializeAuthChecks = false;
int clientInitialBufferSize = 1024; // Must be power of 2
uint32_t maxPacketSize = ABSOLUTE_MAX_PACKET_SIZE;
uint32_t clientMaxWriteBufferSize = 1048576;
uint16_t maxIncomingTopicAliasValue = 65535;
uint16_t maxOutgoingTopicAliasValue = 65535;
#ifdef TESTING
bool logDebug = true;
#else
bool logDebug = false;
#endif
bool logSubscriptions = false;
std::string mosquittoPasswordFile;
std::string mosquittoAclFile;
bool allowAnonymous = false;
int rlimitNoFile = 1000000;
uint32_t expireSessionsAfterSeconds = 1209600;
uint32_t expireRetainedMessagesAfterSeconds = std::numeric_limits<uint32_t>::max();
int pluginTimerPeriod = 60;
std::string storageDir;
int threadCount = 0;
uint16_t maxQosMsgPendingPerClient = 512;
uint maxQosBytesPendingPerClient = 65536;
bool willsEnabled = true;
uint32_t retainedMessagesDeliveryLimit = 2048;
uint32_t retainedMessagesNodeLimit = std::numeric_limits<uint32_t>::max();
RetainedMessagesMode retainedMessagesMode = RetainedMessagesMode::Enabled;
SharedSubscriptionTargeting sharedSubscriptionTargeting = SharedSubscriptionTargeting::RoundRobin;
std::list<std::shared_ptr<Listener>> listeners; // Default one is created later, when none are defined.
std::list<Network> setRealIpFrom;
AuthOptCompatWrap &getAuthOptsCompat();
std::unordered_map<std::string, std::string> &getFlashmqpluginOpts();
std::string getRetainedMessagesDBFile() const;
std::string getSessionsDBFile() const;
std::string getBridgeNamesDBFile() const;
uint32_t getExpireSessionAfterSeconds() const;
bool matchAddrWithSetRealIpFrom(const struct sockaddr *addr) const;
bool matchAddrWithSetRealIpFrom(const struct sockaddr_in6 *addr) const;
bool matchAddrWithSetRealIpFrom(const struct sockaddr_in *addr) const;
std::list<std::shared_ptr<BridgeConfig>> stealBridges();
};
#endif // SETTINGS_H