Page MenuHomePhabricator

No OneTemporary

diff --git a/mediaproxy/__init__.py b/mediaproxy/__init__.py
index b6ef332..0b606bf 100644
--- a/mediaproxy/__init__.py
+++ b/mediaproxy/__init__.py
@@ -1,8 +1,8 @@
"""Mediaproxy implements a media relay for SIP calls"""
__version__ = "2.6.6"
config_directory = '/etc/mediaproxy'
-runtime_directory = '/var/run/mediaproxy'
+runtime_directory = '/run/mediaproxy'
configuration_file = 'config.ini'
diff --git a/mediaproxy/configuration/__init__.py b/mediaproxy/configuration/__init__.py
index 4463d47..1c71c9a 100644
--- a/mediaproxy/configuration/__init__.py
+++ b/mediaproxy/configuration/__init__.py
@@ -1,88 +1,88 @@
from application.configuration import ConfigSection, ConfigSetting
from application.configuration.datatypes import IPAddress, NetworkRangeList
from application.system import host
from mediaproxy import configuration_file
from mediaproxy.configuration.datatypes import AccountingModuleList, DispatcherIPAddress, DispatcherAddressList, DispatcherManagementAddress, PortRange, PositiveInteger, SIPThorDomain, X509NameValidator
class DispatcherConfig(ConfigSection):
__cfgfile__ = configuration_file
__section__ = 'Dispatcher'
socket_path = "dispatcher.sock"
listen = ConfigSetting(type=DispatcherIPAddress, value=DispatcherIPAddress("any"))
listen_management = ConfigSetting(type=DispatcherManagementAddress, value=DispatcherManagementAddress("any"))
relay_timeout = 5 # How much to wait for an answer from a relay
relay_recover_interval = 60 # How much to wait for an unresponsive relay to recover, before disconnecting it
cleanup_dead_relays_after = 43200 # 12 hours
cleanup_expired_sessions_after = 86400 # 24 hours
management_use_tls = True
accounting = ConfigSetting(type=AccountingModuleList, value=[])
passport = ConfigSetting(type=X509NameValidator, value=None)
management_passport = ConfigSetting(type=X509NameValidator, value=None)
class RelayConfig(ConfigSection):
__cfgfile__ = configuration_file
__section__ = 'Relay'
relay_ip = ConfigSetting(type=IPAddress, value=host.default_ip)
advertised_ip = ConfigSetting(type=IPAddress, value=None)
stream_timeout = 90
on_hold_timeout = 7200
traffic_sampling_period = 15
userspace_transmit_every = 1
dispatchers = ConfigSetting(type=DispatcherAddressList, value=[])
port_range = PortRange("50000:60000")
dns_check_interval = PositiveInteger(60)
keepalive_interval = PositiveInteger(10)
reconnect_delay = PositiveInteger(10)
passport = ConfigSetting(type=X509NameValidator, value=None)
routable_private_ranges = ConfigSetting(type=NetworkRangeList, value=[])
class OpenSIPSConfig(ConfigSection):
__cfgfile__ = configuration_file
__section__ = 'OpenSIPS'
- socket_path = '/var/run/opensips/socket'
+ socket_path = '/run/opensips/socket'
location_table = 'location'
class RadiusConfig(ConfigSection):
__cfgfile__ = configuration_file
__section__ = 'Radius'
config_file = "/etc/opensips/radius/client.conf"
additional_dictionary = "radius/dictionary"
class DatabaseConfig(ConfigSection):
__cfgfile__ = configuration_file
__section__ = 'Database'
dburi = ""
sessions_table = "media_sessions"
callid_column = "call_id"
fromtag_column = "from_tag"
totag_column = "to_tag"
info_column = "info"
class TLSConfig(ConfigSection):
__cfgfile__ = configuration_file
__section__ = 'TLS'
certs_path = 'tls'
verify_interval = 300
class ThorNetworkConfig(ConfigSection):
__cfgfile__ = configuration_file
__section__ = 'ThorNetwork'
domain = ConfigSetting(type=SIPThorDomain, value=None)
node_ip = host.default_ip
diff --git a/test/common.py b/test/common.py
index d51d750..58a0607 100644
--- a/test/common.py
+++ b/test/common.py
@@ -1,214 +1,214 @@
# Copyright (C) 2008 AG Projects
#
import sys
sys.path.append(".")
sys.path.append("..")
import os
import random
import string
import struct
import mediaproxy
from application.system import host
from application.configuration import *
from application.process import process
process.system_config_directory = mediaproxy.config_directory
from twisted.internet.protocol import DatagramProtocol, ClientFactory
from twisted.protocols.basic import LineOnlyReceiver
from twisted.internet.task import LoopingCall
from twisted.internet.defer import Deferred, DeferredList, succeed
from twisted.internet import reactor
from mediaproxy.headers import EncodingDict
class Config(ConfigSection):
__cfgfile__ = mediaproxy.configuration_file
__section__ = 'Dispatcher'
- socket = "/var/run/mediaproxy/dispatcher.sock"
+ socket = "/run/mediaproxy/dispatcher.sock"
random_data = os.urandom(512)
stun_data = struct.pack("!HHIIII", 0x0001, 0, 0x2112A442, 0, 0, 0)
default_host_ip = host.default_ip
class OpenSIPSControlClientProtocol(LineOnlyReceiver):
def __init__(self):
self.defer = None
def lineReceived(self, line):
if line == "error":
print "got error from dispatcher!"
reactor.stop()
elif self.defer is not None:
print "got ip/ports from dispatcher: %s" % line
ip, ports = line.split(" ", 1)
defer = self.defer
self.defer = None
defer.callback((ip, [int(i) for i in ports.split()]))
else:
print "got reply from dispatcher: %s" % line
defer = self.defer
self.defer = None
defer.callback(line)
def _send_command(self, command, headers):
self.defer = Deferred()
data = "\r\n".join([command] + ["%s: %s" % item for item in headers.iteritems()] + ["", ""])
#print "writing on socket:\n%s" % data
self.transport.write(data)
return self.defer
def update(self, **kw_args):
return self._send_command("update", EncodingDict(kw_args))
def remove(self, **kw_args):
return self._send_command("remove", EncodingDict(kw_args))
class OpenSIPSConnectorFactory(ClientFactory):
protocol = OpenSIPSControlClientProtocol
def __init__(self):
self.defer = Deferred()
def buildProtocol(self, addr):
prot = ClientFactory.buildProtocol(self, addr)
reactor.callLater(0, self.defer.callback, prot)
return prot
class MediaReceiverProtocol(DatagramProtocol):
def __init__(self, endpoint, index):
self.endpoint = endpoint
self.index = index
self.loop = None
self.received_media = False
self.defer = Deferred()
def datagramReceived(self, data, (host, port)):
if not self.received_media:
self.received_media = True
print "received media %d for %s from %s:%d" % (self.index, self.endpoint.name, host, port)
self.defer.callback(None)
def connectionRefused(self):
print "connection refused for media %d for %s" % (self.index, self.endpoint.name)
class Endpoint(object):
def __init__(self, sip_uri, user_agent, is_caller):
if is_caller:
self.name = "caller"
else:
self.name = "callee"
self.sip_uri = sip_uri
self.user_agent = user_agent
self.tag = "".join(random.sample(string.ascii_lowercase, 8))
self.connectors = []
self.media = []
self.cseq = 1
def set_media(self, media):
assert(len(self.connectors) == 0)
self.media = media
for index, (media_type, port, direction, parameters) in enumerate(self.media):
if port != 0:
protocol = MediaReceiverProtocol(self, index)
connector = reactor.listenUDP(port, protocol)
else:
connector = None
self.connectors.append(connector)
return DeferredList([connector.protocol.defer for connector in self.connectors if connector is not None])
def get_media(self, use_old_hold):
if use_old_hold:
ip = "0.0.0.0"
else:
ip = default_host_ip
return [(media_type, ip, port, direction, parameters) for media_type, port, direction, parameters in self.media]
def start_media(self, ip, ports, send_stun=False):
for port, connector in zip(ports, self.connectors):
if connector is not None:
protocol = connector.protocol
if port != 0:
protocol.transport.connect(ip, port)
protocol.loop = LoopingCall(protocol.transport.write, send_stun and stun_data or random_data)
protocol.loop.start(random.uniform(0.5, 1))
else:
protocol.defer.callback(None)
def stop_media(self):
defers = []
for connector in self.connectors:
if connector is not None:
if connector.protocol.loop is not None:
connector.protocol.loop.stop()
connector.protocol.loop = None
defer = connector.stopListening()
if defer is not None:
defers.append(defer)
self.connectors = []
if defers:
return DeferredList(defers)
else:
return succeed(None)
class Session(object):
def __init__(self, caller, callee):
self.caller = caller
self.callee = callee
self.call_id = "".join(random.sample(string.ascii_letters, 24))
def _get_parties(self, party):
party = getattr(self, party)
if party is self.caller:
other = self.callee
else:
other = self.caller
return party, other
def do_update(self, opensips, party, type, is_final, use_old_hold=False):
party, other = self._get_parties(party)
if type == "request":
from_tag = party.tag
to_tag = other.tag
from_uri = party.sip_uri
to_uri = other.sip_uri
cseq = party.cseq
else:
from_tag = other.tag
to_tag = party.tag
from_uri = other.sip_uri
to_uri = party.sip_uri
cseq = other.cseq
if is_final:
defer = opensips.update(call_id = self.call_id, from_tag = from_tag, to_tag = to_tag, from_uri = from_uri, to_uri = to_uri, cseq = cseq, user_agent = party.user_agent, media = party.get_media(use_old_hold), type = type, dialog_id = "12345:67890")
else:
defer = opensips.update(call_id = self.call_id, from_tag = from_tag, to_tag = to_tag, from_uri = from_uri, to_uri = to_uri, cseq = cseq, user_agent = party.user_agent, media = party.get_media(use_old_hold), type = type, dialog_id = "12345:67890")
if is_final:
if type == "request":
party.cseq += 1
else:
other.cseq += 1
return defer
def do_remove(self, opensips, party):
party, other = self._get_parties(party)
opensips.remove(call_id = self.call_id, from_tag = party.tag, to_tag = other.tag)
def connect_to_dispatcher():
factory = OpenSIPSConnectorFactory()
connector = reactor.connectUNIX(Config.socket, factory)
return connector, factory.defer

File Metadata

Mime Type
text/x-diff
Expires
Sat, Nov 23, 4:02 AM (14 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3408743
Default Alt Text
(11 KB)

Event Timeline