Outgoing client stream: handle the situation when user's domain is hosted by another domain.
git-svn-id: http://voip.null.ro/svn/yate@4616 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
82c1ece8bf
commit
38e791aaff
|
@ -562,7 +562,7 @@ void SASL::buildMD5Digest(String& dest, const NamedList& params,
|
|||
*/
|
||||
// Constructor. Add itself to the stream's engine
|
||||
JBConnect::JBConnect(const JBStream& stream)
|
||||
: m_status(Start), m_domain(stream.remote().domain()), m_port(0),
|
||||
: m_status(Start), m_domain(stream.serverHost()), m_port(0),
|
||||
m_engine(stream.engine()), m_stream(stream.toString()),
|
||||
m_streamType((JBStream::Type)stream.type())
|
||||
{
|
||||
|
@ -1679,10 +1679,18 @@ JBClientStream* JBClientEngine::create(const String& account, const NamedList& p
|
|||
{
|
||||
if (!account)
|
||||
return 0;
|
||||
const char* domain = params.getValue("domain");
|
||||
if (TelEngine::null(domain))
|
||||
String serverHost;
|
||||
String username = params.getValue("username");
|
||||
String domain = params.getValue("domain");
|
||||
int pos = username.find("@");
|
||||
if (pos > 0) {
|
||||
serverHost = domain;
|
||||
domain = username.substr(pos + 1);
|
||||
username = username.substr(0,pos);
|
||||
}
|
||||
if (!domain)
|
||||
domain = params.getValue("server",params.getValue("address"));
|
||||
JabberID jid(params.getValue("username"),domain,params.getValue("resource"));
|
||||
JabberID jid(username,domain,params.getValue("resource"));
|
||||
if (!jid.bare()) {
|
||||
Debug(this,DebugNote,"Can't create client stream: invalid jid=%s",jid.bare().c_str());
|
||||
return 0;
|
||||
|
@ -1690,7 +1698,7 @@ JBClientStream* JBClientEngine::create(const String& account, const NamedList& p
|
|||
Lock lock(this);
|
||||
JBClientStream* stream = static_cast<JBClientStream*>(findAccount(account));
|
||||
if (!stream) {
|
||||
stream = new JBClientStream(this,jid,account,params,name);
|
||||
stream = new JBClientStream(this,jid,account,params,name,serverHost);
|
||||
stream->ref();
|
||||
addStream(stream);
|
||||
}
|
||||
|
|
|
@ -173,10 +173,10 @@ JBStream::JBStream(JBEngine* engine, Socket* socket, Type t, bool ssl)
|
|||
|
||||
// Outgoing
|
||||
JBStream::JBStream(JBEngine* engine, Type t, const JabberID& local, const JabberID& remote,
|
||||
const char* name, const NamedList* params)
|
||||
const char* name, const NamedList* params, const char* serverHost)
|
||||
: Mutex(true,"JBStream"),
|
||||
m_sasl(0),
|
||||
m_state(Idle), m_local(local), m_remote(remote),
|
||||
m_state(Idle), m_local(local), m_remote(remote), m_serverHost(serverHost),
|
||||
m_flags(0), m_xmlns(XMPPNamespace::Count), m_lastEvent(0),
|
||||
m_setupTimeout(0), m_startTimeout(0),
|
||||
m_pingTimeout(0), m_nextPing(0),
|
||||
|
@ -204,8 +204,8 @@ JBStream::JBStream(JBEngine* engine, Type t, const JabberID& local, const Jabber
|
|||
// Compress always defaults to true if not explicitly disabled
|
||||
if (!flag(Compress) && !(params && params->getBoolValue("nocompression")))
|
||||
setFlags(Compress);
|
||||
Debug(this,DebugAll,"JBStream::JBStream(%p,%s,%s,%s) outgoing [%p]",
|
||||
engine,typeName(),local.c_str(),remote.c_str(),this);
|
||||
Debug(this,DebugAll,"JBStream::JBStream(%p,%s,%s,%s,%s) outgoing [%p]",
|
||||
engine,typeName(),local.c_str(),remote.c_str(),m_serverHost.safe(),this);
|
||||
setXmlns();
|
||||
changeState(Idle);
|
||||
}
|
||||
|
@ -2488,8 +2488,9 @@ JBClientStream::JBClientStream(JBEngine* engine, Socket* socket, bool ssl)
|
|||
}
|
||||
|
||||
JBClientStream::JBClientStream(JBEngine* engine, const JabberID& jid, const String& account,
|
||||
const NamedList& params, const char* name)
|
||||
: JBStream(engine,c2s,jid,jid.domain(),TelEngine::null(name) ? account.c_str() : name,¶ms),
|
||||
const NamedList& params, const char* name, const char* serverHost)
|
||||
: JBStream(engine,c2s,jid,jid.domain(),TelEngine::null(name) ? account.c_str() : name,
|
||||
¶ms,serverHost),
|
||||
m_account(account), m_userData(0), m_registerReq(0)
|
||||
{
|
||||
m_password = params.getValue("password");
|
||||
|
|
|
@ -731,6 +731,14 @@ public:
|
|||
void connectAddr(String& addr, int& port, String& localip, int& stat,
|
||||
ObjList& srvs) const;
|
||||
|
||||
/**
|
||||
* Retrieve server host when connecting.
|
||||
* This method is not thread safe
|
||||
* @return Server host if set, remote jid's domain otherwise
|
||||
*/
|
||||
inline const String& serverHost() const
|
||||
{ return m_serverHost ? m_serverHost : m_remote.domain(); }
|
||||
|
||||
/**
|
||||
* Set/reset RosterRequested flag
|
||||
* This method is thread safe
|
||||
|
@ -954,9 +962,10 @@ protected:
|
|||
* @param remote Remote party jabber id
|
||||
* @param name Optional stream name
|
||||
* @param params Optional stream parameters
|
||||
* @param serverHost Optional server host to use instead of jid domain
|
||||
*/
|
||||
JBStream(JBEngine* engine, Type t, const JabberID& local, const JabberID& remote,
|
||||
const char* name = 0, const NamedList* params = 0);
|
||||
const char* name = 0, const NamedList* params = 0, const char* serverHost = 0);
|
||||
|
||||
/**
|
||||
* Close the stream. Release memory
|
||||
|
@ -1194,6 +1203,7 @@ protected:
|
|||
String m_id; // Stream id
|
||||
JabberID m_local; // Local peer's jid
|
||||
JabberID m_remote; // Remote peer's jid
|
||||
String m_serverHost; // Outgoing: optional server host (replaces remote domain when connecting)
|
||||
int m_flags; // Stream flags
|
||||
XMPPNamespace::Type m_xmlns; // Stream namespace
|
||||
XMPPFeatureList m_features; // Advertised features
|
||||
|
@ -1361,9 +1371,10 @@ public:
|
|||
* @param account Account (stream) name
|
||||
* @param params Stream parameters
|
||||
* @param name Optional stream name
|
||||
* @param serverHost Optional server host to use instead of jid domain
|
||||
*/
|
||||
JBClientStream(JBEngine* engine, const JabberID& jid, const String& account,
|
||||
const NamedList& params, const char* name = 0);
|
||||
const NamedList& params, const char* name = 0, const char* serverHost = 0);
|
||||
|
||||
/**
|
||||
* Retrieve stream's account
|
||||
|
|
Loading…
Reference in New Issue