feat(sip): make rtp_timeout_hold configurable in Web UI and default to 0 (unlimited hold)
This commit is contained in:
1 parent
767fea46b7
commit
c1805c9076
5 files changed
+30
-14
No files matched your search
+6
-3
@@ -2017,6 +2017,7 @@ try {
|
|||||||
$rtpChecksums = !empty($payload['rtp_checksums']) ? 1 : 0;
|
$rtpChecksums = !empty($payload['rtp_checksums']) ? 1 : 0;
|
||||||
$rtpStrict = !empty($payload['rtp_strict']) ? 1 : 0;
|
$rtpStrict = !empty($payload['rtp_strict']) ? 1 : 0;
|
||||||
$rtpTimeout = max(5, (int)($payload['rtp_timeout'] ?? 30));
|
$rtpTimeout = max(5, (int)($payload['rtp_timeout'] ?? 30));
|
||||||
|
$rtpHoldTimeout = max(0, (int)($payload['rtp_timeout_hold'] ?? 0));
|
||||||
$rtpKeepalive = max(0, (int)($payload['rtp_keepalive'] ?? 15));
|
$rtpKeepalive = max(0, (int)($payload['rtp_keepalive'] ?? 15));
|
||||||
$allowAnonymousSip = !empty($payload['allow_anonymous_sip']) ? 1 : 0;
|
$allowAnonymousSip = !empty($payload['allow_anonymous_sip']) ? 1 : 0;
|
||||||
|
|
||||||
@@ -2051,6 +2052,7 @@ try {
|
|||||||
rtp_checksums = :rtp_checksums,
|
rtp_checksums = :rtp_checksums,
|
||||||
rtp_strict = :rtp_strict,
|
rtp_strict = :rtp_strict,
|
||||||
rtp_timeout = :rtp_timeout,
|
rtp_timeout = :rtp_timeout,
|
||||||
|
rtp_timeout_hold = :rtp_timeout_hold,
|
||||||
rtp_keepalive = :rtp_keepalive,
|
rtp_keepalive = :rtp_keepalive,
|
||||||
allow_anonymous_sip = :anon,
|
allow_anonymous_sip = :anon,
|
||||||
updated_at = CURRENT_TIMESTAMP
|
updated_at = CURRENT_TIMESTAMP
|
||||||
@@ -2068,9 +2070,10 @@ try {
|
|||||||
':rtp_start' => $rtpStart,
|
':rtp_start' => $rtpStart,
|
||||||
':rtp_end' => $rtpEnd,
|
':rtp_end' => $rtpEnd,
|
||||||
':rtp_checksums' => $rtpChecksums,
|
':rtp_checksums' => $rtpChecksums,
|
||||||
':rtp_strict' => $rtpStrict,
|
':rtp_strict' => $rtpStrict,
|
||||||
':rtp_timeout' => $rtpTimeout,
|
':rtp_timeout' => $rtpTimeout,
|
||||||
':rtp_keepalive' => $rtpKeepalive,
|
':rtp_timeout_hold' => $rtpHoldTimeout,
|
||||||
|
':rtp_keepalive' => $rtpKeepalive,
|
||||||
':anon' => $allowAnonymousSip,
|
':anon' => $allowAnonymousSip,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@@ -4152,6 +4152,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
rtp_checksums: Number(document.getElementById('sip-rtp-checksums')?.value || 1),
|
rtp_checksums: Number(document.getElementById('sip-rtp-checksums')?.value || 1),
|
||||||
rtp_keepalive: Number(document.getElementById('sip-rtp-keepalive')?.value || 15),
|
rtp_keepalive: Number(document.getElementById('sip-rtp-keepalive')?.value || 15),
|
||||||
rtp_timeout: Number(document.getElementById('sip-rtp-timeout')?.value || 30),
|
rtp_timeout: Number(document.getElementById('sip-rtp-timeout')?.value || 30),
|
||||||
|
rtp_timeout_hold: Number(document.getElementById('sip-rtp-timeout-hold')?.value || 0),
|
||||||
allow_anonymous_sip: Number(document.getElementById('sip-allow-anonymous')?.value || 0),
|
allow_anonymous_sip: Number(document.getElementById('sip-allow-anonymous')?.value || 0),
|
||||||
local_networks: localNets
|
local_networks: localNets
|
||||||
};
|
};
|
||||||
@@ -4613,6 +4614,11 @@ function renderSipSettings() {
|
|||||||
rtpTimeoutEl.value = (s.rtp_timeout !== undefined && s.rtp_timeout !== null) ? s.rtp_timeout : 30;
|
rtpTimeoutEl.value = (s.rtp_timeout !== undefined && s.rtp_timeout !== null) ? s.rtp_timeout : 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const rtpHoldTimeoutEl = document.getElementById('sip-rtp-timeout-hold');
|
||||||
|
if (rtpHoldTimeoutEl && document.activeElement !== rtpHoldTimeoutEl) {
|
||||||
|
rtpHoldTimeoutEl.value = (s.rtp_timeout_hold !== undefined && s.rtp_timeout_hold !== null) ? s.rtp_timeout_hold : 0;
|
||||||
|
}
|
||||||
|
|
||||||
const allowAnonEl = document.getElementById('sip-allow-anonymous');
|
const allowAnonEl = document.getElementById('sip-allow-anonymous');
|
||||||
if (allowAnonEl) {
|
if (allowAnonEl) {
|
||||||
allowAnonEl.value = (s.allow_anonymous_sip !== undefined && s.allow_anonymous_sip !== null) ? String(s.allow_anonymous_sip) : '0';
|
allowAnonEl.value = (s.allow_anonymous_sip !== undefined && s.allow_anonymous_sip !== null) ? String(s.allow_anonymous_sip) : '0';
|
||||||
|
|||||||
+7
-1
@@ -2554,7 +2554,7 @@ $isDevEnv = file_exists(__DIR__ . '/../.dev')
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 pt-2">
|
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 pt-2">
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-xs font-semibold text-slate-200 mb-1">RTP Keepalive (secondes)</label>
|
<label class="block text-xs font-semibold text-slate-200 mb-1">RTP Keepalive (secondes)</label>
|
||||||
<input type="number" id="sip-rtp-keepalive" name="rtp_keepalive" value="15" min="0" max="120"
|
<input type="number" id="sip-rtp-keepalive" name="rtp_keepalive" value="15" min="0" max="120"
|
||||||
@@ -2567,6 +2567,12 @@ $isDevEnv = file_exists(__DIR__ . '/../.dev')
|
|||||||
class="w-full px-3 py-2 rounded-xl bg-anthracite-950 border border-anthracite-700 text-xs text-white font-mono focus:ring-2 focus:ring-emerald-500 focus:outline-none">
|
class="w-full px-3 py-2 rounded-xl bg-anthracite-950 border border-anthracite-700 text-xs text-white font-mono focus:ring-2 focus:ring-emerald-500 focus:outline-none">
|
||||||
<p class="text-[11px] text-slate-400 mt-1">Durée avant coupure si aucun flux voix n'est reçu (raccroché distant brutal).</p>
|
<p class="text-[11px] text-slate-400 mt-1">Durée avant coupure si aucun flux voix n'est reçu (raccroché distant brutal).</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-semibold text-slate-200 mb-1">RTP Timeout Mise en attente</label>
|
||||||
|
<input type="number" id="sip-rtp-timeout-hold" name="rtp_timeout_hold" value="0" min="0" max="3600"
|
||||||
|
class="w-full px-3 py-2 rounded-xl bg-anthracite-950 border border-anthracite-700 text-xs text-white font-mono focus:ring-2 focus:ring-emerald-500 focus:outline-none">
|
||||||
|
<p class="text-[11px] text-slate-400 mt-1">Délai max d'un appel en attente sans flux RTP (0 = illimité / désactivé).</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ class ConfigGenerator
|
|||||||
|
|
||||||
// Détection automatique et purge des flux RTP fantômes / morts (ex: basculement HA, coupure réseau)
|
// Détection automatique et purge des flux RTP fantômes / morts (ex: basculement HA, coupure réseau)
|
||||||
$rtpTimeout = max(5, (int)($settings['rtp_timeout'] ?? 30));
|
$rtpTimeout = max(5, (int)($settings['rtp_timeout'] ?? 30));
|
||||||
$rtpHoldTimeout = max(60, (int)($settings['rtp_timeout_hold'] ?? 600)); // Par défaut 600s = 10 minutes d'attente max
|
$rtpHoldTimeout = max(0, (int)($settings['rtp_timeout_hold'] ?? 0));
|
||||||
$rtpKeepalive = max(0, (int)($settings['rtp_keepalive'] ?? 15));
|
$rtpKeepalive = max(0, (int)($settings['rtp_keepalive'] ?? 15));
|
||||||
$lines[] = "rtp_timeout = {$rtpTimeout}";
|
$lines[] = "rtp_timeout = {$rtpTimeout}";
|
||||||
$lines[] = "rtp_timeout_hold = {$rtpHoldTimeout}";
|
$lines[] = "rtp_timeout_hold = {$rtpHoldTimeout}";
|
||||||
@@ -401,7 +401,7 @@ class ConfigGenerator
|
|||||||
$lines[] = "trust_id_outbound = {$trustOutbound}";
|
$lines[] = "trust_id_outbound = {$trustOutbound}";
|
||||||
$lines[] = "timers = {$timers}";
|
$lines[] = "timers = {$timers}";
|
||||||
$rtpTimeout = max(5, (int)($settings['rtp_timeout'] ?? 30));
|
$rtpTimeout = max(5, (int)($settings['rtp_timeout'] ?? 30));
|
||||||
$rtpHoldTimeout = max(60, (int)($settings['rtp_timeout_hold'] ?? 600)); // Par défaut 600s = 10 minutes d'attente max
|
$rtpHoldTimeout = max(0, (int)($settings['rtp_timeout_hold'] ?? 0));
|
||||||
$lines[] = "rtp_timeout = {$rtpTimeout}";
|
$lines[] = "rtp_timeout = {$rtpTimeout}";
|
||||||
$lines[] = "rtp_timeout_hold = {$rtpHoldTimeout}";
|
$lines[] = "rtp_timeout_hold = {$rtpHoldTimeout}";
|
||||||
if ($rtpKeepalive > 0) {
|
if ($rtpKeepalive > 0) {
|
||||||
@@ -1779,9 +1779,10 @@ class ConfigGenerator
|
|||||||
$rtpEnd = max($rtpStart + 4, min(65535, (int)($settings['rtp_end'] ?? 20000)));
|
$rtpEnd = max($rtpStart + 4, min(65535, (int)($settings['rtp_end'] ?? 20000)));
|
||||||
$checksums = !empty($settings['rtp_checksums']) ? 'yes' : 'no';
|
$checksums = !empty($settings['rtp_checksums']) ? 'yes' : 'no';
|
||||||
$strict = !empty($settings['rtp_strict']) ? 'yes' : 'no';
|
$strict = !empty($settings['rtp_strict']) ? 'yes' : 'no';
|
||||||
$timeout = max(5, (int)($settings['rtp_timeout'] ?? 30));
|
$timeout = max(5, (int)($settings['rtp_timeout'] ?? 30));
|
||||||
$keepalive = max(0, (int)($settings['rtp_keepalive'] ?? 15));
|
$holdTimeout = max(0, (int)($settings['rtp_timeout_hold'] ?? 0));
|
||||||
$date = date('Y-m-d H:i:s');
|
$keepalive = max(0, (int)($settings['rtp_keepalive'] ?? 15));
|
||||||
|
$date = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
$lines = [];
|
$lines = [];
|
||||||
$lines[] = "; ===========================================================================";
|
$lines[] = "; ===========================================================================";
|
||||||
@@ -1794,7 +1795,7 @@ class ConfigGenerator
|
|||||||
$lines[] = "rtpchecksums = {$checksums}";
|
$lines[] = "rtpchecksums = {$checksums}";
|
||||||
$lines[] = "strictrtp = {$strict}";
|
$lines[] = "strictrtp = {$strict}";
|
||||||
$lines[] = "rtptimeout = {$timeout}";
|
$lines[] = "rtptimeout = {$timeout}";
|
||||||
$lines[] = "rtpholdtimeout = 300";
|
$lines[] = "rtpholdtimeout = {$holdTimeout}";
|
||||||
if ($keepalive > 0) {
|
if ($keepalive > 0) {
|
||||||
$lines[] = "rtpkeepalive = {$keepalive}";
|
$lines[] = "rtpkeepalive = {$keepalive}";
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -46,9 +46,9 @@ class Database
|
|||||||
@chmod(self::DB_PATH, 0660);
|
@chmod(self::DB_PATH, 0660);
|
||||||
} else {
|
} else {
|
||||||
// Si la base existe déjà, éviter d'exécuter l'intégralité du DDL à chaque requête HTTP
|
// Si la base existe déjà, éviter d'exécuter l'intégralité du DDL à chaque requête HTTP
|
||||||
// ce qui sature SQLite de verrous exclusifs inutiles. On teste juste l'existence de la table principale.
|
// ce qui sature SQLite de verrous exclusifs inutiles. On s'assure des colonnes requises.
|
||||||
try {
|
try {
|
||||||
self::$instance->query("SELECT 1 FROM settings LIMIT 1");
|
self::$instance->query("SELECT rtp_timeout_hold FROM settings LIMIT 1");
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
self::initializeSchema();
|
self::initializeSchema();
|
||||||
}
|
}
|
||||||
@@ -89,7 +89,7 @@ class Database
|
|||||||
rtp_checksums INTEGER NOT NULL DEFAULT 1,
|
rtp_checksums INTEGER NOT NULL DEFAULT 1,
|
||||||
rtp_strict INTEGER NOT NULL DEFAULT 1,
|
rtp_strict INTEGER NOT NULL DEFAULT 1,
|
||||||
rtp_timeout INTEGER NOT NULL DEFAULT 30,
|
rtp_timeout INTEGER NOT NULL DEFAULT 30,
|
||||||
rtp_timeout_hold INTEGER NOT NULL DEFAULT 600,
|
rtp_timeout_hold INTEGER NOT NULL DEFAULT 0,
|
||||||
rtp_keepalive INTEGER NOT NULL DEFAULT 15,
|
rtp_keepalive INTEGER NOT NULL DEFAULT 15,
|
||||||
allow_anonymous_sip INTEGER NOT NULL DEFAULT 0,
|
allow_anonymous_sip INTEGER NOT NULL DEFAULT 0,
|
||||||
last_applied_at DATETIME DEFAULT NULL,
|
last_applied_at DATETIME DEFAULT NULL,
|
||||||
@@ -393,7 +393,7 @@ class Database
|
|||||||
'rtp_checksums' => "INTEGER NOT NULL DEFAULT 1",
|
'rtp_checksums' => "INTEGER NOT NULL DEFAULT 1",
|
||||||
'rtp_strict' => "INTEGER NOT NULL DEFAULT 1",
|
'rtp_strict' => "INTEGER NOT NULL DEFAULT 1",
|
||||||
'rtp_timeout' => "INTEGER NOT NULL DEFAULT 30",
|
'rtp_timeout' => "INTEGER NOT NULL DEFAULT 30",
|
||||||
'rtp_timeout_hold' => "INTEGER NOT NULL DEFAULT 600",
|
'rtp_timeout_hold' => "INTEGER NOT NULL DEFAULT 0",
|
||||||
'rtp_keepalive' => "INTEGER NOT NULL DEFAULT 15",
|
'rtp_keepalive' => "INTEGER NOT NULL DEFAULT 15",
|
||||||
'allow_anonymous_sip' => "INTEGER NOT NULL DEFAULT 0",
|
'allow_anonymous_sip' => "INTEGER NOT NULL DEFAULT 0",
|
||||||
'system_language' => "VARCHAR(16) NOT NULL DEFAULT 'fr'",
|
'system_language' => "VARCHAR(16) NOT NULL DEFAULT 'fr'",
|
||||||
|
|||||||
Reference in new issue
Block a user