diff --git a/debian/control b/debian/control index 44cf104..1c18f2b 100644 --- a/debian/control +++ b/debian/control @@ -1,105 +1,105 @@ Source: mediaproxy Section: net Priority: optional Maintainer: Dan Pascu Uploaders: Tijmen de Mes Build-Depends: debhelper (>= 11), dh-apache2, dh-python, python-all-dev, python-all-dbg, libnetfilter-conntrack-dev, iptables-dev Standards-Version: 4.5.0 Package: mediaproxy-common Architecture: any Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends}, iptables, python-application (>= 2.8.0), - python-cjson, + python-cjson (>= 2.1), python-gnutls (>= 3.0.0), python-pyrad, python-sqlobject, python-twisted-core, python-twisted-names, python-zope.interface Description: MediaProxy common files MediaProxy is a distributed far end NAT traversal solution for media streams of SIP calls. MediaProxy has a dispatcher running on the same host as the OpenSIPS SIP proxy and multiple media relays distributed over the network. The media relays work by manipulating conntrack rules in the Linux kernel to create paths that forward the media streams between the 2 SIP user agents participating in the call. Because it avoids copying stream data between kernel and user space like other implementations, MediaProxy can handle many more media streams at a time, being limited only by the network interface bandwidth and the Linux kernel network layer processing speed. . MediaProxy features secure encrypted communication between the dispatcher and the relays, advanced accounting capabilities using multiple backends, support for any combination of audio and video streams, realtime statistics, T.38 fax support as well as automatic load balancing and redundancy among the active relays. . This package includes files common to all MediaProxy packages. Package: mediaproxy-dispatcher Architecture: all Depends: ${python:Depends}, ${misc:Depends}, mediaproxy-common (>= ${source:Version}) Description: MediaProxy dispatcher for OpenSIPS MediaProxy is a distributed far end NAT traversal solution for media streams of SIP calls. MediaProxy has a dispatcher running on the same host as the OpenSIPS SIP proxy and multiple media relays distributed over the network. The media relays work by manipulating conntrack rules in the Linux kernel to create paths that forward the media streams between the 2 SIP user agents participating in the call. Because it avoids copying stream data between kernel and user space like other implementations, MediaProxy can handle many more media streams at a time, being limited only by the network interface bandwidth and the Linux kernel network layer processing speed. . MediaProxy features secure encrypted communication between the dispatcher and the relays, advanced accounting capabilities using multiple backends, support for any combination of audio and video streams, realtime statistics, T.38 fax support as well as automatic load balancing and redundancy among the active relays. . This package provides the MediaProxy dispatcher. Package: mediaproxy-relay Architecture: all Depends: ${python:Depends}, ${misc:Depends}, mediaproxy-common (>= ${source:Version}) Description: MediaProxy relay for OpenSIPS MediaProxy is a distributed far end NAT traversal solution for media streams of SIP calls. MediaProxy has a dispatcher running on the same host as the OpenSIPS SIP proxy and multiple media relays distributed over the network. The media relays work by manipulating conntrack rules in the Linux kernel to create paths that forward the media streams between the 2 SIP user agents participating in the call. Because it avoids copying stream data between kernel and user space like other implementations, MediaProxy can handle many more media streams at a time, being limited only by the network interface bandwidth and the Linux kernel network layer processing speed. . MediaProxy features secure encrypted communication between the dispatcher and the relays, advanced accounting capabilities using multiple backends, support for any combination of audio and video streams, realtime statistics, T.38 fax support as well as automatic load balancing and redundancy among the active relays. . This package provides the MediaProxy relay. Package: mediaproxy-web-sessions Architecture: all Depends: ${misc:Depends}, libapache2-mod-php Description: MediaProxy sessions web view MediaProxy is a distributed far end NAT traversal solution for media streams of SIP calls. MediaProxy has a dispatcher running on the same host as the OpenSIPS SIP proxy and multiple media relays distributed over the network. The media relays work by manipulating conntrack rules in the Linux kernel to create paths that forward the media streams between the 2 SIP user agents participating in the call. Because it avoids copying stream data between kernel and user space like other implementations, MediaProxy can handle many more media streams at a time, being limited only by the network interface bandwidth and the Linux kernel network layer processing speed. . MediaProxy features secure encrypted communication between the dispatcher and the relays, advanced accounting capabilities using multiple backends, support for any combination of audio and video streams, realtime statistics, T.38 fax support as well as automatic load balancing and redundancy among the active relays. . This package provides a simple web page to display active media sessions. diff --git a/mediaproxy/interfaces/accounting/radius.py b/mediaproxy/interfaces/accounting/radius.py index 687e9e8..87daf3b 100644 --- a/mediaproxy/interfaces/accounting/radius.py +++ b/mediaproxy/interfaces/accounting/radius.py @@ -1,124 +1,124 @@ """Implementation of RADIUS accounting""" from application import log from application.process import process from application.python.queue import EventQueue import pyrad.client import pyrad.dictionary from mediaproxy.configuration import RadiusConfig try: from pyrad.dictfile import DictFile except ImportError: # helper class to make pyrad support the $INCLUDE statement in dictionary files class RadiusDictionaryFile(object): def __init__(self, base_file_name): self.file_names = [base_file_name] self.fd_stack = [open(base_file_name)] def readlines(self): while True: line = self.fd_stack[-1].readline() if line: if line.startswith('$INCLUDE'): file_name = line.rstrip('\n').split(None, 1)[1] if file_name not in self.file_names: self.file_names.append(file_name) self.fd_stack.append(open(file_name)) continue else: yield line else: self.fd_stack.pop() if len(self.fd_stack) == 0: return else: del DictFile class RadiusDictionaryFile(str): pass class Accounting(object): def __init__(self): self.handler = RadiusAccounting() def start(self): self.handler.start() def do_accounting(self, stats): self.handler.put(stats) def stop(self): self.handler.stop() self.handler.join() class RadiusAccounting(EventQueue, pyrad.client.Client): def __init__(self): main_config_file = process.configuration.file(RadiusConfig.config_file) if main_config_file is None: raise RuntimeError('Cannot find the radius configuration file: %r' % RadiusConfig.config_file) try: config = dict(line.rstrip('\n').split(None, 1) for line in open(main_config_file) if len(line.split(None, 1)) == 2 and not line.startswith('#')) secrets = dict(line.rstrip('\n').split(None, 1) for line in open(config['servers']) if len(line.split(None, 1)) == 2 and not line.startswith('#')) server = config['acctserver'] try: server, acctport = server.split(':') acctport = int(acctport) except ValueError: acctport = 1813 secret = secrets[server] dicts = [RadiusDictionaryFile(config['dictionary'])] if RadiusConfig.additional_dictionary: additional_dictionary = process.configuration.file(RadiusConfig.additional_dictionary) if additional_dictionary: dicts.append(RadiusDictionaryFile(additional_dictionary)) else: log.warning('Could not load additional RADIUS dictionary file: %r' % RadiusConfig.additional_dictionary) raddict = pyrad.dictionary.Dictionary(*dicts) timeout = int(config['radius_timeout']) retries = int(config['radius_retries']) except Exception: log.critical('cannot read the RADIUS configuration file') raise - pyrad.client.Client.__init__(self, server, 1812, acctport, secret, raddict) + pyrad.client.Client.__init__(self, server, 1812, acctport, 3799, secret, raddict) self.timeout = timeout self.retries = retries if 'bindaddr' in config and config['bindaddr'] != '*': self.bind((config['bindaddr'], 0)) EventQueue.__init__(self, self.do_accounting) def do_accounting(self, stats): attrs = {} attrs['Acct-Status-Type'] = 'Update' attrs['User-Name'] = 'mediaproxy@default' attrs['Acct-Session-Id'] = stats['call_id'] attrs['Acct-Session-Time'] = stats['duration'] attrs['Acct-Input-Octets'] = sum(stream_stats['caller_bytes'] for stream_stats in stats['streams']) attrs['Acct-Output-Octets'] = sum(stream_stats['callee_bytes'] for stream_stats in stats['streams']) attrs['Sip-From-Tag'] = stats['from_tag'] attrs['Sip-To-Tag'] = stats['to_tag'] or '' attrs['NAS-IP-Address'] = stats['streams'][0]['caller_local'].split(':')[0] attrs['Sip-User-Agents'] = (stats['caller_ua'] + '+' + stats['callee_ua'])[:253] attrs['Sip-Applications'] = ', '.join(sorted(set(stream['media_type'] for stream in stats['streams'] if stream['start_time'] != stream['end_time'])))[:253] attrs['Media-Codecs'] = ', '.join(stream['caller_codec'] for stream in stats['streams'])[:253] if stats['timed_out'] and not stats.get('all_streams_ice', False): attrs['Media-Info'] = 'timeout' elif stats.get('all_streams_ice', False): attrs['Media-Info'] = 'ICE session' else: attrs['Media-Info'] = '' for stream in stats['streams']: if stream['post_dial_delay'] is not None: attrs['Acct-Delay-Time'] = int(stream['post_dial_delay']) break try: self.SendPacket(self.CreateAcctPacket(**attrs)) except Exception, e: log.error('Failed to send radius accounting record: %s' % e)