Skip to content

Commit d71759d

Browse files
committed
move to async/await instead of promises
Add in handleModify Add a dockerfile with multistage build Add in outbound mode option
1 parent f3b76c3 commit d71759d

7 files changed

Lines changed: 296 additions & 192 deletions

File tree

Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM node:10.16.3 AS build-env
2+
3+
WORKDIR /app
4+
COPY package.json /app/
5+
COPY package-lock.json /app/
6+
RUN npm install --production
7+
COPY . /app
8+
9+
FROM gcr.io/distroless/nodejs
10+
EXPOSE 9022
11+
COPY --from=build-env /app /app
12+
WORKDIR /app
13+
CMD ["app.js"]

app.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,17 @@ const config = require('config') ;
1313
const Client = require('rtpengine-client').Client ;
1414
const rtpengine = new Client(config.get('rtpengine.local-port'));
1515

16-
srf.connect(config.get('drachtio'))
16+
if (config.get('drachtio.mode') === 'outbound') {
17+
srf.listen(config.get('drachtio'))
18+
} else {
19+
srf.connect(config.get('drachtio'))
1720
.on('connect', (err, hostport) => {
1821
console.log(`connected to drachtio listening for SIP on hostport ${hostport}`) ;
1922
})
2023
.on('error', (err) => {
2124
console.error(`Error connecting to drachtio server: ${err.message}`) ;
2225
});
26+
}
2327

2428
register.start(srf, registrar);
2529
subscriber.start(srf, registrar);

config/default.json.example

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"drachtio": {
3+
"mode": "inbound",
34
"host": "127.0.0.1",
45
"port": 9022,
56
"secret": "cymru"
6-
},
7+
},
78
"rtpengine": {
89
"host": "127.0.0.1",
910
"port": 22222,
@@ -14,7 +15,7 @@
1415
"trunk": "your.voipprovider.com",
1516
"auth": {
1617
"username": "<yourusername>",
17-
"password": "<yourpassword>"
18+
"password": "<yourpassword>"
1819
}
1920
}
2021
]

0 commit comments

Comments
 (0)