summaryrefslogtreecommitdiff
path: root/abbenay/asterisk.nix
blob: f8a4d1254bdd131bcbee156ed38ea40debb97c63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
{ config, lib, pkgs, ... }:

{

  networking.firewall.enable = false;
  services.asterisk = {
    enable = true;
    confFiles = {
      "extensions.conf" = ''
        [from-internal]
        ; Dial 100 for "hello, world"
        exten => 100,1,Answer()
        same  =>     n,Wait(1)
        same  =>     n,Playback(hello-world)
        same  =>     n,Hangup()

        exten=>6001,1,Dial(PJSIP/demo-alice,20)
        exten=>6002,1,Dial(PJSIP/demo-bob,20)
      '';
      "pjsip.conf" = ''
        [transport-udp]
        type=transport
        protocol=udp
        bind=0.0.0.0


        [endpoint_internal](!)
        type=endpoint
        context=from-internal
        disallow=all
        allow=ulaw

        [auth_userpass](!)
        type=auth
        auth_type=userpass

        [aor_dynamic](!)
        type=aor
        max_contacts=1

        ;Definitions for our phones, using the templates above

        [demo-alice](endpoint_internal)
        auth=demo-alice
        aors=demo-alice
        [demo-alice](auth_userpass)
        password=unsecurepassword ; put a strong, unique password here instead
        username=demo-alice

        [demo-alice]
        type=aor
        contact=sip:192.168.69.113
        max_contacts=1

        [demo-bob](endpoint_internal)
        auth=demo-bob
        aors=demo-bob
        [demo-bob](auth_userpass)
        password=unsecurepassword ; put a strong, unique password here instead
        username=demo-bob
        [demo-bob](aor_dynamic)
      '';
      "logger.conf" = ''
        [general]

        [logfiles]
        ; Add debug output to log
        syslog.local0 => notice,warning,error,debug,verbose4
      '';
    };
  };
}