clanService/phonebox: allow multi-clients to exist on one node
This commit is contained in:
@@ -24,6 +24,36 @@
|
||||
description = "";
|
||||
default = "";
|
||||
};
|
||||
options.extraClientNumbers = lib.mkOption {
|
||||
type = with lib.types; listOf str;
|
||||
description = "List of client suffix number.";
|
||||
default = [ ];
|
||||
};
|
||||
|
||||
options.extraFixedIPClient = lib.mkOption {
|
||||
type = lib.types.attrsOf (
|
||||
lib.types.submodule {
|
||||
options = {
|
||||
ip = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "IP address for this client";
|
||||
};
|
||||
|
||||
name = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Name of the client";
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
description = "Extra client to be added to pjsip config as a fixed IP auth";
|
||||
example = {
|
||||
"01" = {
|
||||
ip = "192.168.1.3";
|
||||
name = "bob";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
perInstance =
|
||||
{
|
||||
@@ -126,6 +156,41 @@
|
||||
remove_existing=yes
|
||||
'';
|
||||
|
||||
genLocalSIPEndpointV6 =
|
||||
{ localNumber }:
|
||||
''
|
||||
[${localNumber}](internal_endpoint)
|
||||
transport=transport-udp6
|
||||
aors=${localNumber}
|
||||
auth=${localNumber}
|
||||
|
||||
[${localNumber}](userpass_auth)
|
||||
username=${localNumber}
|
||||
password=${localNumber}
|
||||
|
||||
[${localNumber}](dynamiic_aor)
|
||||
max_contacts=1
|
||||
'';
|
||||
|
||||
genLocalSIPIPEndpoint = number: ''
|
||||
|
||||
[${number}](internal_endpoint)
|
||||
aors=${number}
|
||||
auth=${number}
|
||||
contact_deny=0.0.0.0/0
|
||||
contact_deny=::/0
|
||||
contact_permit=${settings.extraFixedIPClient.${number}.ip}/128
|
||||
|
||||
[${number}](dynamiic_aor)
|
||||
max_contacts=1
|
||||
remove_existing=yes
|
||||
|
||||
[${number}](userpass_auth)
|
||||
username=${number}
|
||||
password=${number}
|
||||
|
||||
'';
|
||||
|
||||
genLocalExtenConf =
|
||||
{ localNumber }:
|
||||
''
|
||||
@@ -356,6 +421,14 @@
|
||||
+ (genLocalExtenConf {
|
||||
localNumber = config.clan.core.vars.generators.phonebox.files.ata-local-number.value;
|
||||
})
|
||||
+ lib.concatStringsSep "\n" (
|
||||
builtins.map (number: genLocalExtenConf { localNumber = number; }) settings.extraClientNumbers
|
||||
)
|
||||
+ lib.concatStringsSep "\n" (
|
||||
lib.mapAttrsToList (
|
||||
number: _: genLocalExtenConf { localNumber = number; }
|
||||
) settings.extraFixedIPClient
|
||||
)
|
||||
+ serverConf;
|
||||
|
||||
"rtp.conf" = ''
|
||||
@@ -409,6 +482,12 @@
|
||||
+ (genLocalSIPEndpoint {
|
||||
localNumber = config.clan.core.vars.generators.phonebox.files.ata-local-number.value;
|
||||
})
|
||||
+ lib.concatStringsSep "\n" (
|
||||
builtins.map (number: genLocalSIPEndpointV6 { localNumber = number; }) settings.extraClientNumbers
|
||||
)
|
||||
+ lib.concatStringsSep "\n" (
|
||||
lib.mapAttrsToList (number: _: genLocalSIPIPEndpoint number) settings.extraFixedIPClient
|
||||
)
|
||||
+ serverConf;
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user