Module: sems
Branch: master
Commit: 9d7ccee70586c7f99103e15f0411851d663ebf71
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=9d7ccee70586c7f99103e15f0411851d663ebf71

Author: Stefan Sayer <[email protected]>
Committer: Stefan Sayer <[email protected]>
Date:   Sun Jan 23 22:56:10 2011 +0100

add sems.conf option skip_dns_srv

---

 core/AmConfig.cpp         |    5 +++++
 core/AmConfig.h           |    2 ++
 core/etc/sems.conf.sample |   10 ++++++++++
 core/sip/trans_layer.cpp  |   19 +++++++++++--------
 4 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/core/AmConfig.cpp b/core/AmConfig.cpp
index 2df2b54..80714e7 100644
--- a/core/AmConfig.cpp
+++ b/core/AmConfig.cpp
@@ -71,6 +71,7 @@ string       AmConfig::LocalSIPIP              = "";
 string       AmConfig::OutboundProxy           = "";
 bool         AmConfig::ForceOutboundProxy      = false;
 bool         AmConfig::ProxyStickyAuth         = false;
+bool         AmConfig::DisableDNSSRV           = false;
 string       AmConfig::Signature               = "";
 unsigned int AmConfig::MaxForwards             = MAX_FORWARDS;
 bool        AmConfig::SingleCodecInOK         = false;
@@ -290,6 +291,10 @@ int AmConfig::readConfiguration()
   if(cfg.hasParameter("proxy_sticky_auth")) {
     ProxyStickyAuth = (cfg.getParameter("proxy_sticky_auth") == "yes");
   }
+
+  if(cfg.hasParameter("disable_dns_srv")) {
+    DisableDNSSRV = (cfg.getParameter("disable_dns_srv") == "yes");
+  }
   
   // plugin_path
   if (cfg.hasParameter("plugin_path"))
diff --git a/core/AmConfig.h b/core/AmConfig.h
index db51c5e..674dfb9 100644
--- a/core/AmConfig.h
+++ b/core/AmConfig.h
@@ -102,6 +102,8 @@ struct AmConfig
   static bool ForceOutboundProxy;
   /** update ruri-host to previously resolved IP:port on SIP auth */
   static bool ProxyStickyAuth;
+  /** skip DNS SRV lookup for resolving destination address*/
+  static bool DisableDNSSRV;
   /** 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 cbdd3c3..8b239fe 100644
--- a/core/etc/sems.conf.sample
+++ b/core/etc/sems.conf.sample
@@ -379,6 +379,16 @@ use_default_signature=yes
 #   default settings (i.e. leave out) for these should be OK
 #   for most applications
 
+# skip DNS SRV lookup? [yes, no]
+#
+# according to RFC, if no port is specified, destination IP address
+# should be resolved with a DNS SRV lookup. If SEMS should not do that
+# (only an A record lookup), set disable_dns_srv=yes.
+#
+# Default: no
+#
+#disable_dns_srv=yes
+
 # support 100rel (PRACK) extension (RFC3262)? [disabled|supported|require]
 #
 # disabled - disable support for 100rel
diff --git a/core/sip/trans_layer.cpp b/core/sip/trans_layer.cpp
index 0d5c865..a27e76a 100644
--- a/core/sip/trans_layer.cpp
+++ b/core/sip/trans_layer.cpp
@@ -734,18 +734,21 @@ int _trans_layer::set_destination_ip(sip_msg* msg, 
cstring* next_hop, unsigned s
     if(!next_port){
        // no explicit port specified,
        // try SRV first
+       if (AmConfig::DisableDNSSRV) {
+           DBG("no port specified, but DNS SRV disabled (skipping).\n");
+       } else {
+           string srv_name = "_sip._udp." + nh;
 
-       string srv_name = "_sip._udp." + nh;
+           DBG("no port specified, looking up SRV '%s'...\n", 
srv_name.c_str());
 
-       DBG("no port specified, looking up SRV '%s'...\n", srv_name.c_str());
+           if(!resolver::instance()->resolve_name(srv_name.c_str(),
+                                                  &(msg->h_dns),
+                                                  &(msg->remote_ip),IPv4)){
+               return 0;
+           }
 
-       if(!resolver::instance()->resolve_name(srv_name.c_str(),
-                                              &(msg->h_dns),
-                                              &(msg->remote_ip),IPv4)){
-           return 0;
+           DBG("no SRV record for %s",srv_name.c_str());
        }
-
-       DBG("no SRV record for %s",srv_name.c_str());
     }
 
     memset(&(msg->remote_ip),0,sizeof(sockaddr_storage));

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to