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