173 lines
4.6 KiB
Nix
173 lines
4.6 KiB
Nix
{ ... }:
|
|
{
|
|
_class = "clan.service";
|
|
manifest.name = "asterisk";
|
|
manifest.description = "Asterisk PBX server";
|
|
manifest.categories = [ "System" ];
|
|
|
|
roles.default = {
|
|
perInstance.nixosModule =
|
|
{
|
|
lib,
|
|
...
|
|
}:
|
|
{
|
|
networking.firewall.allowedUDPPorts = [ 5060 ];
|
|
services.asterisk = {
|
|
enable = lib.mkDefault true;
|
|
confFiles = {
|
|
"logger.conf" = ''
|
|
[general]
|
|
dateformat = %F %T.%3q ; ISO 8601 date format with milliseconds
|
|
use_callids = yes
|
|
appendhostname = no
|
|
queue_log = yes
|
|
queue_log_to_file = no
|
|
queue_log_name = queue_log
|
|
queue_log_realtime_use_gmt = no
|
|
rotatestrategy = rotate
|
|
exec_after_rotate=gzip -9 $\{filename\}.2
|
|
[logfiles]
|
|
console => notice,warning,error
|
|
security => security
|
|
messages => notice,warning,error
|
|
full => notice,warning,error,verbose,dtmf,fax
|
|
syslog.local0 => notice,warning,error
|
|
'';
|
|
# Dial plan config
|
|
"extensions.conf" = ''
|
|
[from-internal]
|
|
exten => 100,1,Answer()
|
|
same => n,Wait(1)
|
|
same => n,Playback(hello-world)
|
|
same => n,Hangup()
|
|
|
|
exten => 6001,1,Dial(PJSIP/6001,20)
|
|
exten => 6002,1,Dial(PJSIP/6002,20)
|
|
exten => 8001,1,Dial(PJSIP/8001@kurogeek,20)
|
|
'';
|
|
|
|
"pjsip.conf" = ''
|
|
[transport-udp]
|
|
type=transport
|
|
protocol=udp
|
|
bind=0.0.0.0
|
|
[transport-udp6]
|
|
type=transport
|
|
protocol=udp
|
|
bind=::
|
|
|
|
[kurogeek]
|
|
type=endpoint
|
|
context=from-kurogeek
|
|
disallow=all
|
|
allow=ulaw
|
|
allow=alaw
|
|
allow=g722
|
|
allow=gsm
|
|
aors=kurogeek
|
|
direct_media=no
|
|
|
|
[kurogeek]
|
|
type=aor
|
|
contact=sip:[fd79:fada:fbe9:8c5d:d899:932b:d36d:b8cc]
|
|
|
|
[kurogeek]
|
|
type=identify
|
|
endpoint=kurogeek
|
|
match=[fd79:fada:fbe9:8c5d:d899:932b:d36d:b8cc]
|
|
|
|
[6001]
|
|
type=endpoint
|
|
context=from-internal
|
|
disallow=all
|
|
allow=ulaw
|
|
allow=alaw
|
|
allow=g722
|
|
allow=gsm
|
|
auth=6001
|
|
aors=6001
|
|
direct_media=no
|
|
|
|
[6001]
|
|
type=auth
|
|
auth_type=userpass
|
|
password=unsecurepassword
|
|
username=6001
|
|
|
|
[6001]
|
|
type=aor
|
|
max_contacts=1
|
|
|
|
[6002]
|
|
type=endpoint
|
|
context=from-internal
|
|
disallow=all
|
|
allow=ulaw
|
|
allow=alaw
|
|
allow=g722
|
|
allow=gsm
|
|
auth=6002
|
|
aors=6002
|
|
direct_media=no
|
|
|
|
[6002]
|
|
type=auth
|
|
auth_type=userpass
|
|
password=unsecurepassword
|
|
username=6002
|
|
|
|
[6002]
|
|
type=aor
|
|
max_contacts=1
|
|
'';
|
|
# "pjsip.conf" = ''
|
|
# [transport-udp6]
|
|
# type=transport
|
|
# protocol=udp
|
|
# bind=::
|
|
#
|
|
# [transport-udp]
|
|
# type=transport
|
|
# protocol=udp
|
|
# bind=0.0.0.0
|
|
#
|
|
# [endpoint_internal](!)
|
|
# type=endpoint
|
|
# context=from-internal
|
|
# disallow=all
|
|
# allow=ulaw
|
|
# allow=alaw
|
|
# allow=g722
|
|
# allow=gsm
|
|
#
|
|
# [auth_userpass](!)
|
|
# type=auth
|
|
# auth_type=userpass
|
|
#
|
|
# [aor_dynamic](!)
|
|
# type=aor
|
|
# max_contacts=1
|
|
#
|
|
# [user1](endpoint_internal)
|
|
# auth=user1
|
|
# aors=user1
|
|
# [user1](auth_userpass)
|
|
# password=user1
|
|
# username=user1
|
|
# [user1](aor_dynamic)
|
|
#
|
|
# [user2](endpoint_internal)
|
|
# auth=user2
|
|
# aors=user2
|
|
# [user2](auth_userpass)
|
|
# password=user2
|
|
# username=user2
|
|
# [user2](aor_dynamic)
|
|
# '';
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|