[Unit]
Description=OxPulse relay-only node: coturn
After=network-online.target coturn-self-relay-guard.service
Wants=network-online.target
Requires=coturn-self-relay-guard.service
# No secret, no cert, no env file: stay down instead of running half-configured.
ConditionPathExists=/etc/oxpulse-partner-edge/node-secret
ConditionPathExists=/etc/oxpulse-partner-edge/relay.env
ConditionPathExists=/etc/oxpulse-partner-edge/relay-certs/fullchain.pem
ConditionPathExists=/etc/oxpulse-partner-edge/relay-certs/privkey.pem
# A bad secret or missing guard must not become an endless restart loop.
StartLimitIntervalSec=300
StartLimitBurst=5

[Service]
User=turnserver
Group=turnserver
EnvironmentFile=/etc/oxpulse-partner-edge/relay.env
# "+" = full privileges, outside the sandbox below: gate, validate, require the
# guard, and render coturn.conf from the CURRENT node-secret on every (re)start.
ExecStartPre=+/usr/local/sbin/oxpulse-relay-prestart
ExecStart=/usr/local/lib/oxpulse-relay/current/turnserver -c /etc/oxpulse-partner-edge/coturn.conf
Restart=on-failure
RestartSec=5
LimitNOFILE=65536
AmbientCapabilities=CAP_NET_BIND_SERVICE
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
NoNewPrivileges=yes
ProtectSystem=strict
ProtectHome=yes
PrivateTmp=yes
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectControlGroups=yes
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX AF_NETLINK
RestrictRealtime=yes
LockPersonality=yes
SystemCallFilter=@system-service

[Install]
WantedBy=multi-user.target
