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
|
|
|
class Version(models.Model): |
27
|
|
|
|
28
|
|
|
# Fields |
29
|
|
|
table_name = CharField(max_length=32, unique=True) |
30
|
|
|
table_version = IntegerField(default=0) |
31
|
|
|
|
32
|
|
|
|
33
|
|
|
class Meta: |
34
|
|
|
db_table = 'version' |
35
|
|
|
app_label = 'kamailio' |
36
|
|
|
ordering = ('-pk',) |
37
|
|
|
|
38
|
|
|
def __unicode__(self): |
39
|
|
|
return u'%s' % self.pk |
40
|
|
|
|
41
|
|
|
def get_absolute_url(self): |
42
|
|
|
return reverse('kamailio_version_detail', args=(self.pk,)) |
43
|
|
|
|
44
|
|
|
def get_update_url(self): |
45
|
|
|
return reverse('kamailio_version_update', args=(self.pk,)) |
46
|
|
|
|
47
|
|
|
|
48
|
|
|
class Location(models.Model): |
49
|
|
|
|
50
|
|
|
# Fields |
51
|
|
|
ruid = CharField(max_length=64, default='', unique=True, help_text=_(u"Record internal unique id")) |
52
|
|
|
username = CharField(max_length=64, default='', help_text=_(u"Username / phone number")) |
53
|
|
|
domain = CharField(max_length=64, null=True, blank=True, help_text=_(u"Doamin name")) |
54
|
|
|
contact = CharField(max_length=512, default='', help_text=_(u"Contact header field value provides a URI whoses meaning depends on the type of request or response it is in.")) |
55
|
|
|
received = CharField(max_length=128, null=True, blank=True, help_text=_(u"Received IP:PORT in the format SIP:IP:PORT")) |
56
|
|
|
path = CharField(max_length=512, null=True, blank=True, help_text=_(u"Path Header(s) per RFC 3327")) |
57
|
|
|
expires = DateTimeField(default='2030-05-28 21:32:15', db_index=True, help_text=_(u"Date and time when this entry expires.")) |
58
|
|
|
q = DecimalField(max_digits=10, decimal_places=2, default=1.0, help_text=_(u"Value used for preferential routing.")) |
59
|
|
|
callid = CharField(max_length=255, default='Default-Call-ID', help_text=_(u" Call-ID header field uniquely identifies a particular invitation or all registrations of a particular client.")) |
60
|
|
|
cseq = IntegerField(default=1, help_text=_(u"CSeq header field contains a single decimal sequence number and the request method.")) |
61
|
|
|
last_modified = DateTimeField(default='2000-01-01 00:00:01', help_text=_(u"Date and time when this entry was last modified")) |
62
|
|
|
flags = IntegerField(default=0, help_text=_(u"Internal flags")) |
63
|
|
|
cflags = IntegerField(default=0, help_text=_(u"Branch and contact flags")) |
64
|
|
|
user_agent = CharField(max_length=255, default='', help_text=_(u"User-Agent header field contains information about the UAC originating the request.")) |
65
|
|
|
socket = CharField(max_length=64, null=True, blank=True, help_text=_(u"Socket used to connect to Kamailio. For example: UDP:IP:PORT")) |
66
|
|
|
methods = IntegerField(null=True, blank=True, help_text=_(u"Flags that indicate the SIP Methods this contact will accept.")) |
67
|
|
|
instance = CharField(max_length=255, null=True, blank=True, help_text=_(u"The value of SIP instance parameter for GRUU.")) |
68
|
|
|
reg_id = IntegerField(default=0, help_text=_(u"The value of reg-id contact parameter")) |
69
|
|
|
server_id = IntegerField(default=0, help_text=_(u"The value of server_id from configuration file")) |
70
|
|
|
connection_id = IntegerField(default=0, help_text=_(u"The value of connection id for location record")) |
71
|
|
|
keepalive = IntegerField(default=0, help_text=_(u"The value to control sending keep alive requests")) |
72
|
|
|
partition = IntegerField(default=0, help_text=_(u"The value to of the partition for keep alive requests")) |
73
|
|
|
|
74
|
|
|
|
75
|
|
|
class Meta: |
76
|
|
|
db_table = 'location' |
77
|
|
|
app_label = 'kamailio' |
78
|
|
|
ordering = ('-pk',) |
79
|
|
|
verbose_name = _(u"user location") |
80
|
|
|
indexes = [ |
81
|
|
|
models.Index(fields=['username', 'domain', 'contact']), |
82
|
|
|
models.Index(fields=['server_id', 'connection_id']), |
83
|
|
|
] |
84
|
|
|
|
85
|
|
|
def __unicode__(self): |
86
|
|
|
return u'%s' % self.pk |
87
|
|
|
|
88
|
|
|
def get_absolute_url(self): |
89
|
|
|
return reverse('kamailio_location_detail', args=(self.pk,)) |
90
|
|
|
|
91
|
|
|
def get_update_url(self): |
92
|
|
|
return reverse('kamailio_location_update', args=(self.pk,)) |
93
|
|
|
|
94
|
|
|
|
95
|
|
View Code Duplication |
class LocationAttrs(models.Model): |
|
|
|
|
96
|
|
|
|
97
|
|
|
# Fields |
98
|
|
|
ruid = CharField(max_length=64, default='', help_text=_(u"Record internal unique id")) |
99
|
|
|
username = CharField(max_length=64, default='', help_text=_(u"Username / phone number")) |
100
|
|
|
domain = CharField(max_length=64, null=True, blank=True, help_text=_(u"Domain name")) |
101
|
|
|
aname = CharField(max_length=64, default='', help_text=_(u"Attribute name")) |
102
|
|
|
atype = IntegerField(default=0, help_text=_(u"Attribute type")) |
103
|
|
|
avalue = CharField(max_length=255, default='', help_text=_(u"Attribute value")) |
104
|
|
|
last_modified = DateTimeField(default='2000-01-01 00:00:01', db_index=True, help_text=_(u"Date and time when this entry was last modified")) |
105
|
|
|
|
106
|
|
|
|
107
|
|
|
class Meta: |
108
|
|
|
db_table = 'location_attrs' |
109
|
|
|
app_label = 'kamailio' |
110
|
|
|
ordering = ('-pk',) |
111
|
|
|
indexes = [ |
112
|
|
|
models.Index(fields=['username', 'domain', 'ruid']), |
113
|
|
|
] |
114
|
|
|
|
115
|
|
|
def __unicode__(self): |
116
|
|
|
return u'%s' % self.pk |
117
|
|
|
|
118
|
|
|
def get_absolute_url(self): |
119
|
|
|
return reverse('kamailio_locationattrs_detail', args=(self.pk,)) |
120
|
|
|
|
121
|
|
|
def get_update_url(self): |
122
|
|
|
return reverse('kamailio_locationattrs_update', args=(self.pk,)) |
123
|
|
|
|
124
|
|
|
|
125
|
|
|
class UserBlackList(models.Model): |
126
|
|
|
# Choices |
127
|
|
|
WHITELIST_CHOICES = ( |
128
|
|
|
('0', 'blacklist'), |
129
|
|
|
('1', 'whitelist'), |
130
|
|
|
) |
131
|
|
|
# Fields |
132
|
|
|
username = CharField(max_length=64, default='', help_text=_(u"The user that is used for the blacklist lookup")) |
133
|
|
|
domain = CharField(max_length=64, default='', help_text=_(u"The domain that is used for the blacklist lookup")) |
134
|
|
|
prefix = CharField(max_length=64, default='', help_text=_(u"The prefix that is matched for the blacklist")) |
135
|
|
|
whitelist = CharField( |
136
|
|
|
max_length=1, |
137
|
|
|
choices=WHITELIST_CHOICES, |
138
|
|
|
default='0', |
139
|
|
|
help_text=_(u"Specify if this a blacklist (0) or a whitelist (1) entry") |
140
|
|
|
) |
141
|
|
|
|
142
|
|
|
|
143
|
|
|
class Meta: |
144
|
|
|
db_table = 'userblacklist' |
145
|
|
|
app_label = 'kamailio' |
146
|
|
|
ordering = ('-pk',) |
147
|
|
|
indexes = [ |
148
|
|
|
models.Index(fields=['username', 'domain', 'prefix']), |
149
|
|
|
] |
150
|
|
|
|
151
|
|
|
def __unicode__(self): |
152
|
|
|
return u'%s' % self.pk |
153
|
|
|
|
154
|
|
|
def get_absolute_url(self): |
155
|
|
|
return reverse('kamailio_userblacklist_detail', args=(self.pk,)) |
156
|
|
|
|
157
|
|
|
def get_update_url(self): |
158
|
|
|
return reverse('kamailio_userblacklist_update', args=(self.pk,)) |
159
|
|
|
|
160
|
|
|
|
161
|
|
|
class GlobalBlackList(models.Model): |
162
|
|
|
# Choices |
163
|
|
|
WHITELIST_CHOICES = ( |
164
|
|
|
('0', 'blacklist'), |
165
|
|
|
('1', 'whitelist'), |
166
|
|
|
) |
167
|
|
|
# Fields |
168
|
|
|
prefix = CharField(max_length=64, default='', db_index=True, help_text=_(u"The prefix that is matched for the blacklist")) |
169
|
|
|
whitelist = CharField( |
170
|
|
|
max_length=1, |
171
|
|
|
choices=WHITELIST_CHOICES, |
172
|
|
|
default='0', |
173
|
|
|
help_text=_(u"Specify if this a blacklist (0) or a whitelist (1) entry") |
174
|
|
|
) |
175
|
|
|
description = TextField(max_length=255, default='', help_text=_(u"A comment for the entry")) |
176
|
|
|
|
177
|
|
|
|
178
|
|
|
class Meta: |
179
|
|
|
db_table = 'globalblacklist' |
180
|
|
|
app_label = 'kamailio' |
181
|
|
|
ordering = ('-pk',) |
182
|
|
|
|
183
|
|
|
def __unicode__(self): |
184
|
|
|
return u'%s' % self.pk |
185
|
|
|
|
186
|
|
|
def get_absolute_url(self): |
187
|
|
|
return reverse('kamailio_globalblacklist_detail', args=(self.pk,)) |
188
|
|
|
|
189
|
|
|
def get_update_url(self): |
190
|
|
|
return reverse('kamailio_globalblacklist_update', args=(self.pk,)) |
191
|
|
|
|
192
|
|
|
|
193
|
|
View Code Duplication |
class SpeedDial(models.Model): |
|
|
|
|
194
|
|
|
|
195
|
|
|
# Fields |
196
|
|
|
username = CharField(max_length=64, default='', help_text=_(u"Username / phone number")) |
197
|
|
|
domain = CharField(max_length=64, default='', help_text=_(u"Domain name")) |
198
|
|
|
sd_username = CharField(max_length=64, default='', help_text=_(u"Speed dial username")) |
199
|
|
|
sd_domain = CharField(max_length=64, default='', help_text=_(u"Speed dial domain")) |
200
|
|
|
new_uri = CharField(max_length=128, default='', help_text=_(u"New URI")) |
201
|
|
|
fname = CharField(max_length=64, default='', help_text=_(u"First name")) |
202
|
|
|
lname = CharField(max_length=64, default='', help_text=_(u"Last name")) |
203
|
|
|
description = CharField(max_length=64, default='', help_text=_(u"Description")) |
204
|
|
|
|
205
|
|
|
|
206
|
|
|
class Meta: |
207
|
|
|
db_table = 'speed_dial' |
208
|
|
|
app_label = 'kamailio' |
209
|
|
|
ordering = ('-pk',) |
210
|
|
|
unique_together = [ |
211
|
|
|
["username", "domain", "sd_domain", "sd_username"], |
212
|
|
|
] |
213
|
|
|
|
214
|
|
|
def __unicode__(self): |
215
|
|
|
return u'%s' % self.pk |
216
|
|
|
|
217
|
|
|
def get_absolute_url(self): |
218
|
|
|
return reverse('kamailio_speeddial_detail', args=(self.pk,)) |
219
|
|
|
|
220
|
|
|
def get_update_url(self): |
221
|
|
|
return reverse('kamailio_speeddial_update', args=(self.pk,)) |
222
|
|
|
|
223
|
|
|
|
224
|
|
|
class PipeLimit(models.Model): |
225
|
|
|
# choices |
226
|
|
|
ALGO_CHOICES = ( |
227
|
|
|
('NOP', 'NOP'), |
228
|
|
|
('RED', 'RED'), |
229
|
|
|
('TAILDROP', 'TAILDROP'), |
230
|
|
|
('FEEDBACK', 'FEEDBACK'), |
231
|
|
|
('NETWORK', 'NETWORK'), |
232
|
|
|
) |
233
|
|
|
# Fields |
234
|
|
|
pipeid = CharField(max_length=64, default='', help_text=_(u"Unique ID for pipe")) |
235
|
|
|
algorithm = CharField( |
236
|
|
|
max_length=32, |
237
|
|
|
choices=ALGO_CHOICES, |
238
|
|
|
default='TAILDROP', |
239
|
|
|
help_text=_(u"Algorithm to be used for pipe limits. See the readme of the module for description of available options: NOP, RED, TAILDROP, FEEDBACK, NETWORK")) |
240
|
|
|
plimit = IntegerField(default=0, help_text=_(u"Pipe limit (hits per second)")) |
241
|
|
|
|
242
|
|
|
|
243
|
|
|
class Meta: |
244
|
|
|
db_table = 'pl_pipes' |
245
|
|
|
app_label = 'kamailio' |
246
|
|
|
ordering = ('-pk',) |
247
|
|
|
|
248
|
|
|
def __unicode__(self): |
249
|
|
|
return u'%s' % self.pk |
250
|
|
|
|
251
|
|
|
def get_absolute_url(self): |
252
|
|
|
return reverse('kamailio_pipelimit_detail', args=(self.pk,)) |
253
|
|
|
|
254
|
|
|
def get_update_url(self): |
255
|
|
|
return reverse('kamailio_pipelimit_update', args=(self.pk,)) |
256
|
|
|
|
257
|
|
|
|
258
|
|
|
class Mtree(models.Model): |
259
|
|
|
|
260
|
|
|
# Fields |
261
|
|
|
tprefix = CharField(max_length=32, default='', unique=True, help_text=_(u"Key to be used to index the values in the tree, usually a DID or prefix")) |
262
|
|
|
tvalue = CharField(max_length=128, default='', help_text=_(u"The value of the key")) |
263
|
|
|
|
264
|
|
|
|
265
|
|
|
class Meta: |
266
|
|
|
db_table = 'mtree' |
267
|
|
|
app_label = 'kamailio' |
268
|
|
|
ordering = ('-pk',) |
269
|
|
|
|
270
|
|
|
def __unicode__(self): |
271
|
|
|
return u'%s' % self.pk |
272
|
|
|
|
273
|
|
|
def get_absolute_url(self): |
274
|
|
|
return reverse('kamailio_mtree_detail', args=(self.pk,)) |
275
|
|
|
|
276
|
|
|
def get_update_url(self): |
277
|
|
|
return reverse('kamailio_mtree_update', args=(self.pk,)) |
278
|
|
|
|
279
|
|
|
|
280
|
|
|
class Mtrees(models.Model): |
281
|
|
|
|
282
|
|
|
# Fields |
283
|
|
|
tname = CharField(max_length=128, default='', help_text=_(u"Name of shared memory tree")) |
284
|
|
|
tprefix = CharField(max_length=32, default='', help_text=_(u"Key to be used to index the values in the tree, usually a DID or prefix")) |
285
|
|
|
tvalue = CharField(max_length=128, default='', help_text=_(u"The value of the key")) |
286
|
|
|
|
287
|
|
|
|
288
|
|
|
class Meta: |
289
|
|
|
db_table = 'mtrees' |
290
|
|
|
app_label = 'kamailio' |
291
|
|
|
ordering = ('-pk',) |
292
|
|
|
unique_together = [ |
293
|
|
|
["tname", "tprefix", "tvalue"], |
294
|
|
|
] |
295
|
|
|
|
296
|
|
|
def __unicode__(self): |
297
|
|
|
return u'%s' % self.pk |
298
|
|
|
|
299
|
|
|
def get_absolute_url(self): |
300
|
|
|
return reverse('kamailio_mtrees_detail', args=(self.pk,)) |
301
|
|
|
|
302
|
|
|
def get_update_url(self): |
303
|
|
|
return reverse('kamailio_mtrees_update', args=(self.pk,)) |
304
|
|
|
|
305
|
|
|
|
306
|
|
|
class Htable(models.Model): |
307
|
|
|
|
308
|
|
|
# Fields |
309
|
|
|
key_name = CharField(max_length=64, default='', help_text=_(u"Name of the hash key")) |
310
|
|
|
key_type = IntegerField(default=0, help_text=_(u"Type of the key")) |
311
|
|
|
value_type = IntegerField(default=0, help_text=_(u"Type of the value")) |
312
|
|
|
key_value = CharField(max_length=128, default='', help_text=_(u"The value of the key")) |
313
|
|
|
expires = IntegerField(default=0, help_text=_(u"The epoch at which the key expires")) |
314
|
|
|
|
315
|
|
|
|
316
|
|
|
class Meta: |
317
|
|
|
db_table = 'htable' |
318
|
|
|
app_label = 'kamailio' |
319
|
|
|
ordering = ('-pk',) |
320
|
|
|
|
321
|
|
|
def __unicode__(self): |
322
|
|
|
return u'%s' % self.pk |
323
|
|
|
|
324
|
|
|
def get_absolute_url(self): |
325
|
|
|
return reverse('kamailio_htable_detail', args=(self.pk,)) |
326
|
|
|
|
327
|
|
|
def get_update_url(self): |
328
|
|
|
return reverse('kamailio_htable_update', args=(self.pk,)) |
329
|
|
|
|