Line data Source code
1 : /* 2 : * Copyright (C) 2004-2026 Savoir-faire Linux Inc. 3 : * 4 : * This program is free software: you can redistribute it and/or modify 5 : * it under the terms of the GNU General Public License as published by 6 : * the Free Software Foundation, either version 3 of the License, or 7 : * (at your option) any later version. 8 : * 9 : * This program is distributed in the hope that it will be useful, 10 : * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 : * GNU General Public License for more details. 13 : * 14 : * You should have received a copy of the GNU General Public License 15 : * along with this program. If not, see <https://www.gnu.org/licenses/>. 16 : */ 17 : #pragma once 18 : #include "connectivity/sip_utils.h" 19 : #include "sipaccountbase_config.h" 20 : 21 : namespace jami { 22 : constexpr static std::string_view ACCOUNT_TYPE_SIP = "SIP"; 23 : 24 : struct SipAccountConfig : public SipAccountBaseConfig 25 : { 26 87 : SipAccountConfig(const std::string& id = {}, const std::filesystem::path& path = {}) 27 87 : : SipAccountBaseConfig(std::string(ACCOUNT_TYPE_SIP), id, path) 28 87 : {} 29 : void serialize(YAML::Emitter& out) const override; 30 : void unserialize(const YAML::Node& node) override; 31 : std::map<std::string, std::string> toMap() const override; 32 : void fromMap(const std::map<std::string, std::string>&) override; 33 : 34 : /** 35 : * Local port to whih this account is bound 36 : */ 37 : uint16_t localPort {sip_utils::DEFAULT_SIP_PORT}; 38 : 39 : /** 40 : * Potential ip addresss on which this account is bound 41 : */ 42 : std::string bindAddress {}; 43 : 44 : /** 45 : * Published port, used only if defined by the user 46 : */ 47 : uint16_t publishedPort {sip_utils::DEFAULT_SIP_PORT}; 48 : 49 : /** 50 : * interface name on which this account is bound 51 : */ 52 : std::string interface {dhtnet::ip_utils::DEFAULT_INTERFACE}; 53 : 54 : /** 55 : * Determine if STUN public address resolution is required to register this account. In this 56 : * case a STUN server hostname must be specified. 57 : */ 58 : bool stunEnabled {false}; 59 : 60 : /** 61 : * The STUN server hostname (optional), used to provide the public IP address in case the 62 : * softphone stay behind a NAT. 63 : */ 64 : std::string stunServer {}; 65 : 66 : /** 67 : * Network settings 68 : */ 69 : unsigned registrationExpire {3600}; 70 : bool registrationRefreshEnabled {true}; 71 : 72 : // If true, the contact addreass and header will be rewritten 73 : // using the information received from the registrar. 74 : bool allowIPAutoRewrite {true}; 75 : 76 : /** 77 : * Input Outbound Proxy Server Address 78 : */ 79 : std::string serviceRoute; 80 : 81 : /** 82 : * The TLS listener port 83 : */ 84 : uint16_t tlsListenerPort {sip_utils::DEFAULT_SIP_TLS_PORT}; 85 : bool tlsEnable {false}; 86 : std::string tlsMethod; 87 : std::string tlsCiphers; 88 : std::string tlsServerName; 89 : bool tlsVerifyServer {true}; 90 : bool tlsVerifyClient {true}; 91 : bool tlsRequireClientCertificate {true}; 92 : bool tlsDisableSecureDlgCheck {true}; 93 : int tlsNegotiationTimeout {2}; 94 : 95 : /** 96 : * Specifies the type of key exchange used for SRTP, if any. 97 : * This only determine if the media channel is secured. 98 : */ 99 : KeyExchangeProtocol srtpKeyExchange {KeyExchangeProtocol::SDES}; 100 : 101 : bool presenceEnabled {false}; 102 : bool publishSupported {false}; 103 : bool subscribeSupported {false}; 104 : 105 : /** 106 : * Map of credential for this account 107 : */ 108 : struct Credentials 109 : { 110 : std::string realm {}; 111 : std::string username {}; 112 : std::string password {}; 113 : std::string password_h {}; 114 : Credentials(const std::string& r, const std::string& u, const std::string& p) 115 : : realm(r) 116 : , username(u) 117 : , password(p) 118 : {} 119 : Credentials(const std::map<std::string, std::string>& r); 120 : std::map<std::string, std::string> toMap() const; 121 : void computePasswordHash(); 122 : }; 123 : std::vector<Credentials> credentials; 124 : std::vector<std::map<std::string, std::string>> getCredentials() const; 125 : void setCredentials(const std::vector<std::map<std::string, std::string>>& creds); 126 : }; 127 : 128 : } // namespace jami