initial release

This commit is contained in:
Paolo Asperti 2019-01-01 23:34:16 +01:00
commit 2abc5f570c
11 changed files with 246 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
recordings/
recordings-csv/

16
Dockerfile Normal file
View File

@ -0,0 +1,16 @@
FROM alpine:3.8
RUN apk -U add asterisk
COPY config/asterisk.conf /etc/asterisk/
COPY config/cdr_custom.conf /etc/asterisk/
COPY config/cdr.conf /etc/asterisk/
COPY config/extensions.conf /etc/asterisk/
COPY config/logger.conf /etc/asterisk/
COPY config/modules.conf /etc/asterisk/
COPY config/rtp.conf /etc/asterisk/
COPY start.sh /usr/local/bin/start.sh
VOLUME /recordings
ENTRYPOINT ["/bin/sh", "/usr/local/bin/start.sh"]

4
config/asterisk.conf Normal file
View File

@ -0,0 +1,4 @@
[options]
verbose = 2
; debug = 5
;defaultlanguage = es

7
config/cdr.conf Normal file
View File

@ -0,0 +1,7 @@
[general]
enable=yes
[custom]
; We log the unique ID as it can be useful for troubleshooting any issues
; that arise.
loguniqueid=yes

2
config/cdr_custom.conf Normal file
View File

@ -0,0 +1,2 @@
[mappings]
recordings.csv => ${CSV_QUOTE(${CDR(clid)})},${CSV_QUOTE(${CDR(src)})},${CSV_QUOTE(${CDR(dst)})},${CSV_QUOTE(${CDR(dcontext)})},${CSV_QUOTE(${CDR(channel)})},${CSV_QUOTE(${CDR(dstchannel)})},${CSV_QUOTE(${CDR(lastapp)})},${CSV_QUOTE(${CDR(lastdata)})},${CSV_QUOTE(${CDR(start)})},${CSV_QUOTE(${CDR(answer)})},${CSV_QUOTE(${CDR(end)})},${CSV_QUOTE(${CDR(duration)})},${CSV_QUOTE(${CDR(billsec)})},${CSV_QUOTE(${CDR(disposition)})},${CSV_QUOTE(${CDR(amaflags)})},${CSV_QUOTE(${CDR(accountcode)})},${CSV_QUOTE(${CDR(uniqueid)})},${CSV_QUOTE(${CDR(userfield)})},${CDR(sequence)}

3
config/extensions.conf Normal file
View File

@ -0,0 +1,3 @@
[incoming-calls]
; see here for the options: https://github.com/asterisk/asterisk/blob/master/apps/app_record.c
exten=>s,1,Record(/recordings/${STRFTIME(${EPOCH},,%Y-%m)}/${STRFTIME(${EPOCH},,%d)}/${UNIQUEID}.wav,60,0,qkux)

9
config/logger.conf Normal file
View File

@ -0,0 +1,9 @@
[general]
[logfiles]
console = debug,verbose,notice,warning,error
;messages = notice,warning,error
;full = verbose,notice,warning,error,debug
;security = security

97
config/modules.conf Normal file
View File

