mirror of
https://github.com/jambonz/sbc-sip-sidecar.git
synced 2026-07-04 19:32:03 +00:00
when registering over tls contact header should have appropriate sip … (#62)
* rebase * update gh workflow
This commit is contained in:
@@ -15,7 +15,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: prepare tag
|
- name: prepare tag
|
||||||
id: prepare_tag
|
id: prepare_tag
|
||||||
@@ -38,7 +38,7 @@ jobs:
|
|||||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 16.x
|
node-version: 20.x
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm run jslint
|
- run: npm run jslint
|
||||||
- run: npm test
|
- run: npm test
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ srf.on('connect', (err, hp) => {
|
|||||||
logger.info(`connected to drachtio listening on ${hp}`);
|
logger.info(`connected to drachtio listening on ${hp}`);
|
||||||
|
|
||||||
// Add SBC Public IP to Database
|
// Add SBC Public IP to Database
|
||||||
|
srf.locals.sbcPublicIpAddress = {};
|
||||||
const map = new Map();
|
const map = new Map();
|
||||||
const hostports = hp.split(',');
|
const hostports = hp.split(',');
|
||||||
for (const hp of hostports) {
|
for (const hp of hostports) {
|
||||||
@@ -131,13 +132,24 @@ srf.on('connect', (err, hp) => {
|
|||||||
const addr = map.get(ipv4) || {ipv4};
|
const addr = map.get(ipv4) || {ipv4};
|
||||||
switch (arr[1]) {
|
switch (arr[1]) {
|
||||||
case 'udp':
|
case 'udp':
|
||||||
srf.locals.sbcPublicIpAddress = `${ipv4}:${port}`;
|
srf.locals.sbcPublicIpAddress = {
|
||||||
|
...srf.locals.sbcPublicIpAddress,
|
||||||
|
udp: `${ipv4}:${port}`
|
||||||
|
};
|
||||||
map.set(ipv4, {...addr, port: port});
|
map.set(ipv4, {...addr, port: port});
|
||||||
break;
|
break;
|
||||||
case 'tls':
|
case 'tls':
|
||||||
map.set(ipv4, {...addr, tls_port: port});
|
map.set(ipv4, {...addr, tls_port: port});
|
||||||
|
srf.locals.sbcPublicIpAddress = {
|
||||||
|
...srf.locals.sbcPublicIpAddress,
|
||||||
|
tls: `${ipv4}:${port}`
|
||||||
|
};
|
||||||
break;
|
break;
|
||||||
case 'wss':
|
case 'wss':
|
||||||
|
srf.locals.sbcPublicIpAddress = {
|
||||||
|
...srf.locals.sbcPublicIpAddress,
|
||||||
|
wss: `${ipv4}:${port}`
|
||||||
|
};
|
||||||
map.set(ipv4, {...addr, wss_port: port});
|
map.set(ipv4, {...addr, wss_port: port});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,20 +83,22 @@ class Regbot {
|
|||||||
async register(srf) {
|
async register(srf) {
|
||||||
const { updateVoipCarriersRegisterStatus } = srf.locals.dbHelpers;
|
const { updateVoipCarriersRegisterStatus } = srf.locals.dbHelpers;
|
||||||
try {
|
try {
|
||||||
const contactAddress = this.use_public_ip_in_contact ?
|
|
||||||
`${this.fromUser}@${srf.locals.sbcPublicIpAddress}` : this.aor;
|
|
||||||
this.logger.debug(`sending REGISTER for ${this.aor}`);
|
|
||||||
const isIPv4 = /[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}/.test(this.ipv4);
|
|
||||||
const transport = this.protocol.includes('/') ? this.protocol.substring(0, this.protocol.indexOf('/')) :
|
const transport = this.protocol.includes('/') ? this.protocol.substring(0, this.protocol.indexOf('/')) :
|
||||||
this.protocol;
|
this.protocol;
|
||||||
const useSipsScheme = transport === 'tls' && this.use_sips_scheme;
|
let scheme = 'sip';
|
||||||
|
if (transport === 'tls' && this.use_sips_scheme) scheme = 'sips';
|
||||||
|
const publicAddress = srf.locals.sbcPublicIpAddress[transport] || srf.locals.sbcPublicIpAddress.udp;
|
||||||
|
const contactAddress = this.use_public_ip_in_contact ?
|
||||||
|
`${this.fromUser}@${publicAddress}` : this.aor;
|
||||||
|
this.logger.debug(`sending REGISTER for ${this.aor}`);
|
||||||
|
const isIPv4 = /[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}/.test(this.ipv4);
|
||||||
const proxy = `sip:${this.ipv4}${isIPv4 ? `:${this.port}` : ''};transport=${transport}`;
|
const proxy = `sip:${this.ipv4}${isIPv4 ? `:${this.port}` : ''};transport=${transport}`;
|
||||||
const req = await srf.request(`sip${useSipsScheme ? 's' : ''}:${this.aor}`, {
|
const req = await srf.request(`${scheme}:${this.aor}`, {
|
||||||
method: 'REGISTER',
|
method: 'REGISTER',
|
||||||
proxy,
|
proxy,
|
||||||
headers: {
|
headers: {
|
||||||
'From': this.from,
|
'From': this.from,
|
||||||
'Contact': `<sip:${contactAddress}>;expires=${DEFAULT_EXPIRES}`,
|
'Contact': `<${scheme}:${contactAddress}>;expires=${DEFAULT_EXPIRES}`,
|
||||||
'Expires': DEFAULT_EXPIRES
|
'Expires': DEFAULT_EXPIRES
|
||||||
},
|
},
|
||||||
auth: {
|
auth: {
|
||||||
|
|||||||
Reference in New Issue
Block a user