1
0

Compare commits

..

2 Commits

Author SHA1 Message Date
Ember 'n0emis' Keske
03957afd7e
add fieldpoc dect claim script 2022-07-21 00:55:10 +02:00
Ember 'n0emis' Keske
9795ed55b8
nerd: only allow export from services-net 2022-07-20 23:58:11 +02:00
8 changed files with 57 additions and 5 deletions

View File

@ -2,7 +2,7 @@ keys:
- &admin_clerie DD2D88B9FCB74C81E6F63AAD5B5D448C88684BC3
- &admin_n0emis 6E10217E3187069E057DF5ABE0262A773B824745
- &host_nerd age1x69924s94z4k7s50utyuqrwshpt8p8yzwaxny2gle7yeyg4w3spqml95mu
- &host_yate age10pxa70g3ekxdrk788l52s93a6ftavdw3r8x6d23gmsluudmwq3asmu6ah9\
- &host_yate age10pxa70g3ekxdrk788l52s93a6ftavdw3r8x6d23gmsluudmwq3asmu6ah9
- &host_yate_dialup age14zsha5c5238v6hzchdfkjgjjwzc2qc79tl0ngmqrdquck5f945zs35vps4
- &host_pre_yate_n0emis age1lrujyz4d48yjelmh6eufxjffuvfm9pusen3uxskyhnyf27xyucdqq3jza5
creation_rules:

View File

@ -79,8 +79,16 @@
enable = true;
virtualHosts."nerd.bula22.de" = {
extraConfig = ''
@disallow_export {
not remote_ip 10.42.10.0/24 2a01:4f8:1c0c:8221::/64
path /export.json*
}
route {
file_server /static/*
respond @disallow_export 403 {
close
}
reverse_proxy * http://127.0.0.1:10510
}

30
hosts/yate/dect_claim.py Normal file
View File

@ -0,0 +1,30 @@
import asyncio
import os
import re
import socket
from yate.ivr import YateIVR
SOUNDS_PATH = "/run/current-system/sw/share/sounds/yate"
async def main(ivr: YateIVR):
caller_id = ivr.call_params.get("caller", "")
caller_id = re.sub("[^\\d]", "", caller_id)
called_id = ivr.call_params.get("called", "")
called_id = re.sub("[^\\d]", "", called_id)
await ivr.play_soundfile(
os.path.join(SOUNDS_PATH, "yintro.slin"),
complete=True)
await asyncio.sleep(0.5)
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect(("localhost", 9437))
s.recv(1024)
s.sendall(f"claim {caller_id} {called_id}".encode('utf-8'))
s.recv(1024)
app = YateIVR()
app.run(main)

View File

@ -42,4 +42,12 @@
[dialin]
\${sip_x-called}^.*$=lateroute/\\1";
};
environment.systemPackages = with pkgs; [
(writers.makePythonWriter python39 python39.pkgs "/bin/dect_claim" { libraries = [ python39.pkgs.python-yate ]; } (builtins.readFile ./dect_claim.py))
(runCommand "yintro.slin" {} ''
mkdir -p $out/share/sounds/yate
ln -s ${./yintro.slin} $out/share/sounds/yate/yintro.slin
'')
];
}

BIN
hosts/yate/yintro.slin Normal file

Binary file not shown.

View File

@ -20,12 +20,16 @@ in {
};
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [
python3.pkgs.fieldpoc
];
services.postgresql = {
enable = true;
initialScript = pkgs.writeText "backend-initScript" ''
CREATE ROLE nixcloud WITH LOGIN PASSWORD 'nixcloud' CREATEDB;
CREATE DATABASE nixcloud;
GRANT ALL PRIVILEGES ON DATABASE nixcloud TO nixcloud;
CREATE ROLE fieldpoc WITH LOGIN PASSWORD 'fieldpoc' CREATEDB;
CREATE DATABASE fieldpoc;
GRANT ALL PRIVILEGES ON DATABASE fieldpoc TO fieldpoc;
'';
};

View File

@ -6,6 +6,8 @@ self: super: {
python3 = let packageOverrides = final: prev: import ./python final prev;
in super.python3.override { inherit packageOverrides; };
python39 = let packageOverrides = final: prev: import ./python final prev;
in super.python39.override { inherit packageOverrides; };
yate = super.yate.overrideAttrs (old: {
configureFlags =

View File

@ -7,7 +7,7 @@ buildPythonApplication rec {
src = fetchGit {
url = "https://git.n0emis.eu/n0emis/fieldpoc.git";
ref = "main";
rev = "d6d664b4690189a7ed54be65ceef8cb3d79a6bfb";
rev = "2f1347f3415249cb116501af1f5e3282afca24be";
};
format = "pyproject";