@ -0,0 +1,97 @@
[modules]
autoload = no
load = app_record.so
load = app_verbose.so
load = cdr_custom.so
load = chan_pjsip.so
; Codecs
load = codec_gsm.so
load = codec_resample.so
load = codec_ulaw.so
load = codec_alaw.so
load = codec_g722.so
load = codec_adpcm.so
load = codec_g726.so
; Formats
load = format_g719.so
load = format_g723.so
load = format_h263.so
load = format_g729.so
load = format_g726.so
load = format_h264.so
load = format_gsm.so
load = format_pcm.so
load = format_wav_gsm.so
load = format_wav.so
; Functions
load = func_callerid.so
load = func_cdr.so
load = func_pjsip_endpoint.so
load = func_sorcery.so
load = func_devstate.so
load = func_strings.so
load = func_env.so
load = pbx_config.so
; Resources
load = res_pjproject.so
load = res_pjsip_acl.so
load = res_pjsip_authenticator_digest.so
load = res_pjsip_caller_id.so
load = res_pjsip_dialog_info_body_generator.so
load = res_pjsip_diversion.so
load = res_pjsip_dtmf_info.so
load = res_pjsip_endpoint_identifier_anonymous.so
load = res_pjsip_endpoint_identifier_ip.so
load = res_pjsip_endpoint_identifier_user.so
load = res_pjsip_exten_state.so
load = res_pjsip_header_funcs.so
load = res_pjsip_logger.so
load = res_pjsip_messaging.so
load = res_pjsip_mwi_body_generator.so
load = res_pjsip_mwi.so
load = res_pjsip_nat.so
load = res_pjsip_notify.so
load = res_pjsip_one_touch_record_info.so
load = res_pjsip_outbound_authenticator_digest.so
load = res_pjsip_outbound_publish.so
load = res_pjsip_outbound_registration.so
load = res_pjsip_path.so
load = res_pjsip_pidf_body_generator.so
load = res_pjsip_pidf_digium_body_supplement.so
load = res_pjsip_pidf_eyebeam_body_supplement.so
load = res_pjsip_publish_asterisk.so
load = res_pjsip_pubsub.so
load = res_pjsip_refer.so
load = res_pjsip_registrar.so
load = res_pjsip_rfc3326.so
load = res_pjsip_sdp_rtp.so
load = res_pjsip_send_to_voicemail.so
load = res_pjsip_session.so
load = res_pjsip.so
load = res_pjsip_t38.so
load = res_pjsip_transport_websocket.so
load = res_pjsip_xpidf_body_generator.so
load = res_rtp_asterisk.so
load = res_sorcery_astdb.so
load = res_sorcery_config.so
load = res_sorcery_memory.so
load = res_sorcery_realtime.so
load = res_timing_timerfd.so
; Don't load res_hep.so and kin unless you are using hep monitoring in your network
noload = res_hep.so
noload = res_hep_pjsip.so
noload = res_hep_rtcp.so

View File

@ -0,0 +1,49 @@
[mytransport]
type=transport
protocol=udp
bind=0.0.0.0
; localnet=172.17.0.0/16
external_media_address=192.168.2.142
external_signaling_address=192.168.2.142
[mytrunk]
type=registration
transport=mytransport
outbound_auth=mytrunk
server_uri=sip:192.168.2.1:5060
client_uri=sip:internotest@192.168.2.1:5060
; contact_user = incoming-calls
[mytrunk]
type=auth
auth_type=userpass
password=mio4reil
username=internotest
[mytrunk]
type=aor
contact=sip:192.168.2.1:5060
[mytrunk]
type=endpoint
context=incoming-calls
; disallow=all
; allow=ulaw
; allow=all
disallow=all
allow=speex,g726,g722,ilbc,gsm,alaw
outbound_auth=mytrunk
aors=mytrunk
[mytrunk]
type=identify
endpoint=mytrunk
match=192.168.2.1

9
config/rtp.conf Normal file
View File

@ -0,0 +1,9 @@
[general]
;
; RTP start and RTP end configure start and end addresses
;
; Defaults are rtpstart=5000 and rtpend=31000
;
rtpstart=15000
rtpend=15100

48
start.sh Normal file
View File

@ -0,0 +1,48 @@
#!/bin/sh
SIP_SERVER=${SIP_SERVER:-127.0.0.1}
SIP_USER=${SIP_USER:-user}
SIP_PASS=${SIP_PASS:-user}
EXTERNAL_IP=${EXTERNAL_IP:-127.0.0.1}
cat >/etc/asterisk/pjsip.conf <<EOF
[mytransport]
type=transport
protocol=udp
bind=0.0.0.0
; localnet=172.17.0.0/16
external_media_address=${EXTERNAL_IP}
external_signaling_address=${EXTERNAL_IP}
[mytrunk]
type=registration
transport=mytransport
outbound_auth=mytrunk
server_uri=sip:${SIP_SERVER}:5060
client_uri=sip:${SIP_USER}@${SIP_SERVER}:5060
[mytrunk]
type=auth
auth_type=userpass
password=${SIP_PASS}
username=${SIP_USER}
[mytrunk]
type=aor
contact=sip:${SIP_SERVER}:5060
[mytrunk]
type=endpoint
context=incoming-calls
disallow=all
allow=speex,g726,g722,ilbc,gsm,alaw
outbound_auth=mytrunk
aors=mytrunk
[mytrunk]
type=identify
endpoint=mytrunk
match=${SIP_SERVER}
EOF
/usr/sbin/asterisk -cv