[OpenSIPS-Devel] PATCH: use all SRV records for mediaproxy dispatcher entries

Henk Hesselink opensips-devel at voipro.nl
Wed Oct 24 06:11:24 CEST 2012


Hi,

The mediaproxy relay only uses the first SRV record returned for each
entry in the  dispatcher line in the config file.  The attached patch
changes that to use all returned records.  This makes it possible to
group dispatchers, and also means the config file doesn't need to be
changed (and the relay restarted) every time the list of dispatchers
changes.  The patch is against mediaproxy 2.4.2.

Regards,

Henk Hesselink
-------------- next part --------------
--- relay.py-2.4.2	2010-07-15 11:28:32.000000000 +0200
+++ relay.py	2012-10-24 03:09:51.360810895 +0200
@@ -257,9 +257,10 @@
         return KeepRunning
 
     def _cb_got_srv(self, (answers, auth, add), port):
-        for answer in answers:
-            if answer.type == dns.SRV and answer.payload and answer.payload.target != dns.Name("."):
-                return str(answer.payload.target), port
+        srvs = [(str(answer.payload.target), port) for answer in answers
+                    if answer.type == dns.SRV and answer.payload and answer.payload.target != dns.Name(".")]
+        if len(srvs):
+            return srvs
         raise DomainError
 
     def _eb_no_srv(self, failure, addr, port):
@@ -272,7 +273,12 @@
 
     def _cb_got_all(self, results):
         if not self.shutting_down:
-            dispatchers = [result[1] for result in results if result[0] and result[1] is not None]
+            dispatchers = []
+            for dispatcher in [result[1] for result in results if result[0] and result[1] is not None]:
+                if type(dispatcher) == type([]):
+                    dispatchers.extend(dispatcher)
+                else:
+                    dispatchers.append(dispatcher)
             self.update_dispatchers(dispatchers)
 
     def update_dispatchers(self, dispatchers):


More information about the Devel mailing list