introduce proxy_sticky_auth feature

thanks to Tobias Lindgren for reporting
sayer/1.4-spce2.6
Stefan Sayer 16 years ago
parent c4ee58f46b
commit 23c333c734

@ -71,6 +71,7 @@ int AmConfig::LocalSIPPort = 5060;
string AmConfig::LocalSIPIP = "";
string AmConfig::OutboundProxy = "";
bool AmConfig::ForceOutboundProxy = false;
bool AmConfig::ProxyStickyAuth = false;
string AmConfig::Signature = "";
unsigned int AmConfig::MaxForwards = MAX_FORWARDS;
bool AmConfig::SingleCodecInOK = false;
@ -286,6 +287,10 @@ int AmConfig::readConfiguration()
if(cfg.hasParameter("force_outbound_proxy")) {
ForceOutboundProxy = (cfg.getParameter("force_outbound_proxy") == "yes");
}
if(cfg.hasParameter("proxy_sticky_auth")) {
ProxyStickyAuth = (cfg.getParameter("proxy_sticky_auth") == "yes");
}
// plugin_path
if (cfg.hasParameter("plugin_path"))

@ -102,6 +102,8 @@ struct AmConfig
static string OutboundProxy;
/** force Outbound Proxy to be used for in dialog requests */
static bool ForceOutboundProxy;
/** update ruri-host to previously resolved IP:port on SIP auth */
static bool ProxyStickyAuth;
/** Server/User-Agent header (optional) */
static string Signature;
/** Value of Max-Forward header field for new requests */

@ -394,6 +394,16 @@ use_default_signature=yes
#
#100rel=require
# Make SIP authenticated requests sticky to the proxy? [yes | no]
#
# If enabled, host of request-URI of out-of-dialog requests that are
# authenticated with SIP auth is changed to the previously resolved
# next-hop IP:port.
#
# default: no
#
# proxy_sticky_auth=yes
#
# Accept final replies without To-tag? [yes|no]
#

@ -167,6 +167,17 @@ bool UACAuth::onSipReply(const AmSipReply& reply, int old_dlg_status, const stri
// reset remote tag so remote party
// thinks its new dlg
dlg->remote_tag = "";
if (AmConfig::ProxyStickyAuth) {
// update remote URI to resolved IP
size_t hpos = dlg->remote_uri.find("@");
if (hpos != string::npos && reply.remote_ip.length()) {
dlg->remote_uri = dlg->remote_uri.substr(0, hpos+1) +
reply.remote_ip + ":"+int2str(reply.remote_port);
DBG("updated remote URI to '%s'\n", dlg->remote_uri.c_str());
}
}
}
// resend request
if (dlg->sendRequest(ri->second.method,

Loading…
Cancel
Save