reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
ReTurnConfig.hxx
Go to the documentation of this file.
1#if !defined(RETURN_CONFIG_HXX)
2#define RETURN_CONFIG_HXX
3
4#include <map>
5#include <asio.hpp>
6#ifdef USE_SSL
7#include <asio/ssl.hpp>
8#endif
10#include <rutil/Data.hxx>
11#include <rutil/Log.hxx>
13#include <rutil/RWMutex.hxx>
14#include <rutil/Lock.hxx>
15
17
18namespace reTurn {
19
20typedef std::map<resip::Data,reTurn::UserAuthData> RealmUsers;
21typedef std::pair<resip::Data, resip::Data> RealmUserPair;
22
24{
25public:
26 class Exception final : public resip::BaseException
27 {
28 public:
30 const resip::Data& file,
31 const int line)
32 : resip::BaseException(msg, file, line) {}
33 protected:
34 const char* name() const noexcept override { return "ReTurnConfig::Exception"; }
35 };
36
38 virtual ~ReTurnConfig();
39
40 virtual void parseConfig(int argc, char** argv, const resip::Data& defaultConfigFilename);
41
42 void printHelpText(int argc, char **argv);
44
51
54
55 unsigned short mTurnPort;
56 unsigned short mTlsTurnPort;
57 unsigned short mAltStunPort;
58 asio::ip::address mTurnAddress;
59 asio::ip::address mTurnV6Address;
60 asio::ip::address mAltStunAddress;
61
65 unsigned long mNonceLifetime;
66
71 unsigned long mMaxAllocationsPerUser; // over all transports, 0 for no limit
72
77 unsigned long mTlsHandshakeTimeout; // seconds, 0 for none
78 unsigned long mTcpConnectionIdleTimeout; // seconds a TCP/TLS connection without an allocation may receive nothing, 0 for none
79 unsigned long mMaxTcpConnectionsPerIp; // TCP and TLS connections from one client IP address, 0 for no limit
80 long mOpenSSLCTXSetOptions; // SSL_OP_* flags for SSL_CTX_set_options, as repro's settings of the same name
81 long mOpenSSLCTXClearOptions; // SSL_OP_* flags for SSL_CTX_clear_options
82
85
90
91 bool isUserNameValid(const resip::Data& username, const resip::Data& realm) const;
92 resip::Data getHa1ForUsername(const resip::Data& username, const resip::Data& realm) const;
93 std::unique_ptr<UserAuthData> getUser(const resip::Data& userName, const resip::Data& realm) const;
94 void addUser(const resip::Data& username, const resip::Data& password, const resip::Data& realm);
96
97private:
98 std::map<resip::Data,RealmUsers> mUsers;
99 std::map<RealmUserPair, resip::Data> mRealmUsersAuthenticaionCredentials;
100
102};
103
105{
106 public:
108 void start();
109
110 private:
111 time_t mLoadedTime;
112 ReTurnConfig& mReTurnConfig;
113 static bool mHup;
114 int mLoopInterval;
115 time_t mNextFileCheck;
116 asio::steady_timer mTimer;
117
118 bool hasUserFileChanged();
119 void timeout(const asio::error_code& e);
120
121 static void onSignal(int signum);
122};
123
124} // namespace
125
126#endif
127
128
129/* ====================================================================
130
131 Copyright (c) 2008-2026 SIP Spectrum, Inc. https://www.sipspectrum.com
132 Copyright (c) 2007-2008, Plantronics, Inc.
133 All rights reserved.
134
135 Redistribution and use in source and binary forms, with or without
136 modification, are permitted provided that the following conditions are
137 met:
138
139 1. Redistributions of source code must retain the above copyright
140 notice, this list of conditions and the following disclaimer.
141
142 2. Redistributions in binary form must reproduce the above copyright
143 notice, this list of conditions and the following disclaimer in the
144 documentation and/or other materials provided with the distribution.
145
146 3. Neither the name of Plantronics nor the names of its contributors
147 may be used to endorse or promote products derived from this
148 software without specific prior written permission.
149
150 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
151 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
152 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
153 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
154 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
155 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
156 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
157 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
158 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
159 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
160 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
161
162 ==================================================================== */
const char * name() const noexcept override
Exception(const resip::Data &msg, const resip::Data &file, const int line)
unsigned short mAllocationPortRangeMax
std::unique_ptr< UserAuthData > getUser(const resip::Data &userName, const resip::Data &realm) const
unsigned long mMaxTcpConnectionsPerIp
unsigned short mAltStunPort
asio::ip::address mAltStunAddress
unsigned long mTlsHandshakeTimeout
resip::Data mTlsTempDhFilename
bool isUserNameValid(const resip::Data &username, const resip::Data &realm) const
void authParse(const resip::Data &accountDatabaseFilename)
unsigned short mTlsTurnPort
resip::Data mSoftwareName
resip::Data mUsersDatabaseFilename
resip::Data mTlsPrivateKeyPassword
asio::ip::address mTurnAddress
void addUser(const resip::Data &username, const resip::Data &password, const resip::Data &realm)
unsigned short mAllocationPortRangeMin
resip::Data mAuthenticationRealm
unsigned long mDefaultAllocationLifetime
resip::Data mTlsServerCertificateFilename
resip::RWMutex mUserDataMutex
void printHelpText(int argc, char **argv)
unsigned long mMaxAllocationsPerUser
unsigned short mTurnPort
unsigned long mTcpConnectionIdleTimeout
virtual void parseConfig(int argc, char **argv, const resip::Data &defaultConfigFilename)
unsigned long mMaxAllocationLifetime
resip::Data getHa1ForUsername(const resip::Data &username, const resip::Data &realm) const
unsigned long mNonceLifetime
resip::Data mTlsServerPrivateKeyFilename
asio::ip::address mTurnV6Address
The abstract base-class for all exceptions thrown by resip code.
BaseException(const Data &msg, const Data &file, int line)
bool getConfigValue(const resip::Data &name, resip::Data &value) const
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
Wraps the readers/writers mutex implementation on your platform.
Definition RWMutex.hxx:29
std::map< resip::Data, reTurn::UserAuthData > RealmUsers
std::pair< resip::Data, resip::Data > RealmUserPair
dcm! – add UnusedChecking(_enum) below;
void list()
Definition userAdmin.cxx:66