Built motion from commit d415888.|0.0.73
[motion.git] / server / models / trunk.js
1 'use strict';
2
3 var crypto = require('crypto');
4 var md5 = require('md5');
5 var _ = require('lodash');
6
7 module.exports = function(sequelize, DataTypes) {
8   var Trunk = sequelize.define('Trunk', {
9     name: {
10       type: DataTypes.STRING,
11       primaryKey: true
12     },
13     type: {
14       type: DataTypes.ENUM('friend', 'user', 'peer'),
15       allowNull: true,
16       defaultValue: 'friend'
17     },
18     context: {
19       type: DataTypes.STRING,
20       allowNull: true,
21       defaultValue: 'from-sip'
22     },
23     callingpres: {
24       type: DataTypes.ENUM('ALLOWED_NOT_SCREENED',
25         'ALLOWED_PASSED_SCREEN', 'ALLOWED_FAILED_SCREEN', 'ALLOWED',
26         'PROHIB_NOT_SCREENED', 'PROHIB_PASSED_SCREEN',
27         'PROHIB_FAILED_SCREEN', 'PROHIB'),
28       allowNull: true,
29     },
30     permit: {
31       type: DataTypes.STRING,
32       allowNull: true,
33     },
34     deny: {
35       type: DataTypes.STRING,
36       allowNull: true,
37     },
38     secret: {
39       type: DataTypes.STRING,
40       allowNull: true,
41     },
42     md5secret: {
43       type: DataTypes.STRING,
44       allowNull: true,
45     },
46     remotesecret: {
47       type: DataTypes.STRING,
48       allowNull: true,
49     },
50     transport: {
51       type: DataTypes.STRING,
52       allowNull: true,
53       defaultValue: 'udp'
54     },
55     dtmfmode: {
56       type: DataTypes.ENUM('rfc2833', 'info', 'shortinfo', 'inband',
57         'auto'),
58       allowNull: true,
59       defaultValue: 'rfc2833'
60     },
61     directmedia: {
62       type: DataTypes.ENUM('yes', 'no', 'nonat', 'update', 'outgoing'),
63       allowNull: true,
64       defaultValue: 'no'
65     },
66     directrtpsetup: {
67       type: DataTypes.ENUM('yes', 'no'),
68       allowNull: true,
69       defaultValue: 'no'
70     },
71     directmediapermit: {
72       type: DataTypes.STRING,
73       allowNull: true,
74     },
75     directmediadeny: {
76       type: DataTypes.STRING,
77       allowNull: true,
78     },
79     nat: {
80       type: DataTypes.STRING,
81       allowNull: true,
82       defaultValue: 'force_rport,comedia'
83     },
84     callgroup: {
85       type: DataTypes.STRING,
86       allowNull: true,
87     },
88     namedcallgroup: { //We are in named call groups engineering,sales,netgroup,protgroup
89       type: DataTypes.STRING,
90       allowNull: true,
91     },
92     pickupgroup: {
93       type: DataTypes.STRING,
94       allowNull: true,
95     },
96     namedpickupgroup: { //We can do call pick-p for named call group sales
97       type: DataTypes.STRING,
98       allowNull: true,
99     },
100     language: {
101       type: DataTypes.STRING,
102       allowNull: true,
103       defaultValue: 'en'
104     },
105     tonezone: {
106       type: DataTypes.STRING,
107       allowNull: true
108     },
109     disallow: {
110       type: DataTypes.STRING,
111       allowNull: true,
112       defaultValue: 'all'
113     },
114     allow: {
115       type: DataTypes.STRING,
116       allowNull: false,
117       defaultValue: 'alaw;ulaw;gsm'
118     },
119     autoframing: {
120       type: DataTypes.ENUM('yes', 'no'),
121       allowNull: true,
122     },
123     insecure: {
124       type: DataTypes.STRING,
125       allowNull: true,
126       defaultValue: 'port,invite'
127     },
128     trustrpid: {
129       type: DataTypes.ENUM('yes', 'no'),
130       allowNull: true,
131       defaultValue: 'no'
132     },
133     trust_id_outbound: {
134       type: DataTypes.ENUM('yes', 'no'),
135       allowNull: true,
136       defaultValue: 'no'
137     },
138     progressinband: {
139       type: DataTypes.ENUM('yes', 'no', 'never'),
140       allowNull: true,
141     },
142     promiscredir: {
143       type: DataTypes.ENUM('yes', 'no'),
144       allowNull: true,
145     },
146     useclientcode: {
147       type: DataTypes.ENUM('yes', 'no'),
148       allowNull: true,
149     },
150     accountcode: {
151       type: DataTypes.INTEGER(11),
152       allowNull: true,
153     },
154     setvar: {
155       type: DataTypes.STRING,
156       allowNull: true,
157     },
158     callerid: {
159       type: DataTypes.STRING,
160       allowNull: true,
161       defaultValue: '"" <>'
162     },
163     amaflags: {
164       type: DataTypes.STRING,
165       allowNull: true,
166     },
167     callcounter: {
168       type: DataTypes.ENUM('yes', 'no'),
169       allowNull: true,
170       defaultValue: 'yes'
171     },
172     busylevel: {
173       type: DataTypes.INTEGER(11),
174       allowNull: true,
175     },
176     allowoverlap: {
177       type: DataTypes.ENUM('yes', 'no'),
178       allowNull: true,
179     },
180     allowsubscribe: {
181       type: DataTypes.ENUM('yes', 'no'),
182       allowNull: true,
183     },
184     allowtransfer: {
185       type: DataTypes.ENUM('yes', 'no'),
186       allowNull: true,
187     },
188     ignoresdpversion: {
189       type: DataTypes.ENUM('yes', 'no'),
190       allowNull: true,
191     },
192     subscribecontext: {
193       type: DataTypes.STRING,
194       allowNull: true,
195     },
196     template: {
197       type: DataTypes.STRING,
198       allowNull: true,
199     },
200     videosupport: {
201       type: DataTypes.ENUM('yes', 'no', 'always'),
202       allowNull: true,
203       defaultValue: 'no'
204     },
205     maxcallbitrate: {
206       type: DataTypes.INTEGER(11),
207       allowNull: true,
208     },
209     rfc2833compensate: {
210       type: DataTypes.ENUM('yes', 'no'),
211       allowNull: true,
212     },
213     mailbox: {
214       type: DataTypes.STRING,
215       allowNull: true,
216     },
217     session_timers: {
218       type: DataTypes.ENUM('accept', 'refuse', 'originate'),
219       allowNull: true,
220     },
221     session_expires: {
222       type: DataTypes.INTEGER(11),
223       allowNull: true,
224     },
225     session_minse: {
226       type: DataTypes.INTEGER(11),
227       allowNull: true,
228     },
229     session_refresher: {
230       type: DataTypes.ENUM('uac', 'uas'),
231       allowNull: true,
232       defaultValue: 'uas'
233     },
234     t38pt_usertpsource: {
235       type: DataTypes.STRING,
236       allowNull: true,
237     },
238     regexten: {
239       type: DataTypes.STRING,
240       allowNull: true,
241     },
242     fromdomain: {
243       type: DataTypes.STRING,
244       allowNull: true,
245     },
246     fromuser: {
247       type: DataTypes.STRING,
248       allowNull: true,
249     },
250     host: {
251       type: DataTypes.STRING,
252       allowNull: true,
253       defaultValue: 'dynamic'
254     },
255     port: {
256       type: DataTypes.INTEGER(5),
257       allowNull: true,
258     },
259     qualify: {
260       type: DataTypes.ENUM('yes', 'no'),
261       allowNull: true,
262       defaultValue: 'yes'
263     },
264     keepalive: {
265       type: DataTypes.INTEGER(11),
266       allowNull: true,
267     },
268     defaultip: {
269       type: DataTypes.STRING,
270       allowNull: true,
271     },
272     defaultuser: {
273       type: DataTypes.STRING,
274       allowNull: true,
275     },
276     rtptimeout: { // Terminate call if 60 seconds of no RTP or RTCP activity on the audio channel  when we're not on hold.
277       type: DataTypes.INTEGER(11),
278       allowNull: true,
279     },
280     rtpholdtimeout: { // Terminate call if 300 seconds of no RTP or RTCP activity on the audio channel when we're on hold (must be > rtptimeout)
281       type: DataTypes.INTEGER(11),
282       allowNull: true,
283     },
284     rtpkeepalive: { // Send keepalives in the RTP stream to keep NAT open (default is off - zero)
285       type: DataTypes.INTEGER(11),
286       allowNull: true,
287     },
288     sendrpid: {
289       type: DataTypes.ENUM('yes', 'no'),
290       allowNull: true,
291       defaultValue: 'no'
292     },
293     outboundproxy: {
294       type: DataTypes.STRING,
295       allowNull: true,
296     },
297     callbackextension: {
298       type: DataTypes.STRING,
299       allowNull: true,
300     },
301     timert1: {
302       type: DataTypes.INTEGER(11),
303       allowNull: true,
304     },
305     timerb: {
306       type: DataTypes.INTEGER(11),
307       allowNull: true,
308     },
309     qualifyfreq: {
310       type: DataTypes.INTEGER(11),
311       allowNull: true,
312     },
313     contactpermit: {
314       type: DataTypes.STRING,
315       allowNull: true,
316     },
317     contactdeny: {
318       type: DataTypes.STRING,
319       allowNull: true,
320     },
321     contactacl: {
322       type: DataTypes.STRING,
323       allowNull: true,
324     },
325     unsolicited_mailbox: {
326       type: DataTypes.STRING,
327       allowNull: true,
328     },
329     use_q850_reason: {
330       type: DataTypes.STRING,
331       allowNull: true,
332     },
333     maxforwards: {
334       type: DataTypes.INTEGER(11),
335       allowNull: true,
336     },
337     encryption: {
338       type: DataTypes.ENUM('yes', 'no'),
339       allowNull: true,
340       defaultValue: 'no'
341     },
342     avpf: {
343       type: DataTypes.ENUM('yes', 'no'),
344       allowNull: true
345     },
346     force_avp: {
347       type: DataTypes.ENUM('yes', 'no'),
348       allowNull: true
349     },
350     icesupport: {
351       type: DataTypes.ENUM('yes', 'no'),
352       allowNull: true
353     },
354     dtlsenable: {
355       type: DataTypes.ENUM('yes', 'no'),
356       allowNull: true
357     },
358     dtlsverify: {
359       type: DataTypes.ENUM('yes', 'no', 'fingerprint', 'certificate'),
360       allowNull: true
361     },
362     dtlsrekey: {
363       type: DataTypes.INTEGER(11),
364       allowNull: true,
365     },
366     dtlscertfile: {
367       type: DataTypes.STRING,
368       allowNull: true,
369     },
370     dtlsprivatekey: {
371       type: DataTypes.STRING,
372       allowNull: true,
373     },
374     dtlscipher: {
375       type: DataTypes.STRING,
376       allowNull: true,
377     },
378     dtlscafile: {
379       type: DataTypes.STRING,
380       allowNull: true,
381     },
382     dtlscapath: {
383       type: DataTypes.STRING,
384       allowNull: true,
385     },
386     dtlssetup: {
387       type: DataTypes.ENUM('active', 'passive', 'actpass'),
388       allowNull: true
389     },
390     dtlsfingerprint: {
391       type: DataTypes.STRING,
392       allowNull: true,
393     },
394     usereqphone: { //This provider requires ";user=phone" on URI
395       type: DataTypes.ENUM('yes', 'no'),
396       allowNull: true,
397       defaultValue: 'no'
398     },
399     recordonfeature: { //Feature to use when INFO with Record: on is received.
400       type: DataTypes.STRING,
401       allowNull: true,
402     },
403     recordofffeature: { //Feature to use when INFO with Record: off is received.
404       type: DataTypes.STRING,
405       allowNull: true,
406     },
407     call_limit: {
408       type: DataTypes.INTEGER(11),
409       allowNull: true,
410       defaultValue: null
411     },
412     registertrying: { //Send a 100 Trying when the device registers.
413       type: DataTypes.ENUM('yes', 'no'),
414       allowNull: true,
415     },
416     subscribemwi: { //Only send notifications if this phone subscribes for mailbox notification
417       type: DataTypes.ENUM('yes', 'no'),
418       allowNull: true,
419     },
420     vmexten: { // dialplan extension to reach mailbox. defaults to global vmexten which defaults to "asterisk"
421       type: DataTypes.STRING,
422       allowNull: true,
423     },
424     mohinterpret: { // This option specifies a preference for which music on hold class this channel should listen to when put on hold
425       type: DataTypes.STRING,
426       allowNull: true,
427     },
428     mohsuggest: { //  This option specifies which music on hold class to suggest to the peer channel when this channel places the peer on hold.
429       type: DataTypes.STRING,
430       allowNull: true,
431     },
432     parkinglot: {
433       type: DataTypes.STRING,
434       allowNull: true,
435     },
436     description: {
437       type: DataTypes.STRING,
438       allowNull: true,
439     },
440     canreinvite: {
441       type: DataTypes.ENUM('yes', 'no', 'nonat', 'update', 'update,nonat'),
442       allowNull: true,
443       defaultValue: 'no'
444     },
445     registry: {
446       type: DataTypes.STRING,
447       allowNull: true,
448     },
449     otherFields: {
450       type: DataTypes.STRING,
451       allowNull: true,
452     }
453   }, {
454     tableName: 'trunks'
455   });
456
457   return Trunk;
458 }