Run this script on another machine, and switch in /etc/freeswitch/autoload_configs/xml_curl.conf.xml the URL for binding=configuration. Then relanch unifi-talk, and the new configuration should be fetched by freeswitch.
Created
January 22, 2024 22:56
-
-
Save lionep/15f42cdaace5f7c17e8fc3c86b22716e to your computer and use it in GitHub Desktop.
Simple express server to mock the UDM unifi talk config files sent to freeswitch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const bodyParser = require('body-parser'); | |
const app = express(); | |
app.use(bodyParser.urlencoded({extended: true})); | |
app.use((req, res, next) => { | |
console.log(req.method + ' ' + req.path + " " + req.socket.remoteAddress); | |
next(); | |
}) | |
// For debug purpose | |
app.get('/config/:confName', (req, res, next) => { | |
req.method = 'POST'; | |
req.body = { | |
key_value: req.params.confName | |
}; | |
next('route'); | |
}); | |
// To get the original files to replace here : you can run on your UDM terminal : | |
// curl -X POST -d "key_value=sofia.conf" http://127.0.0.1:3423 | |
// curl -X POST -d "key_value=post_load_switch.conf" http://127.0.0.1:3423 | |
// curl -X POST -d "key_value=acl.conf" http://127.0.0.1:3423 | |
app.post('/*', (req, res) => { | |
res.header('Content-Type', 'text/xml; charset=utf-8'); | |
console.log('Fetching...'); | |
console.log(req.body.key_value); | |
if (req.body.key_value === 'sofia.conf') { | |
return res.send(`<document type="freeswitch/xml"> | |
<section name="configuration"> | |
<configuration name="sofia.conf" description="sofia Endpoint"> | |
<global_settings> | |
<param name="log-level" value="0"/> | |
<param name="tracelevel" value="DEBUG"/> | |
</global_settings> | |
<profiles> | |
<profile name="external_talk"> | |
<gateways> | |
<gateway name="Talk"> | |
<param name="username" value="XXXXXXXX"/> | |
<param name="password" value="XXXXXXXX"/> | |
<param name="proxy" value="XXXXXXXX.twilio.com"/> | |
<param name="caller-id-in-from" value="true"/> | |
<param name="register-transport" value="tcp"/> | |
<param name="register" value="false"/> | |
<param name="ping" value="25"/> | |
</gateway> | |
<gateway name="MyProvider"> | |
<param name="realm" value="provider.com"/> | |
<param name="cid-type" value="pid"/> | |
<param name="password" value="XXXXXXXX"/> | |
<param name="register" value="true"/> | |
<param name="username" value="XXXXXXXX"/> | |
<param name="retry-seconds" value="60"/> | |
<param name="caller-id-type" value="pid"/> | |
<param name="caller-id-in-from" value="true"/> | |
</gateway> | |
</gateways> | |
<domains> | |
<domain name="all" alias="false" parse="true"></domain> | |
</domains> | |
<settings> | |
<param name="debug" value="9"/> | |
<param name="sip-trace" value="no"/> | |
<param name="caller-id-type" value="pid"/> | |
<param name="dialplan" value="XML"/> | |
<param name="context" value="public"/> | |
<param name="codec-prefs" value="PCMU,PCMA,G711"/> | |
<param name="rtp-ip" value="\$\${local_ip_v4}"/> | |
<param name="sip-ip" value="\$\${local_ip_v4}"/> | |
<param name="ext-rtp-ip" value="stun:global.stun.twilio.com"/> | |
<param name="ext-sip-ip" value="stun:global.stun.twilio.com"/> | |
<param name="apply-inbound-acl" value="talk_acl"/> | |
<param name="enable-compact-headers" value="true"/> | |
<param name="user-agent-string" value="UT-2.2.3"/> | |
<param name="tls" value="false"/> | |
<param name="tls-version" value="tlsv1.2"/> | |
<param name="tls-cert-dir" value="/data/unifi-talk/config"/> | |
<param name="tls-certificate" value="\$\${tls-cert-dir}/active.crt"/> | |
<param name="tls-private-key" value="\$\${tls-cert-dir}/active.key"/> | |
<param name="rtp-timer-name" value="soft"/> | |
<param name="rtp-rewrite-timestamps" value="true"/> | |
</settings> | |
</profile> | |
<profile name="internal"> | |
<aliases></aliases> | |
<gateways></gateways> | |
<domains> | |
<domain name="all" alias="true" parse="false"></domain> | |
</domains> | |
<settings> | |
<param name="debug" value="9"/> | |
<param name="sip-trace" value="no"/> | |
<param name="sip-capture" value="no"/> | |
<param name="watchdog-enabled" value="no"/> | |
<param name="watchdog-step-timeout" value="30000"/> | |
<param name="watchdog-event-timeout" value="30000"/> | |
<param name="log-auth-failures" value="false"/> | |
<param name="forward-unsolicited-mwi-notify" value="false"/> | |
<param name="context" value="public"/> | |
<param name="rfc2833-pt" value="101"/> | |
<param name="sip-port" value="5060"/> | |
<param name="dialplan" value="XML"/> | |
<param name="dtmf-duration" value="2000"/> | |
<param name="inbound-codec-prefs" value="PCMU,PCMA,G711,VP8"/> | |
<param name="outbound-codec-prefs" value="PCMU,PCMA,G711,VP8"/> | |
<param name="rtp-timer-name" value="soft"/> | |
<param name="rtp-rewrite-timestamps" value="true"/> | |
<param name="rtp-ip" value="10.X.X.X"/> | |
<param name="sip-ip" value="10.X.X.X"/> | |
<param name="hold-music" value="\$\${hold_music}"/> | |
<param name="apply-nat-acl" value="nat.auto"/> | |
<param name="apply-inbound-acl" value="domains"/> | |
<param name="local-network-acl" value="localnet.auto"/> | |
<param name="record-path" value="\$\${recordings_dir}"/> | |
<param name="record-template" value="\${caller_id_number}.\${target_domain}.\${strftime(%Y-%m-%d-%H-%M-%S)}.wav"/> | |
<param name="manage-presence" value="true"/> | |
<param name="presence-hosts" value="talk.com"/> | |
<param name="presence-privacy" value="\$\${presence_privacy}"/> | |
<param name="inbound-codec-negotiation" value="greedy"/> | |
<param name="tls" value="\$\${internal_ssl_enable}"/> | |
<param name="tls-only" value="false"/> | |
<param name="tls-bind-params" value="transport=tls"/> | |
<param name="tls-sip-port" value="\$\${internal_tls_port}"/> | |
<param name="tls-passphrase" value=""/> | |
<param name="tls-verify-date" value="true"/> | |
<param name="tls-verify-policy" value="none"/> | |
<param name="tls-verify-depth" value="2"/> | |
<param name="tls-verify-in-subjects" value=""/> | |
<param name="tls-version" value="\$\${sip_tls_version}"/> | |
<param name="tls-ciphers" value="\$\${sip_tls_ciphers}"/> | |
<param name="inbound-late-negotiation" value="true"/> | |
<param name="inbound-zrtp-passthru" value="true"/> | |
<param name="nonce-ttl" value="60"/> | |
<param name="auth-calls" value="\$\${internal_auth_calls}"/> | |
<param name="inbound-reg-force-matching-username" value="true"/> | |
<param name="auth-all-packets" value="false"/> | |
<param name="rtp-timeout-sec" value="300"/> | |
<param name="rtp-hold-timeout-sec" value="1800"/> | |
<param name="force-register-domain" value="talk.com"/> | |
<param name="force-subscription-domain" value="talk.com"/> | |
<param name="force-register-db-domain" value="talk.com"/> | |
<param name="ws-binding" value=":5066"/> | |
<param name="challenge-realm" value="auto_from"/> | |
<param name="enable-compact-headers" value="true"/> | |
</settings> | |
</profile> | |
</profiles> | |
</configuration> | |
</section> | |
</document>`); | |
} | |
if (req.body.key_value === 'post_load_switch.conf') { | |
return res.send(`<document type="freeswitch/xml"> | |
<section name="configuration"> | |
<configuration name="post_load_switch.conf" description="Core Configuration"> | |
<cli-keybindings> | |
<key name="1" value="help"></key> | |
<key name="2" value="status"></key> | |
<key name="3" value="show channels"></key> | |
<key name="4" value="show calls"></key> | |
<key name="5" value="sofia status"></key> | |
<key name="6" value="reloadxml"></key> | |
<key name="7" value="console loglevel 0"></key> | |
<key name="8" value="console loglevel 7"></key> | |
<key name="9" value="sofia status profile internal"></key> | |
<key name="10" value="sofia profile internal siptrace on"></key> | |
<key name="11" value="sofia profile internal siptrace off"></key> | |
<key name="12" value="version"></key> | |
</cli-keybindings> | |
<default-ptimes></default-ptimes> | |
<settings> | |
<param name="colorize-console" value="true"/> | |
<param name="dialplan-timestamps" value="false"/> | |
<param name="max-db-handles" value="50"/> | |
<param name="db-handle-timeout" value="10"/> | |
<param name="max-sessions" value="1000"/> | |
<param name="sessions-per-second" value="100"/> | |
<param name="loglevel" value="debug"/> | |
<param name="mailer-app" value="sendmail"/> | |
<param name="mailer-app-args" value="-t"/> | |
<param name="dump-cores" value="yes"/> | |
<param name="rtp-enable-zrtp" value="false"/> | |
</settings> | |
</configuration> | |
</section> | |
</document>`) | |
} | |
if (req.body.key_value === 'acl.conf') { | |
return res.send(`<document type="freeswitch/xml"> | |
<section name="configuration"> | |
<configuration name="acl.conf" description="Network Lists"> | |
<network-lists> | |
<list name="lan" default=""></list> | |
<list name="domains" default=""> | |
<node type="allow" domain="\$\${domain}"></node> | |
</list> | |
<list name="talk_acl" default=""> | |
<node type="allow" cidr="XX.XX.XX.X/23"></node> | |
</list> | |
</network-lists> | |
</configuration> | |
</section> | |
</document>`); | |
} | |
console.log('Not found'); | |
res.status(404); | |
res.send('Not Found'); | |
}); | |
app.listen(3423); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment