Line data Source code
1 : /* 2 : * Copyright (C) 2004-2025 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 "sipaccountbase_config.h" 19 : 20 : namespace jami { 21 : constexpr static std::string_view ACCOUNT_TYPE_SIP = "SIP"; 22 : 23 : struct SipAccountConfig : public SipAccountBaseConfig 24 : { 25 87 : SipAccountConfig(const std::string& id = {}, const std::filesystem::path& path = {}) 26 87 : : SipAccountBaseConfig(std::string(ACCOUNT_TYPE_SIP), id, path) 27 87 : {} 28 : void serialize(YAML::Emitter& out) const override; 29 : void unserialize(const YAML::Node& node) override; 30 : std::map<std::string, std::string> toMap() const override; 31 : void fromMap(const std::map<std::string, std::string>&) override; 32 : 33 : /** 34 : * Local port to whih this account is bound 35 : */ 36 : uint16_t localPort {sip_utils::DEFAULT_SIP_PORT}; 37 : 38 : /** 39 : * Potential ip addresss on which this account is bound 40 : */ 41 : std::string bindAddress {}; 42 : 43 : /** 44 : * Published port, used only if defined by the user 45 : */ 46 : uint16_t publishedPort {sip_utils::DEFAULT_SIP_PORT}; 47 : 48 : /** 49 : * interface name on which this account is bound 50 : */ 51 : std::string interface {dhtnet::ip_utils::DEFAULT_INTERFACE}; 52 : 53 : /** 54 : * Determine if STUN public address resolution is required to register this account. In this 55 : * case a STUN server hostname must be specified. 56 : */ 57 : bool stunEnabled {false}; 58 : 59 : /** 60 : * The STUN server hostname (optional), used to provide the public IP address in case the 61 : * softphone stay behind a NAT. 62 : */ 63 : std::string stunServer {}; 64 : 65 : /** 66 : * Network settings 67 : */ 68 : unsigned registrationExpire {3600}; 69 : bool registrationRefreshEnabled {true}; 70 : 71 : // If true, the contact addreass and header will be rewritten 72 : // using the information received from the registrar. 73 : bool allowIPAutoRewrite {true}; 74 : 75 : /** 76 : * Input Outbound Proxy Server Address 77 : */ 78 : std::string serviceRoute; 79 : 80 : /** 81 : * The TLS listener port 82 : */ 83 : uint16_t tlsListenerPort {sip_utils::DEFAULT_SIP_TLS_PORT}; 84 : bool tlsEnable {false}; 85 : std::string tlsMethod; 86 : std::string tlsCiphers; 87 : std::string tlsServerName; 88 : bool tlsVerifyServer {true}; 89 : bool tlsVerifyClient {true}; 90 : bool tlsRequireClientCertificate {true}; 91 : bool tlsDisableSecureDlgCheck {true}; 92 : int tlsNegotiationTimeout {2}; 93 : 94 : /** 95 : * Determine if the softphone should fallback on non secured media channel if SRTP negotiation 96 : * fails. Make sure other SIP endpoints share the same behavior since it could result in 97 : * encrypted data to be played through the audio device. 98 : */ 99 : bool srtpFallback {false}; 100 : /** 101 : * Specifies the type of key exchange used for SRTP, if any. 102 : * This only determine if the media channel is secured. 103 : */ 104 : KeyExchangeProtocol srtpKeyExchange {KeyExchangeProtocol::SDES}; 105 : 106 : bool presenceEnabled {false}; 107 : bool publishSupported {false}; 108 : bool subscribeSupported {false}; 109 : 110 : /** 111 : * Map of credential for this account 112 : */ 113 : struct Credentials 114 : { 115 : std::string realm {}; 116 : std::string username {}; 117 : std::string password {}; 118 : std::string password_h {}; 119 : Credentials(const std::string& r, const std::string& u, const std::string& p) 120 : : realm(r) 121 : , username(u) 122 : , password(p) 123 : {} 124 : Credentials(const std::map<std::string, std::string>& r); 125 : std::map<std::string, std::string> toMap() const; 126 : void computePasswordHash(); 127 : }; 128 : std::vector<Credentials> credentials; 129 : std::vector<std::map<std::string, std::string>> getCredentials() const; 130 : void setCredentials(const std::vector<std::map<std::string, std::string>>& creds); 131 : }; 132 : 133 : } // namespace jami