Hi.

I'm running media-relay on amazon ec2, and it has private ip address that
mapped to public one. Hence media relay returns private ip instead of
public ip address. I did little patch. You can specify advertised_address
parameter in config.ini, to return this address instead of address, that
used to listen. I've noticed, that I'm not alone who stucked with this
problem. May be possible to include this patch, or same functionality done
in another way into upstream? In any way, may be this patch can be useful
to another guys who have same pb:)
Please review attached patch (for version 2.5.2).

Pavel.
diff --git a/mediaproxy/mediacontrol.py b/mediaproxy/mediacontrol.py
index 7030ce6..5f77ad6 100644
--- a/mediaproxy/mediacontrol.py
+++ b/mediaproxy/mediacontrol.py
@@ -18,7 +18,7 @@ from twisted.python.log import Logger
 from application import log
 from application.system import host
 from application.configuration import ConfigSection, ConfigSetting
-from application.configuration.datatypes import IPAddress
+from application.configuration.datatypes import IPAddress, Hostname
 
 from mediaproxy import configuration_filename
 from mediaproxy.interfaces.system import _conntrack
@@ -48,6 +48,7 @@ class Config(ConfigSection):
     on_hold_timeout = 7200
     traffic_sampling_period = 15
     userspace_transmit_every = 1
+    advertised_address = ConfigSetting(type=Hostname, value=host.default_ip)
 
 
 if Config.relay_ip is None:
@@ -180,8 +181,9 @@ class MediaSubParty(object):
         self.listener = listener
         self.listener.protocol.cb_func = self.got_data
         self.remote = Address(None, None)
-        host = self.listener.protocol.transport.getHost()
+        host = self.listener.protocol.transport.getHost()        
         self.local = Address(host.host, host.port)
+        self.local_or_advertised = Address(Config.advertised_address, host.port)
         self.timer = None
         self.codec = "Unknown"
         self.got_stun_probing = False
@@ -597,9 +599,9 @@ class Session(object):
         except ValueError:
             return None
         if is_downstream:
-            retval = [(stream.status in ["active", "on hold"]) and tuple(stream.rtp.callee.local) or (stream.rtp.callee.local.host, 0) for stream in self.streams[cseq]]
+            retval = [(stream.status in ["active", "on hold"]) and tuple(stream.rtp.callee.local_or_advertised) or (stream.rtp.callee.local_or_advertised.host, 0) for stream in self.streams[cseq]]
         else:
-            retval = [(stream.status in ["active", "on hold"]) and tuple(stream.rtp.caller.local) or (stream.rtp.caller.local.host, 0) for stream in self.streams[cseq]]
+            retval = [(stream.status in ["active", "on hold"]) and tuple(stream.rtp.caller.local_or_advertised) or (stream.rtp.caller.local_or_advertised.host, 0) for stream in self.streams[cseq]]
         return retval
 
     def cleanup(self):
_______________________________________________
Devel mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/devel

Reply via email to