diff --git a/ops/nixos/bvm-prosody/asterisk-override.nix b/ops/nixos/bvm-prosody/asterisk-override.nix new file mode 100644 index 0000000000..87083ab931 --- /dev/null +++ b/ops/nixos/bvm-prosody/asterisk-override.nix @@ -0,0 +1,14 @@ +{ asterisk, fetchFromGitHub, fetchpatch, ... }: + +asterisk.overrideAttrs (old: { + #src = /home/lukegb/Projects/asterisk; + #patches = [ /home/lukegb/Projects/asterisk.patch ]; + patches = [ + #(fetchpatch { + # url = "https://p.lukegb.com/raw/MultiplyMagicalKoi.patch"; + # sha256 = "056iy9415xyp9g69xs8ckyvccs8sskc7zp7frnwrvl7wlxnsf2va"; + #}) + /home/lukegb/Projects/asterisk.patch + ]; + enableParallelBuilding = true; +}) diff --git a/ops/nixos/bvm-prosody/default.nix b/ops/nixos/bvm-prosody/default.nix index b70f1a1827..a215d351a9 100644 --- a/ops/nixos/bvm-prosody/default.nix +++ b/ops/nixos/bvm-prosody/default.nix @@ -6,6 +6,7 @@ { imports = [ ../lib/bvm.nix + ./eventphone-asterisk.nix ]; # Networking! @@ -58,9 +59,6 @@ services.prosody = { enable = true; admins = [ "admin@lukegb.com" "lukegb@lukegb.com" ]; - package = pkgs.prosody.override { - withCommunityModules = [ "external_services" ]; - }; virtualHosts."lukegb.com" = { enabled = true; @@ -112,6 +110,9 @@ secret = turn_secret, } } + + Component "asterisk.lukegb.com" + component_secret = "thisisasampleofspeex" ''; }; diff --git a/ops/nixos/bvm-prosody/eventphone-asterisk.nix b/ops/nixos/bvm-prosody/eventphone-asterisk.nix new file mode 100644 index 0000000000..e26bccd10b --- /dev/null +++ b/ops/nixos/bvm-prosody/eventphone-asterisk.nix @@ -0,0 +1,100 @@ +# SPDX-FileCopyrightText: 2020 Luke Granger-Brown +# +# SPDX-License-Identifier: Apache-2.0 + +{ depot, lib, pkgs, config, ... }: + +{ + services.asterisk = { + enable = true; + confFiles = { + "pjsip.conf" = '' + [transport-udp] + type=transport + protocol=udp + bind=92.118.28.3 + + [transport-udp-v6] + type=transport + protocol=udp + bind=2a09:a441::3 + + [eventphone-registration] + type=registration + transport=transport-udp + outbound_auth=eventphone-auth + server_uri=sip:voip.eventphone.de + client_uri=sip:5422@voip.eventphone.de + contact_user=5422 + retry_interval=60 + forbidden_retry_interval=600 + expiration=3600 + line=yes + endpoint=eventphone + + [eventphone-auth] + type=auth + auth_type=userpass + username=5422 + password=BPun1r0l7JJZ + realm=voip.eventphone.de + + [eventphone] + type=endpoint + allow=!all,ulaw,alaw + context=eventphone-incoming + outbound_auth=eventphone-auth + transport=transport-udp + aors=eventphone-aor + from_domain=voip.eventphone.de + + [eventphone-aor] + type=aor + contact=sip:voip.eventphone.de + max_contacts=10 + + [eventphone-identify] + type=identify + endpoint=eventphone + match=45.15.105.12/32 + ''; + "motif.conf" = '' + [default](!) + disallow=all + allow=ulaw + allow=h264 + context=incoming-motif + + [prosody](default) + transport=ice-udp + connection=prosody + ''; + "xmpp.conf" = '' + [general] + debug=yes + + [prosody] + type=component + serverhost=localhost + username=asterisk.lukegb.com + secret=thisisasampleofspeex + port=5347 + context=xmpp-incoming + debug=yes + usetls=no + usesasl=no + autoregister=yes + buddy=lukegb@lukegb.com + ''; + "extensions.conf" = '' + [eventphone-incoming] + exten => _X.,1,Answer() + exten => _X.,n,Dial(Motif/prosody/lukegb@lukegb.com) + + [xmpp-incoming] + exten => _X.,1,Dial(PJSIP/''${EXTEN:1}@eventphone) + ''; + }; + package = pkgs.callPackage ./asterisk-override.nix {}; + }; +}