{ ... }: { _class = "clan.service"; manifest.name = "phonebox"; manifest.description = ""; manifest.categories = [ "System" ]; roles.default = { perInstance.nixosModule = { lib, config, ... }: let ata-interface = ""; rtpPortFrom = 10000; rtpPortTo = 20000; genServerSIPEndpoint = { hostname, address }: '' [${hostname}](internal_endpoint) aors=${hostname} [${hostname}](ip_auth) endpoint=${hostname} match=[${address}] [${hostname}](dynamiic_aor) contact=sip:[${address}] ''; genLocalSIPEndpoint = {number in { clan.core.vars.generators.phonebox = { files = { server-prefix.secret = false; ata-number.secret = false; ata-password.secret = true; }; script = ''''; }; networking.interfaces = { ${ata-interface} = { useDHCP = false; ipv4.addresses = [ { address = "192.168.254.1"; prefixLength = 24; } ]; }; }; services.dnsmasq = { enable = true; settings = { bind-interfaces = true; # enable-ra = true; domain-needed = true; domain = "localhost"; dhcp-range = [ "192.168.254.100,192.168.254.100,255.255.255.0,24h" ]; dhcp-option = [ "3,192.168.254.1" ]; interface = [ ata-interface ]; }; }; services.nginx = { enable = true; virtualHosts = { "_" = { locations."/" = { proxyPass = "http://192.168.254.100"; }; }; }; }; networking.firewall.allowedUDPPortRanges = [ { from = rtpPortFrom; to = rtpPortTo; } ]; networking.firewall.allowedUDPPorts = [ 53 67 5060 ]; networking.firewall.allowedTCPPorts = [ 53 80 ]; 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) ''; "rtp.conf" = '' [general] rtpstart=${rtpPortFrom} rtpend=${rtpPortTo} ''; "pjsip.conf" = '' [transport-udp] type=transport protocol=udp bind=0.0.0.0 [transport-udp6] type=transport protocol=udp bind=:: [base_endpoint](!) type=endpoint disallow=all allow=ulaw,alaw,g722,gsm direct_media=no [internal_endpoint](!,base_endpoint) context=from-internal [external_endpoint](!,base_endpoint) context=from-internal [userpass_auth](!) type=auth auth_type=userpass [ip_auth](!) type=identify endpoint=external [dynamiic_aor](!) type=aor ''; }; }; }; }; }