@babblevoice/babble-drachtio-callmanager 3.7.21 → 3.7.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,79 @@
1
+ -----BEGIN RSA PRIVATE KEY-----
2
+ MIIJKQIBAAKCAgEAosVylV24FMoPC06kPXWQO5H9JEhaHy175Hl0tE/Pcwb1wNmQ
3
+ wGYi1gebbXw9ArA2ebNi7M0jJbo0gFm9IQjCb3zO6P2u/S26clKZROmhIf/uhNV+
4
+ WGQ1i1C3cVNir8LauVwrrFefh/sa76ZQ0T04px+A1vmgGTPujMqDHqKO9IKw5zWe
5
+ 5DPAzPhjc6/5JQWsze9p3KJCxsvXKqOJ/TEEuoxmHCzLXTnBsncjbVmBfUtQFL+o
6
+ yo1kqruQz5mcEQfGw4KIpvwMTDs7RL6XZr2gDE3c3E3Py003Du7zlPgpSiP4UIt3
7
+ iaHTq90EpJ3h+DuUifHb27zPCMA5xClI+52ty+glny0MHELD93QOvL//np9j5CUU
8
+ lPfaLBRqWhoaA8KyPvqbjrCxVj6jrWEG7gvSYC8zKHVll9K7nkIeYZ4nAMaBo9kZ
9
+ 6gU/PTpRUn8dmGjh9wR2+qWhon4oD9Dm6IJs3wLfUXIefoCDxny7i7PhsI7ROo6E
10
+ bsWOusxFkhNNKWOdv0sgdOB7poBMMIhyQe+6KqRjZ2h/1UmMaFiO+/f+0C40WRBI
11
+ VpzQ67ZEPzmL7BFLYfr6ZivSmUFy5RvOdjA/Sl4cn7eAj6eSKdDbxTpC0+HxhKso
12
+ XDkZ/a8CXMjobGfBDnFrPH3/ZzFKWOMgikal1vbZEmyj8APU/hJxP8ubWjMCAwEA
13
+ AQKCAgAm5YIdOXkc1rBDpnZPDYH7Ckbw3a1Tl/3sOi3uTMgpF7ewbw1NPNsERGsa
14
+ /b5inxNVf82bAuZsRJP5O/ibJUm5dJzJRp4DeGL+oMhplF7iDhPEgHQh0UiOUyqT
15
+ FTcXAzx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cYjBrD7xUso1LoIw==
79
+ -----END CERTIFICATE-----
package/README.md CHANGED
@@ -162,6 +162,30 @@ npm link projectrtp
162
162
  npm link babble-drachtio-registrar
163
163
  npm link babble-drachtio-auth
164
164
 
165
+ If you want to test then projectrtp needs to be able to build locally, this uses the latest projectrtp docker image.
166
+
167
+ ```bash
168
+ docker run --rm -it \
169
+ -e HOME=/usr/src/app \
170
+ -v "$(pwd)":/usr/src/app \
171
+ -w /usr/src/app \
172
+ tinpotnick/projectrtp \
173
+ npm test
174
+
175
+ ```
176
+
177
+ or for a specific test
178
+
179
+ ```bash
180
+ docker run --rm -it \
181
+ -e HOME=/usr/src/app \
182
+ -v "$(pwd)":/usr/src/app \
183
+ -w /usr/src/app \
184
+ tinpotnick/projectrtp \
185
+ ./node_modules/mocha/bin/mocha --recursive --check-leaks --grep 'Create call and send 183 - early - SAVPF'
186
+
187
+ ```
188
+
165
189
  # References
166
190
 
