Module: sems Branch: master Commit: 23c333c734dedc6d7a4e806a9f006abf501408a4 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=23c333c734dedc6d7a4e806a9f006abf501408a4
Author: Stefan Sayer <[email protected]> Committer: Stefan Sayer <[email protected]> Date: Tue Oct 26 16:53:59 2010 +0200 introduce proxy_sticky_auth feature thanks to Tobias Lindgren for reporting --- core/AmConfig.cpp | 5 +++++ core/AmConfig.h | 2 ++ core/etc/sems.conf.sample | 10 ++++++++++ core/plug-in/uac_auth/UACAuth.cpp | 11 +++++++++++ 4 files changed, 28 insertions(+), 0 deletions(-) diff --git a/core/AmConfig.cpp b/core/AmConfig.cpp index b648586..8ea2c90 100644 --- a/core/AmConfig.cpp +++ b/core/AmConfig.cpp @@ -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")) diff --git a/core/AmConfig.h b/core/AmConfig.h index b722649..f587b40 100644 --- a/core/AmConfig.h +++ b/core/AmConfig.h @@ -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 */ diff --git a/core/etc/sems.conf.sample b/core/etc/sems.conf.sample index f53c0db..d2d8418 100644 --- a/core/etc/sems.conf.sample +++ b/core/etc/sems.conf.sample @@ -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] # diff --git a/core/plug-in/uac_auth/UACAuth.cpp b/core/plug-in/uac_auth/UACAuth.cpp index e9fb675..82bbdd7 100644 --- a/core/plug-in/uac_auth/UACAuth.cpp +++ b/core/plug-in/uac_auth/UACAuth.cpp @@ -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, _______________________________________________ Semsdev mailing list [email protected] http://lists.iptel.org/mailman/listinfo/semsdev
