File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,7 @@ const {
8787 isMemberOfSet,
8888 retrieveSet,
8989 createEphemeralGateway,
90+ deleteEphemeralGateway
9091} = require ( '@jambonz/realtimedb-helpers' ) ( { } , logger ) ;
9192
9293const interval = SBC_PUBLIC_ADDRESS_KEEP_ALIVE_IN_MILISECOND || 900000 ; // Default 15 minutes
@@ -119,6 +120,7 @@ srf.locals = {
119120 retrieveKey,
120121 retrieveSet,
121122 createEphemeralGateway,
123+ deleteEphemeralGateway
122124 } ,
123125 writeAlerts,
124126 AlertType
Original file line number Diff line number Diff line change @@ -51,8 +51,19 @@ class Regbot {
5151 }
5252
5353 stop ( ) {
54+ const { deleteEphemeralGateway } = srf . locals . realtimeDbHelpers ;
5455 this . logger . info ( `stopping regbot ${ this . fromUser } @${ this . sip_realm } ` ) ;
5556 clearTimeout ( this . timer ) ;
57+ this . timer = null ;
58+ // remove any ephemeral gateways created for this regbot
59+ if ( this . addresses && this . addresses . length ) {
60+ this . addresses . forEach ( ( ip ) => {
61+ deleteEphemeralGateway ( ip , this . voip_carrier_sid ) . catch ( ( err ) => {
62+ this . logger . error ( { err, ip} , 'Error deleting ephemeral gateway on regbot stop' ) ;
63+ } ) ;
64+ } ) ;
65+ }
66+
5667 }
5768
5869 toJSON ( ) {
You can’t perform that action at this time.
0 commit comments