nixpkgs/nixos/modules/services/misc/siproxd.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

197 lines
4.8 KiB
Nix
Raw Normal View History

2014-07-10 14:08:38 -04:00
{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.siproxd;
conf = ''
daemonize = 0
rtp_proxy_enable = 1
user = siproxd
if_inbound = ${cfg.ifInbound}
if_outbound = ${cfg.ifOutbound}
sip_listen_port = ${toString cfg.sipListenPort}
rtp_port_low = ${toString cfg.rtpPortLow}
rtp_port_high = ${toString cfg.rtpPortHigh}
rtp_dscp = ${toString cfg.rtpDscp}
sip_dscp = ${toString cfg.sipDscp}
${lib.optionalString (
cfg.hostsAllowReg != [ ]
) "hosts_allow_reg = ${lib.concatStringsSep "," cfg.hostsAllowReg}"}
${lib.optionalString (
cfg.hostsAllowSip != [ ]
) "hosts_allow_sip = ${lib.concatStringsSep "," cfg.hostsAllowSip}"}
${lib.optionalString (
cfg.hostsDenySip != [ ]
) "hosts_deny_sip = ${lib.concatStringsSep "," cfg.hostsDenySip}"}
${lib.optionalString (cfg.passwordFile != "") "proxy_auth_pwfile = ${cfg.passwordFile}"}
2014-07-10 14:08:38 -04:00
${cfg.extraConfig}
'';
confFile = builtins.toFile "siproxd.conf" conf;
in
{
##### interface
options = {
services.siproxd = {
enable = lib.mkOption {
type = lib.types.bool;
2014-07-10 14:08:38 -04:00
default = false;
description = ''
Whether to enable the Siproxd SIP
2020-11-22 17:23:53 +10:00
proxy/masquerading daemon.
2014-07-10 14:08:38 -04:00
'';
};
ifInbound = lib.mkOption {
type = lib.types.str;
2014-07-10 14:08:38 -04:00
example = "eth0";
description = "Local network interface";
};
ifOutbound = lib.mkOption {
type = lib.types.str;
2014-07-10 14:08:38 -04:00
example = "ppp0";
description = "Public network interface";
};
hostsAllowReg = lib.mkOption {
type = lib.types.listOf lib.types.str;
2020-11-22 17:23:53 +10:00
default = [ ];
2014-07-10 14:08:38 -04:00
example = [
"192.168.1.0/24"
"192.168.2.0/24"
];
2020-11-22 17:23:53 +10:00
description = ''
2023-05-19 22:11:38 -04:00
Access control list for incoming SIP registrations.
2014-07-10 14:08:38 -04:00
'';
};
hostsAllowSip = lib.mkOption {
type = lib.types.listOf lib.types.str;
2020-11-22 17:23:53 +10:00
default = [ ];
2014-07-10 14:08:38 -04:00
example = [
"123.45.0.0/16"
"123.46.0.0/16"
];
2020-11-22 17:23:53 +10:00
description = ''
2023-05-19 22:11:38 -04:00
Access control list for incoming SIP traffic.
2014-07-10 14:08:38 -04:00
'';
};
hostsDenySip = lib.mkOption {
type = lib.types.listOf lib.types.str;
2020-11-22 17:23:53 +10:00
default = [ ];
2014-07-10 14:08:38 -04:00
example = [
"10.0.0.0/8"
"11.0.0.0/8"
];
2020-11-22 17:23:53 +10:00
description = ''
2023-05-19 22:11:38 -04:00
Access control list for denying incoming
2020-11-22 17:23:53 +10:00
SIP registrations and traffic.
2014-07-10 14:08:38 -04:00
'';
};
sipListenPort = lib.mkOption {
type = lib.types.int;
2014-07-10 14:08:38 -04:00
default = 5060;
description = ''
2020-11-22 17:23:53 +10:00
Port to listen for incoming SIP messages.
2014-07-10 14:08:38 -04:00
'';
};
rtpPortLow = lib.mkOption {
type = lib.types.int;
2014-07-10 14:08:38 -04:00
default = 7070;
description = ''
Bottom of UDP port range for incoming and outgoing RTP traffic
'';
};
rtpPortHigh = lib.mkOption {
type = lib.types.int;
2014-07-10 14:08:38 -04:00
default = 7089;
description = ''
Top of UDP port range for incoming and outgoing RTP traffic
'';
};
rtpTimeout = lib.mkOption {
type = lib.types.int;
2014-07-10 14:08:38 -04:00
default = 300;
description = ''
Timeout for an RTP stream. If for the specified
2014-07-10 14:08:38 -04:00
number of seconds no data is relayed on an active
stream, it is considered dead and will be killed.
'';
};
rtpDscp = lib.mkOption {
type = lib.types.int;
2014-07-10 14:08:38 -04:00
default = 46;
description = ''
DSCP (differentiated services) value to be assigned
to RTP packets. Allows QOS aware routers to handle
2014-07-10 14:08:38 -04:00
different types traffic with different priorities.
'';
};
sipDscp = lib.mkOption {
type = lib.types.int;
2014-07-10 14:08:38 -04:00
default = 0;
description = ''
DSCP (differentiated services) value to be assigned
to SIP packets. Allows QOS aware routers to handle
2014-07-10 14:08:38 -04:00
different types traffic with different priorities.
'';
};
passwordFile = lib.mkOption {
type = lib.types.str;
2014-07-10 14:08:38 -04:00
default = "";
description = ''
Path to per-user password file.
'';
};
extraConfig = lib.mkOption {
type = lib.types.lines;
2014-07-10 14:08:38 -04:00
default = "";
description = ''
Extra configuration to add to siproxd configuration.
'';
};
};
};
##### implementation
config = lib.mkIf cfg.enable {
2014-07-10 14:08:38 -04:00
users.users.siproxyd = {
2014-07-10 14:08:38 -04:00
uid = config.ids.uids.siproxd;
};
systemd.services.siproxd = {
description = "SIP proxy/masquerading daemon";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
serviceConfig = {
ExecStart = "${pkgs.siproxd}/sbin/siproxd -c ${confFile}";
};
};
};
}