Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bigger rework (freeswitch, handling of sessions, typescript, docker) #2

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ node_modules/

build/
public/config/config.js
docker/freeswitch/conf/sip_profiles/external/*
!docker/freeswitch/conf/sip_profiles/external/provider.xml.example
.vscode
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

A SIP gateway for [edumeet](https://github.com/edumeet/edumeet)

## Usage
1. Install newest docker & docker compose
2. create config `$ cp public/config/config.example.js public/config/config.js`
3. edit config `$ vim public/config/config.js`
* `edumeetHostName`
* `edumeetPort`
* `roomMapping`
4. create sip gateway config `$ cp docker/freeswitch/conf/sip_profiles/external/provider.xml.example docker/freeswitch/conf/sip_profiles/external/provider.xml`
5. configure sip config `$ vim docker/freeswitch/conf/sip_profiles/external/provider.xml`
6. start with `$ USERID=$(id -u) docker-compose up`

## Note
- can still be considered as a proof of concept
- this currently doesn't work behind NAT

## License

MIT
32 changes: 32 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: '3.6'

services:
freeswitch:
build: ./docker/freeswitch
network_mode: host
cap_add:
- CAP_SYS_NICE
volumes:
- ./docker/freeswitch/conf/sip_profiles/external:/etc/freeswitch/sip_profiles/external:ro

app:
image: node:15-buster-slim
entrypoint: bash -c 'cd /app && npm install && npm run start'
user: ${USERID}
volumes:
- ./:/app
stdin_open: true

browser:
image: montferret/chromium
entrypoint: sh -c 'wget --no-check-certificate --retry-on-host-error --no-verbose --spider --retry-connrefused https://app:4443 && ./entrypoint.sh'
environment:
CHROME_OPTS: '--autoplay-policy=no-user-gesture-required https://app:4443'

networks:
default:
ipam:
driver: default
config:
- subnet: 10.5.0.0/16
gateway: 10.5.0.1
24 changes: 24 additions & 0 deletions docker/freeswitch/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM debian:buster-slim

# add freeswitch repo
RUN apt-get update && \
apt-get install -y --no-install-recommends subversion curl wget ca-certificates gnupg gnupg2 lsb-release unzip && \
curl -k https://files.freeswitch.org/repo/deb/debian-release/fsstretch-archive-keyring.asc | apt-key add - && \
echo 'deb http://files.freeswitch.org/repo/deb/debian-release/ buster main' > /etc/apt/sources.list.d/freeswitch.list

# install freeswitch
RUN apt-get update && apt-get install -y \
freeswitch \
freeswitch-mod-commands \
freeswitch-mod-dialplan-xml \
freeswitch-mod-dptools \
freeswitch-mod-event-socket \
freeswitch-mod-opus \
freeswitch-mod-h26x \
freeswitch-mod-rtc \
freeswitch-mod-sofia \
freeswitch-mod-spandsp

COPY ./conf /etc/freeswitch

ENTRYPOINT /usr/bin/freeswitch
8 changes: 8 additions & 0 deletions docker/freeswitch/conf/autoload_configs/event_socket.conf.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<configuration name="event_socket.conf" description="Socket Client">
<settings>
<param name="nat-map" value="false"/>
<param name="listen-ip" value="127.0.0.1"/>
<param name="listen-port" value="8021"/>
<param name="password" value="ClueCon"/>
</settings>
</configuration>
22 changes: 22 additions & 0 deletions docker/freeswitch/conf/autoload_configs/modules.conf.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<configuration name="modules.conf" description="Modules">
<modules>
<!-- Loggers (I'd load these first) -->
<!-- <load module="mod_console"/>-->

<!-- Event Handlers -->
<load module="mod_event_socket"/>

<!-- Endpoints -->
<load module="mod_sofia"/>

<!-- Applications -->
<load module="mod_commands"/>
<load module="mod_dptools"/>

<!-- Dialplan Interfaces -->
<load module="mod_dialplan_xml"/>

<load module="mod_opus"/>
<load module="mod_h26x"/>
</modules>
</configuration>
10 changes: 10 additions & 0 deletions docker/freeswitch/conf/autoload_configs/sofia.conf.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<configuration name="sofia.conf" description="sofia Endpoint">
<global_settings>
<param name="log-level" value="0"/>
<param name="tracelevel" value="DEBUG"/>
</global_settings>

<profiles>
<X-PRE-PROCESS cmd="include" data="../sip_profiles/*.xml"/>
</profiles>
</configuration>
17 changes: 17 additions & 0 deletions docker/freeswitch/conf/autoload_configs/switch.conf.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<configuration name="switch.conf" description="Core Configuration">
<settings>
<param name="colorize-console" value="true"/>

<!-- Max number of sessions to allow at any given time -->
<param name="max-sessions" value="1000"/>
<!--Most channels to create per second -->
<param name="sessions-per-second" value="30"/>

<!-- Default Global Log Level - value is one of debug,info,notice,warning,err,crit,alert -->
<param name="loglevel" value="debug"/>

<!-- RTP port range -->
<param name="rtp-start-port" value="16384"/>
<param name="rtp-end-port" value="32768"/>
</settings>
</configuration>
13 changes: 13 additions & 0 deletions docker/freeswitch/conf/dialplan/public.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- http://wiki.freeswitch.org/wiki/Dialplan_XML -->
<include>
<context name="public">

<extension name="from_my_provider">
<condition>
<action application="start_dtmf" />
<action application="bridge" data="sofia/internal/1000%edumeet-sip"/>
</condition>
</extension>

</context>
</include>
15 changes: 15 additions & 0 deletions docker/freeswitch/conf/directory/edumeet-sip.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<include>
<domain name="edumeet-sip">
<groups>
<group name="local">
<users>
<user id="1000">
<params>
<param name="password" value="$${internal_extension_1000_password}"/>
</params>
</user>
</users>
</group>
</groups>
</domain>
</include>
19 changes: 19 additions & 0 deletions docker/freeswitch/conf/freeswitch.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0"?>
<document type="freeswitch/xml">
<X-PRE-PROCESS cmd="include" data="vars.xml"/>

<section name="configuration" description="Various Configuration">
<X-PRE-PROCESS cmd="include" data="autoload_configs/*.xml"/>
</section>

<!-- mod_dingaling is reliant on the vcard data in the "directory" section. -->
<!-- mod_sofia is reliant on the user data for authorization -->
<section name="directory" description="User Directory">
<X-PRE-PROCESS cmd="include" data="directory/*.xml"/>
</section>

<section name="dialplan" description="Regex/XML Dialplan">
<X-PRE-PROCESS cmd="include" data="dialplan/*.xml"/>
</section>

</document>
23 changes: 23 additions & 0 deletions docker/freeswitch/conf/sip_profiles/external.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<profile name="external">
<gateways>
<X-PRE-PROCESS cmd="include" data="external/*.xml"/>
</gateways>

<settings>
<param name="auth-calls" value="false"/>

<param name="debug" value="0"/>

<param name="dialplan" value="XML"/>
<param name="context" value="public"/>
<param name="inbound-codec-prefs" value="$${global_codec_prefs}"/>
<param name="outbound-codec-prefs" value="$${global_codec_prefs}"/>

<!-- invalid IP will automatically replaced with WAN ip -->
<param name="rtp-ip" value="0.0.0.0"/>
<param name="sip-ip" value="0.0.0.0"/>
<param name="ext-rtp-ip" value="auto-nat"/>
<param name="ext-sip-ip" value="auto-nat"/>
<param name="sip-port" value="$${external_sip_port}"/>
</settings>
</profile>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<include>
<gateway name="myprovider">
<param name="proxy" value="sips.peoplefone.de"/>
<param name="username" value="USERNAME"/>
<param name="password" value="PASSWORD"/>
</gateway>
</include>
25 changes: 25 additions & 0 deletions docker/freeswitch/conf/sip_profiles/internal.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<profile name="internal">
<settings>
<param name="challenge-realm" value="edumeet-sip"/>

<param name="auth-calls" value="true"/>
<param name="apply-nat-acl" value="nat.auto"/>

<param name="debug" value="0"/>

<param name="dialplan" value="XML"/>
<param name="context" value="default"/>
<param name="codec-prefs" value="PCMU,PCMA"/>

<!-- invalid IP will automatically replaced with WAN ip -->
<param name="rtp-ip" value="0.0.0.0"/>
<param name="ext-rtp-ip" value="auto-nat"/>
<param name="ext-sip-ip" value="auto-nat"/>

<param name="sip-ip" value="127.0.0.1"/>
<param name="sip-port" value="5060"/>
<param name="tls-cert-dir" value="/etc/freeswitch/tls"/>
<param name="wss-binding" value="$${internal_wss_binding}"/>
<param name="dtmf-type" value="info"/>
</settings>
</profile>
8 changes: 8 additions & 0 deletions docker/freeswitch/conf/vars.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<include>
<X-PRE-PROCESS cmd="set" data="global_codec_prefs=OPUS,G722,PCMU,PCMA,H264,VP8"/>
<X-PRE-PROCESS cmd="set" data="outbound_codec_prefs=OPUS,G722,PCMU,PCMA,H264,VP8"/>

<X-PRE-PROCESS cmd="set" data="external_sip_port=50807"/>
<X-PRE-PROCESS cmd="set" data="internal_extension_1000_password=HelloWorld"/>
<X-PRE-PROCESS cmd="set" data="internal_wss_binding=10.5.0.1:7443"/>
</include>/
16 changes: 12 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,22 @@
"author": "Håvar Aambø Fosstveit <[email protected]>",
"license": "MIT",
"dependencies": {
"@types/domready": "^1.0.0",
"@types/jest": "^26.0.21",
"@types/node": "^14.14.35",
"@types/random-string": "^0.0.28",
"@types/react": "^17.0.3",
"@types/react-dom": "^17.0.3",
"@types/sdp-transform": "^2.4.4",
"domready": "^1.0.8",
"mediasoup-client": "^3.6.5",
"mediasoup-client": "^3.6.29",
"random-string": "^0.2.0",
"react-scripts": "^3.4.1",
"sdp-transform": "^2.14.0",
"sip.js": "^0.15.10",
"socket.io-client": "^2.3.0",
"source-map-explorer": "^2.1.0"
"sip.js": "^0.20.0",
"socket.io-client": "^2.4.0",
"source-map-explorer": "^2.1.0",
"typescript": "^3.9.9"
},
"scripts": {
"analyze-main": "source-map-explorer build/static/js/main.*",
Expand Down
28 changes: 12 additions & 16 deletions public/config/config.example.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
// eslint-disable-next-line
var config =
{
userAgentString : 'edumeet SIPGW',
displayName : 'edumeet SIPGW',
register : true,
uri : '[email protected]',
password : 'password',
wsServers : [ 'wss://example.com' ],
traceSip : true,
sip : {
displayName : 'edumeet SIPGW',
userAgentString : 'edumeet SIPGW',
server : 'wss://10.5.0.1:7443',
uri : 'sip:1000@edumeet-sip',
username : '1000',
password : 'HelloWorld',
traceSip : true
},
edumeetHostName : 'example.com',
edumeetPort : '4443',
turnServers : [
{
urls : [
'turn:turn.example.com:443?transport=tcp'
],
username : 'example',
credential : 'example'
}
],
roomMapping : {
'00000' : 'test'
},
requestTimeout : 10000,
transportOptions :
{
Expand Down
Binary file added public/sounds/conference-pin.wav
Binary file not shown.
Binary file added public/sounds/invalid-pin.wav
Binary file not shown.
Binary file added public/sounds/muted.wav
Binary file not shown.
Binary file added public/sounds/notify.mp3
Binary file not shown.
Binary file added public/sounds/unmuted.wav
Binary file not shown.
Loading