167
191
  * SIP: Session Initiation Protocol [RFC 3261](https://tools.ietf.org/html/rfc3261)
package/lib/call.js CHANGED
@@ -213,7 +213,10 @@ class call {
213
213
  }
214
214
 
215
215
  this.counters = {
216
- "newuac": 0
216
+ "newuac": 0,
217
+ "adoptions": 0,
218
+ "adoptees": 0,
219
+ "mixes": 0
217
220
  }
218
221
 
219
222
  /**
@@ -1312,6 +1315,9 @@ class call {
1312
1315
  this.children.add( other )
1313
1316
  other.moh = this.moh
1314
1317
 
1318
+ this.counters.adoptions += 1
1319
+ other.counters.adoptees += 1
1320
+
1315
1321
  /* maintain privacy */
1316
1322
  if ( this.options.privacy )
1317
1323
  other.options.privacy = this.options.privacy
@@ -2412,6 +2418,9 @@ class call {
2412
2418
 
2413
2419
  this.epochs.mix = Math.floor( +new Date() / 1000 )
2414
2420
  othercall.epochs.mix = Math.floor( +new Date() / 1000 )
2421
+
2422
+ this.counters.mixes += 1
2423
+ othercall.counters.mixes += 1
2415
2424
  }
2416
2425
 
2417
2426
  /**
@@ -4306,6 +4315,8 @@ class call {
4306
4315
  set uactimeout( ms ) {
4307
4316
  if( this.established ) return
4308
4317
 
4318
+ ms = Math.min( ms, 30 * 60 * 1000 )
4319
+
4309
4320
  clearTimeout( this._timers.newuac )
4310
4321
  this._timers.newuac = setTimeout( () => {
4311
4322
  this.hangup( hangupcodes.REQUEST_TIMEOUT )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babblevoice/babble-drachtio-callmanager",
3
- "version": "3.7.21",
3
+ "version": "3.7.22",
4
4
  "description": "Call processing to create a PBX",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -25,17 +25,17 @@
25
25
  "uuid": "^8.3.2"
26
26
  },
27
27
  "optionalDependencies": {
28
- "@babblevoice/projectrtp": "^2.5.28"
28
+ "@babblevoice/projectrtp": "^2.6.2"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@typescript-eslint/eslint-plugin": "^5.48.2",
32
+ "chai": "^4.3.6",
32
33
  "eslint": "^8.32.0",
33
34
  "eslint-config-standard-with-typescript": "^30.0.0",
34
35
  "eslint-plugin-import": "^2.27.5",
35
36
  "eslint-plugin-n": "^15.6.1",
36
37
  "eslint-plugin-promise": "^6.1.1",
37
38
  "mocha": "^9.2.2",
38
- "chai": "^4.3.6",
39
39
  "typescript": "^4.9.4"
40
40
  },
41
41
  "bugs": {
@@ -258,7 +258,7 @@ describe( "call object", function() {
258
258
  child.update()
259
259
 
260
260
  expect( requestoptions.method ).to.equal( "UPDATE" )
261
- expect( requestoptions.headers[ "remote-party-id" ] ).to.equal( "\"0123456789\" <sip:0123456789@someotherrealm.com>;party=calling;screen=yes" )
261
+ expect( requestoptions.headers[ "remote-party-id" ] ).to.equal( "\"0123456789\" <sip:0123456789@someotherrealm.com>;party=called;screen=yes" )
262
262
 
263
263
  /* simulate wire to propogate hangup */
264
264
  await call.hangup( call.hangupcodes.NORMAL_CLEARING, false, "wire" )
@@ -790,7 +790,7 @@ describe( "call object", function() {
790
790
 
791
791
  await call.newuac( options, { "early": ( c ) => c.hangup() } )
792
792
 
793
- expect( createuacoptions.headers[ "remote-party-id" ] ).to.equal( "\"0000000000\" <sip:0000000000@localhost.localdomain>;party=calling;screen=yes" )
793
+ expect( createuacoptions.headers[ "remote-party-id" ] ).to.equal( "\"0000000000\" <sip:0000000000@localhost.localdomain>;party=called;screen=yes" )
794
794
  expect( createuacoptions.late ).to.be.true
795
795
  } )
796
796
 
@@ -850,7 +850,7 @@ describe( "call object", function() {
850
850
 
851
851
  expect( requestoptions.method ).to.equal( "UPDATE" )
852
852
  expect( requestoptions.body ).to.be.a( "string" )
853
- expect( requestoptions.headers[ "remote-party-id" ] ).to.equal( "\"Kermit\" <sip:kermy@localhost.localdomain>;party=calling;screen=yes" )
853
+ expect( requestoptions.headers[ "remote-party-id" ] ).to.equal( "\"Kermit\" <sip:kermy@localhost.localdomain>;party=called;screen=yes" )
854
854
 
855
855
  } )
856
856
 
@@ -1068,20 +1068,15 @@ describe( "call object", function() {
1068
1068
  setTimeout( () => connection.write( projectrtpmessage.createmessage( {"id": msgid,"uuid":"6d8ba7bb-44b9-4989-9aaf-5d938b496c49","action":"play","event":"start","reason":"new","status":{"channel":{"available":4995,"current":5},"workercount":12,"instance":"ca0ef6a9-9174-444d-bdeb-4c9eb54d5c94"}} ) ), 1 )
1069
1069
  setTimeout( () => connection.write( projectrtpmessage.createmessage( {"id": msgid,"uuid":"6d8ba7bb-44b9-4989-9aaf-5d938b496c49","action":"play","event":"end","reason":"completed","status":{"channel":{"available":4995,"current":5},"workercount":12,"instance":"ca0ef6a9-9174-444d-bdeb-4c9eb54d5c94"}} ) ), 10 )
1070
1070
  c.channels.audio.play( { "files": [ { "wav": "/voicemail/greeting.wav", "alt": "greeting" } ] } )
1071
- let ev = await c.waitforanyevent( { "action": "play", "event": "end" } )
1072
- expect( ev.action ).to.equal( "play" )
1073
- expect( ev.event ).to.equal( "end" )
1074
- expect( ev.reason ).to.equal( "completed" )
1071
+ const playgreetendev = await c.waitforanyevent( { "action": "play", "event": "end" } )
1075
1072
 
1076
1073
  setTimeout( () => connection.write( projectrtpmessage.createmessage( {"id": msgid,"uuid":"6d8ba7bb-44b9-4989-9aaf-5d938b496c49","action":"play","event":"start","reason":"new","status":{"channel":{"available":4995,"current":5},"workercount":12,"instance":"ca0ef6a9-9174-444d-bdeb-4c9eb54d5c94"}} ) ) )
1077
1074
  setTimeout( () => connection.write( projectrtpmessage.createmessage( {"id": msgid,"uuid":"6d8ba7bb-44b9-4989-9aaf-5d938b496c49","action":"play","event":"end","reason":"completed","status":{"channel":{"available":4995,"current":5},"workercount":12,"instance":"ca0ef6a9-9174-444d-bdeb-4c9eb54d5c94"}} ) ) )
1078
1075
  c.channels.audio.play( { "files": [ { "wav": "/voicemail/boing.wav", "alt": "" } ] } )
1079
- ev = await c.waitforanyevent( { "action": "play", "event": "end" } )
1080
- expect( ev.action ).to.equal( "play" )
1081
- expect( ev.event ).to.equal( "end" )
1082
- expect( ev.reason ).to.equal( "completed" )
1076
+ const playendev = await c.waitforanyevent( { "action": "play", "event": "end" } )
1083
1077
 
1084
1078
  setTimeout( () => connection.write( projectrtpmessage.createmessage( {"id": msgid,"uuid":"6d8ba7bb-44b9-4989-9aaf-5d938b496c49","action":"record","file":"/tmp/voicemail/recording/03039cdb-1949-407d-91d6-15ba6894955c.wav","event":"recording","status":{"channel":{"available":4995,"current":5},"workercount":12,"instance":"ca0ef6a9-9174-444d-bdeb-4c9eb54d5c94"}} ) ), 5 )
1079
+ setTimeout( () => connection.write( projectrtpmessage.createmessage( {"id": msgid,"uuid":"6d8ba7bb-44b9-4989-9aaf-5d938b496c49","action":"record","file":"/tmp/voicemail/recording/03039cdb-1949-407d-91d6-15ba6894955c.wav","event":"finished","event":"finished.channelclosed", "transcription": "test recording for voicemail", "emailed": true, "filesize": 160684, "status":{"channel":{"available":4995,"current":5},"workercount":12,"instance":"ca0ef6a9-9174-444d-bdeb-4c9eb54d5c94"}} ) ), 10 )
1085
1080
 
1086
1081
  c.channels.audio.record( {
1087
1082
  "file": "/voicemail/jhjhjgjhgjg.wav",
@@ -1100,15 +1095,25 @@ describe( "call object", function() {
1100
1095
  c._onhangup( "wire" )
1101
1096
  }, 50 )
1102
1097
 
1103
- ev = await c.waitforanyevent( { "action": "record", "event": /finished.*|\*/ }, 10000 )
1104
- expect( ev.action ).to.equal( "record" )
1105
- expect( ev.event ).to.equal( "finished.channelclosed" )
1106
- expect( ev.transcription ).to.equal( "test recording for voicemail" )
1107
- expect( ev.emailed ).to.be.true
1108
- expect( ev.filesize ).to.equal( 160684 )
1098
+ const recordfinishev = await c.waitforanyevent( { "action": "record", "event": /finished.*|\*/ }, 10000 )
1109
1099
 
1110
1100
  connection.destroy()
1111
1101
  await rtpserver.destroy()
1102
+
1103
+ expect( playgreetendev.action ).to.equal( "play" )
1104
+ expect( playgreetendev.event ).to.equal( "end" )
1105
+ expect( playgreetendev.reason ).to.equal( "completed" )
1106
+
1107
+ expect( playendev.action ).to.equal( "play" )
1108
+ expect( playendev.event ).to.equal( "end" )
1109
+ expect( playendev.reason ).to.equal( "completed" )
1110
+
1111
+ expect( recordfinishev.action ).to.equal( "record" )
1112
+ expect( recordfinishev.event ).to.equal( "finished.channelclosed" )
1113
+ expect( recordfinishev.transcription ).to.equal( "test recording for voicemail" )
1114
+ expect( recordfinishev.emailed ).to.be.true
1115
+ expect( recordfinishev.filesize ).to.equal( 160684 )
1116
+
1112
1117
  } )
1113
1118
 
1114
1119
  it( "set get moh", async function() {
@@ -1152,7 +1157,7 @@ describe( "call object", function() {
1152
1157
  const c = await call.newuac( options )
1153
1158
 
1154
1159
  /* no default configured */
1155
- expect( c.options.headers[ "remote-party-id" ] ).to.equal( "\"Hello\" <sip:0000000000@localhost.localdomain>;party=calling;screen=yes" )
1160
+ expect( c.options.headers[ "remote-party-id" ] ).to.equal( "\"Hello\" <sip:0000000000@localhost.localdomain>;party=called;screen=yes" )
1156
1161
 
1157
1162
  c._onhangup( "wire" )
1158
1163
 
@@ -1173,7 +1178,7 @@ describe( "call object", function() {
1173
1178
 
1174
1179
 
1175
1180
  /* no default configured */
1176
- expect( c.options.headers[ "remote-party-id" ] ).to.equal( "\"012345789\" <sip:012345789@localhost.localdomain>;party=calling;screen=yes" )
1181
+ expect( c.options.headers[ "remote-party-id" ] ).to.equal( "\"012345789\" <sip:012345789@localhost.localdomain>;party=called;screen=yes" )
1177
1182
 
1178
1183
  c._onhangup( "wire" )
1179
1184
 
@@ -52,6 +52,9 @@ describe( "call early", function() {
52
52
  const messagestate = projectrtpmessage.newstate()
53
53
  const channelmessages = []
54
54
  let opencount = 0
55
+
56
+ let ourclosepromise
57
+ const closepromise = new Promise( resolve => ourclosepromise = resolve )
55
58
 
56
59
  connection.on( "data", ( data ) => {
57
60
  projectrtpmessage.parsemessage( messagestate, data, ( msg ) => {
@@ -87,6 +90,7 @@ describe( "call early", function() {
87
90
  } else if ( "close" === msg.channel ) {
88
91
  connection.write( projectrtpmessage.createmessage( {"id": msg.id,"uuid":msg.uuid,"action":"close","reason":"requested","stats":{"in":{"mos":4.5,"count":586,"dropped":0,"skip":0},"out":{"count":303,"skip":0},"tick":{"meanus":124,"maxus":508,"count":597}}, "status":{"channel":{"available":4995,"current":5},"workercount":12,"instance":"ca0ef6a9-9174-444d-bdeb-4c9eb54d4566"}
89
92
  } ) )
93
+ ourclosepromise()
90
94
  } else if ( "mix" === msg.channel ) {
91
95
  mixing = true
92
96
  }
@@ -140,6 +144,12 @@ a=sendrecv`.replace(/(\r\n|\n|\r)/gm, "\r\n")
140
144
  const newcall = await call.newuac( { "contact": "callto" } )
141
145
 
142
146
  await call._onhangup( "wire" )
147
+
148
+ await closepromise
149
+
150
+ connection.destroy()
151
+ rtpserver.destroy()
152
+
143
153
  expect( newcall.state.early ).to.be.true
144
154
  expect( call.state.early ).to.be.true
145
155
  expect( mixing ).to.be.true
@@ -158,8 +168,6 @@ a=sendrecv`.replace(/(\r\n|\n|\r)/gm, "\r\n")
158
168
 
159
169
  expect( msginfo.body ).to.include( "audio 10010 RTP/AVP" )
160
170
 
161
- connection.destroy()
162
- rtpserver.destroy()
163
171
  } )
164
172
 
165
173
 
@@ -181,6 +189,9 @@ a=sendrecv`.replace(/(\r\n|\n|\r)/gm, "\r\n")
181
189
  const srfscenario = new srf.srfscenario()
182
190
  const rtpserver = callmanager.projectrtp.proxy.addnode( { host: "127.0.0.1", port: 9002 } )
183
191
 
192
+ let ourclosepromise
193
+ const closepromise = new Promise( resolve => ourclosepromise = resolve )
194
+
184
195
  let connection
185
196
  const mockrtp = net.createServer()
186
197
  mockrtp.on( "connection", ( c ) => {
@@ -220,6 +231,7 @@ a=sendrecv`.replace(/(\r\n|\n|\r)/gm, "\r\n")
220
231
  } else if ( "close" === msg.channel ) {
221
232
  connection.write( projectrtpmessage.createmessage( {"id": msg.id,"uuid":msg.uuid,"action":"close","reason":"requested","stats":{"in":{"mos":4.5,"count":586,"dropped":0,"skip":0},"out":{"count":303,"skip":0},"tick":{"meanus":124,"maxus":508,"count":597}}, "status":{"channel":{"available":4995,"current":5},"workercount":12,"instance":"ca0ef6a9-9174-444d-bdeb-4c9eb54d4566"}
222
233
  } ) )
234
+ ourclosepromise()
223
235
  } else if ( "mix" === msg.channel ) {
224
236
  mixing = true
225
237
  }
@@ -281,6 +293,9 @@ a=sendrecv`.replace(/(\r\n|\n|\r)/gm, "\r\n")
281
293
  const newcall = await call.newuac( { "contact": "callto" } )
282
294
 
283
295
  await call._onhangup( "wire" )
296
+
297
+ await closepromise
298
+
284
299
  expect( newcall.state.early ).to.be.true
285
300
  expect( call.state.early ).to.be.true
286
301
  expect( mixing ).to.be.true
@@ -332,6 +347,9 @@ a=sendrecv`.replace(/(\r\n|\n|\r)/gm, "\r\n")
332
347
  const messagestate = projectrtpmessage.newstate()
333
348
  const channelmessages = []
334
349
  let opencount = 0
350
+
351
+ let ourclosepromise
352
+ const closepromise = new Promise( resolve => ourclosepromise = resolve )
335
353
 
336
354
  connection.on( "data", ( data ) => {
337
355
  projectrtpmessage.parsemessage( messagestate, data, ( msg ) => {
@@ -366,6 +384,7 @@ a=sendrecv`.replace(/(\r\n|\n|\r)/gm, "\r\n")
366
384
  opencount++
367
385
  } else if ( "close" === msg.channel ) {
368
386
  connection.write( projectrtpmessage.createmessage( {"id": msg.id,"uuid":msg.uuid,"action":"close","reason":"requested","stats":{"in":{"mos":4.5,"count":586,"dropped":0,"skip":0},"out":{"count":303,"skip":0},"tick":{"meanus":124,"maxus":508,"count":597}}, "status":{"channel":{"available":4995,"current":5},"workercount":12,"instance":"ca0ef6a9-9174-444d-bdeb-4c9eb54d4566"}}))
387
+ ourclosepromise()
369
388
  } else if ( "mix" === msg.channel ) {
370
389
  mixing = true
371
390
  }
@@ -427,7 +446,8 @@ a=sendrecv`.replace(/(\r\n|\n|\r)/gm, "\r\n")
427
446
  const newcall = await call.newuac( { "contact": "callto" } )
428
447
 
429
448
  await call._onhangup( "wire" )
430
-
449
+ await closepromise
450
+
431
451
  expect( newcall.state.early ).to.be.true
432
452
  expect( call.state.early ).to.be.true
433
453
  expect( mixing ).to.be.true
@@ -485,6 +505,9 @@ a=sendrecv`.replace(/(\r\n|\n|\r)/gm, "\r\n")
485
505
  const messagestate = projectrtpmessage.newstate()
486
506
  const channelmessages = []
487
507
  let opencount = 0
508
+
509
+ let ourclosepromise
510
+ const closepromise = new Promise( resolve => ourclosepromise = resolve )
488
511
 
489
512
  connection.on( "data", ( data ) => {
490
513
  projectrtpmessage.parsemessage( messagestate, data, ( msg ) => {
@@ -519,6 +542,7 @@ a=sendrecv`.replace(/(\r\n|\n|\r)/gm, "\r\n")
519
542
  opencount++
520
543
  } else if ( "close" === msg.channel ) {
521
544
  connection.write( projectrtpmessage.createmessage( {"id": msg.id,"uuid":msg.uuid,"action":"close","reason":"requested","stats":{"in":{"mos":4.5,"count":586,"dropped":0,"skip":0},"out":{"count":303,"skip":0},"tick":{"meanus":124,"maxus":508,"count":597}}, "status":{"channel":{"available":4995,"current":5},"workercount":12,"instance":"ca0ef6a9-9174-444d-bdeb-4c9eb54d4566"}} ) )
545
+ ourclosepromise()
522
546
  } else if ( "mix" === msg.channel ) {
523
547
  mixing = true
524
548
  }
@@ -580,6 +604,10 @@ a=sendrecv`.replace(/(\r\n|\n|\r)/gm, "\r\n")
580
604
 
581
605
  await new Promise( ( resolve ) => setTimeout( () => resolve(), 500 ) )
582
606
  await call._onhangup( "wire" )
607
+ await closepromise
608
+
609
+ connection.destroy()
610
+ rtpserver.destroy()
583
611
 
584
612
  expect( newcall.state.early ).to.be.true
585
613
  expect( call.state.early ).to.be.true
@@ -600,8 +628,6 @@ a=sendrecv`.replace(/(\r\n|\n|\r)/gm, "\r\n")
600
628
 
601
629
  expect( msginfo.body ).to.include( "UDP/TLS/RTP/SAVPF" )
602
630
 
603
- connection.destroy()
604
- rtpserver.destroy()
605
631
  } )
606
632
 
607
633
  } )