|
1
|
|
|
# Copyright 2018 Mathias WOLFF |
|
2
|
|
|
# This file is part of pyfreebilling. |
|
3
|
|
|
# |
|
4
|
|
|
# pyfreebilling is free software: you can redistribute it and/or modify |
|
5
|
|
|
# it under the terms of the Affero GNU General Public License as published by |
|
6
|
|
|
# the Free Software Foundation, either version 3 of the License, or |
|
7
|
|
|
# (at your option) any later version. |
|
8
|
|
|
# |
|
9
|
|
|
# pyfreebilling is distributed in the hope that it will be useful, |
|
10
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12
|
|
|
# GNU General Public License for more details. |
|
13
|
|
|
# |
|
14
|
|
|
# You should have received a copy of the GNU Affero General Public License |
|
15
|
|
|
# along with pyfreebilling. If not, see <http://www.gnu.org/licenses/> |
|
16
|
|
|
|
|
17
|
|
|
from django.core.urlresolvers import reverse |
|
18
|
|
|
from django.db import models as models |
|
19
|
|
|
from django.db.models import * |
|
20
|
|
|
from django.conf import settings |
|
21
|
|
|
from django.utils.translation import ugettext_lazy as _ |
|
22
|
|
|
|
|
23
|
|
|
from django_extensions.db import fields as extension_fields |
|
24
|
|
|
from django_extensions.db.fields import AutoSlugField |
|
25
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
class UacReg(models.Model): |
|
28
|
|
|
|
|
29
|
|
|
# Fields |
|
30
|
|
|
l_uuid = models.CharField(max_length=64, default="", db_index=True, help_text=_(u"Local unique id used to build and match contact addresses.")) |
|
31
|
|
|
l_username = models.CharField(max_length=64, default="", help_text=_(u"Local username")) |
|
32
|
|
|
l_domain = models.CharField(max_length=64, default="", help_text=_(u"Local domain")) |
|
33
|
|
|
r_username = models.CharField(max_length=64, default="", help_text=_(u"Remote username")) |
|
34
|
|
|
r_domain = models.CharField(max_length=64, default="", help_text=_(u"Remote domain")) |
|
35
|
|
|
realm = models.CharField(max_length=64, default="", help_text=_(u"realm")) |
|
36
|
|
|
auth_username = models.CharField(max_length=64, default="", help_text=_(u"Auth username")) |
|
37
|
|
|
auth_password = models.CharField(max_length=64, default="", help_text=_(u"Auth password")) |
|
38
|
|
|
auth_ha1 = models.CharField(max_length=128, default="", help_text=_(u"Hashed (HA1) auth password")) |
|
39
|
|
|
auth_proxy = models.CharField(max_length=128, default="", help_text=_(u"Outbound proxy SIP address")) |
|
40
|
|
|
expires = models.IntegerField(default=0, help_text=_(u"Expiration time in seconds, 0 means disabled")) |
|
41
|
|
|
flags = models.IntegerField(default=0, help_text=_(u"Flags to control the behaviour")) |
|
42
|
|
|
reg_delay = models.IntegerField(default=0, help_text=_(u"initial registration delay")) |
|
43
|
|
|
|
|
44
|
|
|
|
|
45
|
|
|
class Meta: |
|
46
|
|
|
db_table = 'uacreg' |
|
47
|
|
|
app_label = 'endpoint' |
|
48
|
|
|
ordering = ('-pk',) |
|
49
|
|
|
|
|
50
|
|
|
def __unicode__(self): |
|
51
|
|
|
return u'%s' % self.pk |
|
52
|
|
|
|
|
53
|
|
|
def get_absolute_url(self): |
|
54
|
|
|
return reverse('endpoint_uacreg_detail', args=(self.pk,)) |
|
55
|
|
|
|
|
56
|
|
|
|
|
57
|
|
|
def get_update_url(self): |
|
58
|
|
|
return reverse('endpoint_uacreg_update', args=(self.pk,)) |
|
59
|
|
|
|
|
60
|
|
|
|
|
61
|
|
|
class Trusted(models.Model): |
|
62
|
|
|
|
|
63
|
|
|
# Choices |
|
64
|
|
|
PROTO_CHOICES = ( |
|
65
|
|
|
('any', 'any'), |
|
66
|
|
|
('udp', 'udp'), |
|
67
|
|
|
('tcp', 'tcp'), |
|
68
|
|
|
('tls', 'tls'), |
|
69
|
|
|
('sctp', 'sctp'), |
|
70
|
|
|
) |
|
71
|
|
|
|
|
72
|
|
|
# Fields |
|
73
|
|
|
src_ip = models.CharField(max_length=50, db_index=True, default="", help_text=_(u"Source address is equal to source address of request")) |
|
74
|
|
|
proto = models.CharField(max_length=4, choices=PROTO_CHOICES, default="any", help_text=_(u"Transport protocol is either any or equal to transport protocol of request")) |
|
75
|
|
|
from_pattern = models.CharField(max_length=64, null=True, blank=True, help_text=_(u"Regular expression matches From URI of request.")) |
|
76
|
|
|
ruri_pattern = models.CharField(max_length=64, null=True, blank=True, help_text=_(u"Regular expression matches Request URI of request.")) |
|
77
|
|
|
tag = models.CharField(max_length=64, default="", help_text=_(u"Tag")) |
|
78
|
|
|
priority = models.IntegerField(default=0, help_text=_(u"Priority of rule")) |
|
79
|
|
|
|
|
80
|
|
|
|
|
81
|
|
|
class Meta: |
|
82
|
|
|
db_table = 'trusted' |
|
83
|
|
|
app_label = 'endpoint' |
|
84
|
|
|
ordering = ('-pk',) |
|
85
|
|
|
|
|
86
|
|
|
def __unicode__(self): |
|
87
|
|
|
return u'%s' % self.pk |
|
88
|
|
|
|
|
89
|
|
|
def get_absolute_url(self): |
|
90
|
|
|
return reverse('endpoint_trusted_detail', args=(self.pk,)) |
|
91
|
|
|
|
|
92
|
|
|
|
|
93
|
|
|
def get_update_url(self): |
|
94
|
|
|
return reverse('endpoint_trusted_update', args=(self.pk,)) |
|
95
|
|
|
|