Page MenuHomePhabricator

No OneTemporary

diff --git a/config.ini.sample b/config.ini.sample
index b0b3d47..119f77f 100644
--- a/config.ini.sample
+++ b/config.ini.sample
@@ -1,135 +1,138 @@
; SylkServer configuration file
[Server]
; The following settings are the default used by the software, uncomment
; them only if you want to make changes
; default_application = conference
; Statically map a Request URI to a specific application. In the example
; below, 123 is matched 1st against the domain part, than the username part
; of the Request URI This static mapping can be overwritten by adding
; X-Sylk-App header set to the value of a valid SylkServer application name
; application_map = echo:echo,123:conference,test:ircconference,gmail.com:xmppgateway
; Disable the specified applications
; disabled_applications =
; Directory where extra applications are stored
; extra_applications_dir =
trace_dir = /var/log/sylkserver
; trace_core = False
; trace_sip = False
; trace_msrp = False
; trace_notifications = False
+; Log level (one of debug, info, warning, error or critical).
+;log_level = info
+
; TLS is used by default for SIP signaling and MSRP media using a
; self-signed certificate. You may want to use a properly signed X.509
; certificate and configure it below
; The X.509 Certificate Authorities file
ca_file = /etc/sylkserver/tls/ca.crt
; The file containing X.509 certificate and private key in unencrypted format
certificate = /etc/sylkserver/tls/default.crt
; verify_server = False
; Enable Bonjour capabilities for applications
; enable_bonjour = False
; Base directory for files created by the server, excluding log files
; spool_dir = /var/spool/sylkserver
[SIP]
; SIP transport settings
; IP address used for SIP signaling and RTP media; an empty string or 'any' means listening on
; the interface used by the default route
; local_ip =
; IP address to be advertised in the SDP, useful in 1-to-1 NAT scenarios such as Amazon EC2
; advertised_ip =
; Ports used for SIP transports, if not set to any value the transport will be disabled
; local_udp_port = 5060
; local_tcp_port = 5060
; local_tls_port = 5061
; If set, all outbound SIP requests will be sent through this SIP proxy
; The proxy address format is: proxy.example.com:5061;transport=tls
; Transport can be udp, tcp or tls, if skipped it is considered udp
; If only the hostname is set, RFC3263 lookups are performed to lookup
; the outbound proxy server address
; outbound_proxy =
; A comma-separated list of hosts or networks to trust.
; The elements can be an IP address in CIDR format, a
; hostname or an IP address (in the latter 2 a mask of 32
; is assumed), or the special keywords 'any' and 'none'
; (being equivalent to 0.0.0.0/0 and 0.0.0.0/32
; respectively). It defaults to 'any'.
; trusted_peers =
; Toggle ICE support (RFC 5245)
; enable_ice = False
[MSRP]
; MSRP transport settings
; A valid X.509 certificate is required for MSRP to work over TLS.
; TLS is enabled by default, a default TLS certificate is provided with SylkServer.
; use_tls = True
[RTP]
; RTP transport settings
; Allowed codec list, valid values: opus, G722, speex, PCMU, PCMA, iLBC, GSM
; audio_codecs = opus,G722,speex,PCMU,PCMA
; Port range used for RTP
; port_range = 50000:50500
; SRTP valid values: disabled, sdes, zrtp, opportunistic
; srtp_encryption = opportunistic
; RTP stream timeout, session will be disconnected after this value
; timeout = 30
; Audio sampling rate
; sample_rate = 48000
[WebServer]
; Global web server settings
; IP address used for serving HTTP(S) requests, empty string
; means listen on interface used by the default route
; local_ip =
; Port where the web server will listen on, set to 0 for random
; local_port = 10888
; X.509 server certificate for HTTPS connections, the certificate private
; key must be concatenated inside the same file, set to empty in order to
; disable HTTPS
; certificate = /etc/sylkserver/tls/default.crt
; Certificat chain file containing all the certificates that the server
; should present to the client. If specified, it must also contain the
; certificate in the file specified by the 'certificate' option.
; certificate_chain
; Hostname used when publishing the server URL. Must match the common name
; of server X.509 certificate set above, otherwise clients will raise
; warning. If not set the listening IP address will be used
; hostname =
diff --git a/sylk/configuration/__init__.py b/sylk/configuration/__init__.py
index aab506e..1aef305 100644
--- a/sylk/configuration/__init__.py
+++ b/sylk/configuration/__init__.py
@@ -1,87 +1,88 @@
from application.configuration import ConfigSection, ConfigSetting
from application.configuration.datatypes import NetworkRangeList, StringList
from application.system import host
from sipsimple.configuration.datatypes import NonNegativeInteger, SampleRate
from sylk import configuration_filename
-from sylk.configuration.datatypes import AudioCodecs, IPAddress, Path, Port, PortRange, SIPProxyAddress, SRTPEncryption
+from sylk.configuration.datatypes import AudioCodecs, IPAddress, Path, Port, PortRange, SIPProxyAddress, SRTPEncryption, LogLevel
from sylk.resources import Resources, VarResources
from sylk.tls import Certificate, PrivateKey
class ServerConfig(ConfigSection):
__cfgfile__ = configuration_filename
__section__ = 'Server'
ca_file = ConfigSetting(type=Path, value=Path(Resources.get('tls/ca.crt')))
certificate = ConfigSetting(type=Path, value=Path(Resources.get('tls/default.crt')))
verify_server = False
enable_bonjour = False
default_application = 'conference'
application_map = ConfigSetting(type=StringList, value=['echo:echo'])
disabled_applications = ConfigSetting(type=StringList, value='')
extra_applications_dir = ConfigSetting(type=Path, value=None)
trace_dir = ConfigSetting(type=Path, value=Path(VarResources.get('log/sylkserver')))
trace_core = False
trace_sip = False
trace_msrp = False
trace_notifications = False
+ log_level = ConfigSetting(type=LogLevel, value=LogLevel('info'))
spool_dir = ConfigSetting(type=Path, value=Path(VarResources.get('spool/sylkserver')))
class SIPConfig(ConfigSection):
__cfgfile__ = configuration_filename
__section__ = 'SIP'
local_ip = ConfigSetting(type=IPAddress, value=IPAddress(host.default_ip))
local_udp_port = ConfigSetting(type=Port, value=5060)
local_tcp_port = ConfigSetting(type=Port, value=5060)
local_tls_port = ConfigSetting(type=Port, value=5061)
advertised_ip = ConfigSetting(type=IPAddress, value=None)
outbound_proxy = ConfigSetting(type=SIPProxyAddress, value=None)
trusted_peers = ConfigSetting(type=NetworkRangeList, value=NetworkRangeList('any'))
enable_ice = False
class MSRPConfig(ConfigSection):
__cfgfile__ = configuration_filename
__section__ = 'MSRP'
use_tls = True
class RTPConfig(ConfigSection):
__cfgfile__ = configuration_filename
__section__ = 'RTP'
audio_codecs = ConfigSetting(type=AudioCodecs, value=['opus', 'G722', 'speex', 'PCMA', 'PCMU'])
port_range = ConfigSetting(type=PortRange, value=PortRange('50000:50500'))
srtp_encryption = ConfigSetting(type=SRTPEncryption, value='opportunistic')
timeout = ConfigSetting(type=NonNegativeInteger, value=30)
sample_rate = ConfigSetting(type=SampleRate, value=48000)
class WebServerConfig(ConfigSection):
__cfgfile__ = configuration_filename
__section__ = 'WebServer'
local_ip = ConfigSetting(type=IPAddress, value=IPAddress(host.default_ip))
local_port = ConfigSetting(type=Port, value=10888)
hostname = ''
certificate = ConfigSetting(type=Path, value=None)
certificate_chain = ConfigSetting(type=Path, value=None)
class ThorNodeConfig(ConfigSection):
__cfgfile__ = configuration_filename
__section__ = 'ThorNetwork'
enabled = False
domain = "sipthor.net"
multiply = 1000
certificate = ConfigSetting(type=Certificate, value=None)
private_key = ConfigSetting(type=PrivateKey, value=None)
ca = ConfigSetting(type=Certificate, value=None)
diff --git a/sylk/configuration/datatypes.py b/sylk/configuration/datatypes.py
index 74571c9..1e52051 100644
--- a/sylk/configuration/datatypes.py
+++ b/sylk/configuration/datatypes.py
@@ -1,176 +1,188 @@
import os
import re
import socket
import urllib
import urlparse
+from application import log
from application.system import host
from sipsimple.configuration.datatypes import AudioCodecList, Hostname, SIPTransport
class AudioCodecs(list):
def __new__(cls, value):
if isinstance(value, (tuple, list)):
return [str(x) for x in value if x in AudioCodecList.available_values] or None
elif isinstance(value, basestring):
if value.lower() in ('none', ''):
return None
return [x for x in re.split(r'\s*,\s*', value) if x in AudioCodecList.available_values] or None
else:
raise TypeError("value must be a string, list or tuple")
class IPAddress(str):
"""An IP address in quad dotted number notation"""
def __new__(cls, value):
try:
socket.inet_aton(value)
except socket.error:
raise ValueError("invalid IP address: %r" % value)
except TypeError:
raise TypeError("value must be a string")
return str.__new__(cls, value)
@property
def normalized(self):
if self == '0.0.0.0':
return host.default_ip or '127.0.0.1'
return str(self)
class Port(int):
def __new__(cls, value):
try:
value = int(value)
except ValueError:
return None
if not (0 <= value <= 65535):
raise ValueError("illegal port value: %s" % value)
return value
class PortRange(object):
"""A port range in the form start:end with start and end being even numbers in the [1024, 65536] range"""
def __init__(self, value):
self.start, self.end = [int(p) for p in value.split(':', 1)]
allowed = xrange(1024, 65537, 2)
if not (self.start in allowed and self.end in allowed and self.start < self.end):
raise ValueError("bad range: %r: ports must be even numbers in the range [1024, 65536] with start < end" % value)
class SIPProxyAddress(object):
_description_re = re.compile(r"^(?P<host>(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})|([a-zA-Z0-9\-_]+(\.[a-zA-Z0-9\-_]+)*))(:(?P<port>\d+))?(;transport=(?P<transport>.+))?$")
def __new__(cls, description):
if not description:
return None
if not cls._description_re.match(description):
raise ValueError("illegal SIP proxy address: %s" % description)
return super(SIPProxyAddress, cls).__new__(cls)
def __init__(self, description):
match = self.__class__._description_re.match(description)
data = match.groupdict()
host = data.get('host')
port = data.get('port', None) or 5060
transport = data.get('transport', None) or 'udp'
self.host = Hostname(host)
self.port = Port(port)
if self.port == 0:
raise ValueError("illegal port value: 0")
self.transport = SIPTransport(transport)
def __getstate__(self):
return unicode(self)
def __setstate__(self, state):
if not self.__class__._description_re.match(state):
raise ValueError("illegal SIP proxy address: %s" % state)
self.__init__(state)
def __eq__(self, other):
try:
return (self.host, self.port, self.transport) == (other.host, other.port, other.transport)
except AttributeError:
return False
def __ne__(self, other):
return not self.__eq__(other)
def __hash__(self):
return hash((self.host, self.port, self.transport))
def __unicode__(self):
return u'%s:%d;transport=%s' % (self.host, self.port, self.transport)
class Path(unicode):
def __new__(cls, path):
if path:
path = os.path.normpath(path)
return unicode.__new__(cls, path)
@property
def normalized(self):
return os.path.expanduser(self)
class URL(object):
"""A class describing an URL and providing access to its elements"""
def __init__(self, url):
scheme, netloc, path, query, fragment = urlparse.urlsplit(url)
if netloc:
if "@" in netloc:
userinfo, hostport = netloc.split("@", 1)
if ":" in userinfo:
username, password = userinfo.split(":", 1)
else:
username, password = userinfo, None
else:
username = password = None
hostport = netloc
if ':' in hostport:
host, port = hostport.split(':', 1)
else:
host, port = hostport, None
else:
username = password = host = port = None
self.original_url = url
self.scheme = scheme
self.username = username
self.password = password
self.host = host
self.port = int(port) if port is not None else None
self.path = urllib.url2pathname(path)
self.query_items = dict(urlparse.parse_qsl(query))
self.fragment = fragment
def __str__(self):
return urlparse.urlunsplit((self.scheme, self.netloc, urllib.pathname2url(self.path), self.query, self.fragment))
def __repr__(self):
return '%s(%r)' % (self.__class__.__name__, self.__str__())
url = property(__str__)
@property
def query(self):
return urllib.urlencode(self.query_items)
@property
def netloc(self):
authinfo = ':'.join(str(x) for x in (self.username, self.password) if x is not None) or None
hostport = ':'.join(str(x) for x in (self.host or '', self.port) if x is not None)
return '@'.join(x for x in (authinfo, hostport) if x is not None)
class SRTPEncryption(str):
available_values = ('opportunistic', 'sdes', 'zrtp', 'disabled')
def __new__(cls, value):
value = str(value)
if value not in cls.available_values:
raise ValueError("illegal value for SRTP encryption: %s" % value)
return value
+
+class LogLevel(log.NamedLevel):
+ __levelmap__ = {value.name: value for value in (log.level.DEBUG, log.level.INFO, log.level.WARNING, log.level.ERROR, log.level.CRITICAL)}
+
+ def __new__(cls, value):
+ value = str(value).upper()
+ if value not in cls.__levelmap__:
+ raise ValueError("illegal value for log level: %s" % value)
+ log.level.current = cls.__levelmap__[value]
+ return log.level.current
+

File Metadata

Mime Type
text/x-diff
Expires
Sat, Feb 1, 11:30 AM (1 d, 3 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3489291
Default Alt Text
(14 KB)

Event Timeline