...
This commit is contained in:
@@ -1 +1 @@
|
||||
2922310
|
||||
329755
|
||||
|
||||
@@ -1 +1 @@
|
||||
2922459
|
||||
329872
|
||||
|
||||
@@ -117,11 +117,18 @@ export const AdminMenu = [
|
||||
{
|
||||
id: "180",
|
||||
label: "setting.nginx.title",
|
||||
class: "end",
|
||||
link: "/settings/nginx",
|
||||
access: "1_18",
|
||||
icon: <MdVerified size={18} />,
|
||||
},
|
||||
{
|
||||
id: "181",
|
||||
label: "nginxManagement.rtpSettingsTitle",
|
||||
class: "end",
|
||||
link: "/settings/rtp",
|
||||
access: "1_18",
|
||||
icon: <MdVerified size={18} />,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -119,11 +119,18 @@ export const menuData = [
|
||||
{
|
||||
id: "180",
|
||||
label: "setting.nginx.title",
|
||||
class: "end",
|
||||
link: "/settings/nginx",
|
||||
access: "1_18",
|
||||
icon: <MdVerified size={18} />,
|
||||
},
|
||||
{
|
||||
id: "181",
|
||||
label: "nginxManagement.rtpSettingsTitle",
|
||||
class: "end",
|
||||
link: "/settings/rtp",
|
||||
access: "1_18",
|
||||
icon: <MdVerified size={18} />,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -79,7 +79,7 @@
|
||||
"title": "Settings",
|
||||
"about": "About",
|
||||
"certificates": "SSL Certificates",
|
||||
"nginx": { "title": "Nginx Management" },
|
||||
"nginx": { "title": "WebServer Management" },
|
||||
"ami_ari_information": "ARI/AMI ID Information",
|
||||
"feature": "Feature Codes",
|
||||
"backup": "Take Backup / Restore Backup",
|
||||
@@ -125,7 +125,7 @@
|
||||
}
|
||||
},
|
||||
"nginxManagement": {
|
||||
"title": "Nginx Management",
|
||||
"title": "WebServer Management",
|
||||
"baseTitle": "Protected base configuration",
|
||||
"webrtc": "WebRTC proxy",
|
||||
"webrtcHelp": "Choose how browser signaling reaches Asterisk. RTP/DTLS media still connects directly to Asterisk and needs its UDP ports reachable.",
|
||||
@@ -147,6 +147,43 @@
|
||||
"dtlsFullchain": "DTLS certificate",
|
||||
"dtlsPrivateKey": "DTLS private key",
|
||||
"dtlsRequired": "Paste the DTLS certificate and matching private key.",
|
||||
"rtpSettingsTitle": "RTP Settings",
|
||||
"saveRtp": "Save RTP settings",
|
||||
"rtpSuccess": "RTP, ICE, and TURN settings applied successfully.",
|
||||
"rtpRange": "Asterisk UDP RTP port range",
|
||||
"rtpStart": "RTP start port",
|
||||
"rtpEnd": "RTP end port",
|
||||
"rtpHelp": "Open this UDP range in the server firewall. The settings apply to Asterisk RTP.",
|
||||
"stunHost": "Asterisk STUN hostname or IP (optional)",
|
||||
"stunPort": "Asterisk STUN port",
|
||||
"clientStunHost": "Browser client STUN hostname or IP (optional)",
|
||||
"clientStunPort": "Browser client STUN port",
|
||||
"clientStunHelp": "This STUN server is sent to WebRTC clients in iceServers. It is separate from Asterisk's RTP STUN setting above.",
|
||||
"iceHostCandidates": "Static ICE address mappings (one per line)",
|
||||
"iceHostCandidatesHelp": "Use local IP => public IP for a server behind one-to-one NAT. Leave STUN empty when mappings are set.",
|
||||
"includeLocalIceCandidates": "Advertise both local and public ICE addresses",
|
||||
"turnTitle": "TURN relay (coturn) client settings",
|
||||
"turnEnabled": "Use TURN for browser clients",
|
||||
"turnHelp": "These settings generate time-limited TURN credentials for SIP user QR codes. Configure coturn separately with the same shared secret, realm, ports, relay range, and TLS files.",
|
||||
"turnHost": "TURN hostname or IP",
|
||||
"turnRealm": "TURN realm",
|
||||
"turnCredentialTtl": "Credential lifetime (seconds)",
|
||||
"turnUdpPort": "TURN UDP/TCP port",
|
||||
"turnTlsPort": "TURN over TLS port",
|
||||
"turnRelayStart": "Relay range start",
|
||||
"turnRelayEnd": "Relay range end",
|
||||
"turnUdp": "UDP",
|
||||
"turnTcp": "TCP",
|
||||
"turnTls": "TLS (turns)",
|
||||
"turnInternalIp": "Coturn Internal IP (optional)",
|
||||
"turnExternalIp": "Coturn Public IP (optional)",
|
||||
"turnTlsCertPath": "coturn TLS certificate path",
|
||||
"turnTlsKeyPath": "coturn TLS private key path",
|
||||
"turnSharedSecret": "Coturn Shared Secret",
|
||||
"turnSecretKeep": "Leave blank to keep the saved secret",
|
||||
"turnSecretConfigured": "A secret is saved and will not be returned to the browser. Leave blank to keep it or enter a new secret.",
|
||||
"turnSecretRequired": "Set the same secret on coturn. Use at least 32 characters.",
|
||||
"turnExternalNotice": "This page does not install or change coturn. Apply matching use-auth-secret/static-auth-secret, realm, listening ports, relay range, NAT mapping, and certificate paths on the TURN server.",
|
||||
"hostSsl": "Host SSL",
|
||||
"serverName": "Server name (server_name)",
|
||||
"httpPort": "HTTP port",
|
||||
@@ -288,11 +325,9 @@
|
||||
"qr_show": "Show SIP user QR code",
|
||||
"qr_title": "SIP user QR code",
|
||||
"qr_settings_title": "QR settings",
|
||||
"qr_settings_help": "Enter the SIP server or hostname and TURN settings. Port and WebRTC are read from each user's SIP profile.",
|
||||
"qr_settings_help": "Enter the SIP server or hostname for non-WebRTC accounts. WebRTC signaling and TURN are taken from central settings.",
|
||||
"qr_server_ip": "SIP Server or Hostname",
|
||||
"qr_turn_server": "TURN server",
|
||||
"qr_turn_user": "TURN user",
|
||||
"qr_turn_password": "TURN password",
|
||||
"qr_turn_central": "WebRTC QR codes use the central signaling/TURN configuration. TURN credentials are generated for this SIP user and expire automatically.",
|
||||
"qr_ip_required": "Enter the SIP server or hostname",
|
||||
"qr_profile_missing": "No SIP profile is assigned to this user",
|
||||
"qr_profile_port_missing": "No port was found in the SIP profile's transport.bind setting",
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
"title": "تنظیمات",
|
||||
"about": "دربارهٔ سیستم",
|
||||
"certificates": "گواهینامههای SSL",
|
||||
"nginx": { "title": "مدیریت Nginx" },
|
||||
"nginx": { "title": "مدیریت وبسرور" },
|
||||
"advance": "تنظیمات بیشتر",
|
||||
"ha": "دسترس بودن بالا (HA)",
|
||||
"personalize": "شخصی سازی",
|
||||
@@ -130,7 +130,7 @@
|
||||
}
|
||||
},
|
||||
"nginxManagement": {
|
||||
"title": "مدیریت Nginx",
|
||||
"title": "مدیریت وبسرور",
|
||||
"baseTitle": "تنظیمات اصلی و قفلشده",
|
||||
"webrtc": "پروکسی WebRTC",
|
||||
"webrtcHelp": "روش اتصال سیگنالدهی مرورگر به Asterisk را انتخاب کنید. صدای RTP/DTLS همچنان مستقیماً به Asterisk میرسد و پورتهای UDP آن باید در دسترس باشند.",
|
||||
@@ -152,6 +152,43 @@
|
||||
"dtlsFullchain": "گواهی DTLS",
|
||||
"dtlsPrivateKey": "کلید خصوصی DTLS",
|
||||
"dtlsRequired": "گواهی DTLS و کلید خصوصی متناظر را وارد کنید.",
|
||||
"rtpSettingsTitle": "RTP Settings",
|
||||
"saveRtp": "ذخیره تنظیمات RTP",
|
||||
"rtpSuccess": "تنظیمات RTP، ICE و TURN با موفقیت اعمال شد.",
|
||||
"rtpRange": "بازه پورت UDP رسانهٔ RTP در Asterisk",
|
||||
"rtpStart": "پورت آغاز RTP",
|
||||
"rtpEnd": "پورت پایان RTP",
|
||||
"rtpHelp": "این بازهٔ UDP را در فایروال سرور باز کنید. تنظیمات روی RTP در Asterisk اعمال میشود.",
|
||||
"stunHost": "نام میزبان یا IP سرور STUN در Asterisk (اختیاری)",
|
||||
"stunPort": "پورت STUN در Asterisk",
|
||||
"clientStunHost": "نام میزبان یا IP سرور STUN برای مرورگر (اختیاری)",
|
||||
"clientStunPort": "پورت STUN برای مرورگر",
|
||||
"clientStunHelp": "این STUN در iceServers به کلاینت WebRTC فرستاده میشود و از STUN مربوط به RTP در Asterisk جداست.",
|
||||
"iceHostCandidates": "نگاشت ثابت نشانی ICE (هر خط یک مورد)",
|
||||
"iceHostCandidatesHelp": "برای سرور پشت NAT یکبهیک، local IP => public IP بنویسید. اگر نگاشت وارد شده، STUN را خالی بگذارید.",
|
||||
"includeLocalIceCandidates": "ارسال همزمان نشانی محلی و عمومی ICE",
|
||||
"turnTitle": "تنظیمات TURN برای کلاینتها (coturn)",
|
||||
"turnEnabled": "استفاده از TURN برای کلاینتهای مرورگر",
|
||||
"turnHelp": "این مقادیر برای QR کاربران SIP اعتبار موقت TURN میسازند. coturn جداگانه و با secret، realm، پورتها، بازهٔ relay و فایلهای TLS یکسان تنظیم میشود.",
|
||||
"turnHost": "نام میزبان یا IP سرور TURN",
|
||||
"turnRealm": "قلمرو (realm) در TURN",
|
||||
"turnCredentialTtl": "مدت اعتبار رمز (ثانیه)",
|
||||
"turnUdpPort": "پورت TURN روی UDP/TCP",
|
||||
"turnTlsPort": "پورت TURN روی TLS",
|
||||
"turnRelayStart": "ابتدای بازهٔ Relay",
|
||||
"turnRelayEnd": "انتهای بازهٔ Relay",
|
||||
"turnUdp": "UDP",
|
||||
"turnTcp": "TCP",
|
||||
"turnTls": "TLS (turns)",
|
||||
"turnInternalIp": "Coturn Internal IP (optional)",
|
||||
"turnExternalIp": "Coturn Public IP (optional)",
|
||||
"turnTlsCertPath": "مسیر گواهی TLS در coturn",
|
||||
"turnTlsKeyPath": "مسیر کلید خصوصی TLS در coturn",
|
||||
"turnSharedSecret": "Coturn Shared Secret",
|
||||
"turnSecretKeep": "برای نگهداشتن رمز ذخیرهشده خالی بگذارید",
|
||||
"turnSecretConfigured": "رمز ذخیره شده و به مرورگر برگردانده نمیشود. برای حفظ آن خالی بگذارید یا رمز جدید وارد کنید.",
|
||||
"turnSecretRequired": "همین رمز را در coturn هم تنظیم کنید؛ حداقل ۳۲ نویسه.",
|
||||
"turnExternalNotice": "این صفحه coturn را نصب یا تغییر نمیدهد. use-auth-secret و static-auth-secret، realm، پورتها، بازهٔ relay، نگاشت NAT و مسیر گواهی را در سرور TURN همسان تنظیم کنید.",
|
||||
"hostSsl": "SSL میزبان",
|
||||
"serverName": "نام سرور (server_name)",
|
||||
"httpPort": "پورت HTTP",
|
||||
@@ -279,11 +316,9 @@
|
||||
"qr_show": "نمایش QR داخلی",
|
||||
"qr_title": "QR داخلی",
|
||||
"qr_settings_title": "تنظیمات QR",
|
||||
"qr_settings_help": "سرور SIP یا نام میزبان و تنظیمات TURN را وارد کنید؛ پورت و WebRTC از پروفایل هر داخلی خوانده میشود.",
|
||||
"qr_settings_help": "برای داخلیهای غیر WebRTC، سرور SIP یا نام میزبان را وارد کنید. نشانی سیگنالدهی WebRTC و TURN از تنظیمات مرکزی گرفته میشود.",
|
||||
"qr_server_ip": "سرور SIP یا نام میزبان",
|
||||
"qr_turn_server": "سرور TURN",
|
||||
"qr_turn_user": "کاربر TURN",
|
||||
"qr_turn_password": "رمز TURN",
|
||||
"qr_turn_central": "QR کاربران WebRTC از تنظیمات مرکزی سیگنالدهی و TURN استفاده میکند. اعتبار TURN برای همان داخلی ساخته میشود و خودکار منقضی میشود.",
|
||||
"qr_ip_required": "سرور SIP یا نام میزبان را وارد کنید",
|
||||
"qr_profile_missing": "برای این داخلی پروفایل SIP مشخص نشده است",
|
||||
"qr_profile_port_missing": "پورت در تنظیمات transport.bind پروفایل SIP پیدا نشد",
|
||||
|
||||
@@ -78,6 +78,7 @@ const Certificates = React.lazy(() => import("../../pages/settings/certificate/C
|
||||
const QueueReports = React.lazy(() => import("../../pages/monitoring/queue-reports/QueueReports"));
|
||||
const About = React.lazy(() => import("../../pages/settings/about/About"));
|
||||
const NginxManagement = React.lazy(() => import("../../pages/settings/nginx/NginxManagement"));
|
||||
const RTPSettings = React.lazy(() => import("../../pages/settings/nginx/RTPSettings"));
|
||||
|
||||
export interface IAppRouteNode {
|
||||
path: string;
|
||||
@@ -98,6 +99,7 @@ export const AppRoutes = [
|
||||
{ path: "/settings/cti-settings", element: <CtiSettings /> },
|
||||
{ path: "/settings/about", element: <About /> },
|
||||
{ path: "/settings/nginx", element: <NginxManagement /> },
|
||||
{ path: "/settings/rtp", element: <RTPSettings /> },
|
||||
{ path: "/settings/system-sip-settings", element: <SystemSipSettings /> },
|
||||
{ path: "/sip-profiles/index", element: <SipProfiles /> },
|
||||
{ path: "/sip-profiles/edit/:id", element: <SipProfileForm /> },
|
||||
|
||||
@@ -29,8 +29,9 @@ interface WebRtcConfiguration {
|
||||
const API = "/nginx-management";
|
||||
const ACCESS = AccessCodeSettings.Nginx;
|
||||
const defaultHost: HostSettings = { serverName: "_", httpPort: 80, httpsPort: 443, redirectHttpToHttps: true };
|
||||
const defaultWebRtc: WebRtcConfiguration = { mode: "proxy", dtlsMode: "auto", serverName: "_", port: 443 };
|
||||
|
||||
const defaultWebRtc: WebRtcConfiguration = {
|
||||
mode: "proxy", dtlsMode: "auto", serverName: "_", port: 443,
|
||||
};
|
||||
const NginxManagement: React.FC = () => {
|
||||
const { t } = useTranslation();
|
||||
const [loading, setLoading] = useState(true);
|
||||
@@ -56,7 +57,10 @@ const NginxManagement: React.FC = () => {
|
||||
setHost({ ...defaultHost, ...(current.host ?? {}) });
|
||||
setSavedHttpsPort(Number(current.host?.httpsPort ?? 443));
|
||||
setSavedHttpPort(Number(current.host?.httpPort ?? 80));
|
||||
setWebRtc({ ...defaultWebRtc, ...(current.webrtc ?? {}) });
|
||||
setWebRtc({
|
||||
...defaultWebRtc,
|
||||
...(current.webrtc ?? {}),
|
||||
});
|
||||
setFullchain(current.sslContents?.fullchain ?? "");
|
||||
setPrivateKey(current.sslContents?.privateKey ?? "");
|
||||
}
|
||||
@@ -111,7 +115,6 @@ const NginxManagement: React.FC = () => {
|
||||
}, ACCESS, RequestActions.Update);
|
||||
setBusy(false);
|
||||
if (response && !response.Error) {
|
||||
setWebRtc({ ...webRtc, ...(response.data?.result?.webrtc ?? {}) });
|
||||
setDtlsFullchain("");
|
||||
setDtlsPrivateKey("");
|
||||
toast.success(t("nginxManagement.webrtcSuccess"));
|
||||
|
||||
411
cti_app/src/components/pages/settings/nginx/RTPSettings.tsx
Normal file
411
cti_app/src/components/pages/settings/nginx/RTPSettings.tsx
Normal file
@@ -0,0 +1,411 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { Alert, Button, Card, Col, Form, Row, Spinner } from "react-bootstrap";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import toast from "react-hot-toast";
|
||||
import RequestService from "../../../services/RequestService";
|
||||
import { AccessCodeSettings, RequestActions } from "../../../application-components/user/Permissions/AccessCodes";
|
||||
|
||||
interface RtpConfiguration {
|
||||
rtpStart: number;
|
||||
rtpEnd: number;
|
||||
stunHost: string;
|
||||
stunPort: number;
|
||||
clientStunHost: string;
|
||||
clientStunPort: number;
|
||||
iceHostCandidates: string;
|
||||
includeLocalIceCandidates: boolean;
|
||||
turnEnabled: boolean;
|
||||
turnHost: string;
|
||||
turnPort: number;
|
||||
turnTlsPort: number;
|
||||
turnUdpEnabled: boolean;
|
||||
turnTcpEnabled: boolean;
|
||||
turnTlsEnabled: boolean;
|
||||
turnRelayStart: number;
|
||||
turnRelayEnd: number;
|
||||
turnRealm: string;
|
||||
turnInternalIp: string;
|
||||
turnExternalIp: string;
|
||||
turnTlsCertPath: string;
|
||||
turnTlsPrivateKeyPath: string;
|
||||
turnCredentialTtlSeconds: number;
|
||||
turnSecretConfigured: boolean;
|
||||
}
|
||||
|
||||
const API = "/nginx-management";
|
||||
const ACCESS = AccessCodeSettings.Nginx;
|
||||
const defaultRtp: RtpConfiguration = {
|
||||
rtpStart: 10000,
|
||||
rtpEnd: 20000,
|
||||
stunHost: "",
|
||||
stunPort: 3478,
|
||||
clientStunHost: "",
|
||||
clientStunPort: 3478,
|
||||
iceHostCandidates: "",
|
||||
includeLocalIceCandidates: false,
|
||||
turnEnabled: false,
|
||||
turnHost: "",
|
||||
turnPort: 3478,
|
||||
turnTlsPort: 5349,
|
||||
turnUdpEnabled: true,
|
||||
turnTcpEnabled: false,
|
||||
turnTlsEnabled: false,
|
||||
turnRelayStart: 49152,
|
||||
turnRelayEnd: 65535,
|
||||
turnRealm: "",
|
||||
turnInternalIp: "",
|
||||
turnExternalIp: "",
|
||||
turnTlsCertPath: "",
|
||||
turnTlsPrivateKeyPath: "",
|
||||
turnCredentialTtlSeconds: 3600,
|
||||
turnSecretConfigured: false,
|
||||
};
|
||||
|
||||
const RTPSettings: React.FC = () => {
|
||||
const { t } = useTranslation();
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [rtp, setRtp] = useState<RtpConfiguration>(defaultRtp);
|
||||
const [turnSharedSecret, setTurnSharedSecret] = useState("");
|
||||
|
||||
const load = async () => {
|
||||
setLoading(true);
|
||||
const response = await RequestService.GetRequest(API, ACCESS, RequestActions.Read);
|
||||
if (response && !response.Error && response.data?.result?.rtp) {
|
||||
const current = response.data.result.rtp;
|
||||
setRtp({
|
||||
...defaultRtp,
|
||||
...current,
|
||||
iceHostCandidates: Array.isArray(current.iceHostCandidates)
|
||||
? current.iceHostCandidates.join("\n")
|
||||
: current.iceHostCandidates ?? "",
|
||||
});
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
useEffect(() => { void load(); }, []);
|
||||
|
||||
const save = async (event: React.FormEvent) => {
|
||||
event.preventDefault();
|
||||
setBusy(true);
|
||||
const response = await RequestService.PostRequest(`${API}/rtp`, {
|
||||
rtpStart: Number(rtp.rtpStart),
|
||||
rtpEnd: Number(rtp.rtpEnd),
|
||||
stunHost: rtp.stunHost,
|
||||
stunPort: Number(rtp.stunPort),
|
||||
clientStunHost: rtp.clientStunHost,
|
||||
clientStunPort: Number(rtp.clientStunPort),
|
||||
iceHostCandidates: rtp.iceHostCandidates,
|
||||
includeLocalIceCandidates: rtp.includeLocalIceCandidates,
|
||||
turnEnabled: rtp.turnEnabled,
|
||||
turnHost: rtp.turnHost,
|
||||
turnPort: Number(rtp.turnPort),
|
||||
turnTlsPort: Number(rtp.turnTlsPort),
|
||||
turnUdpEnabled: rtp.turnUdpEnabled,
|
||||
turnTcpEnabled: rtp.turnTcpEnabled,
|
||||
turnTlsEnabled: rtp.turnTlsEnabled,
|
||||
turnRelayStart: Number(rtp.turnRelayStart),
|
||||
turnRelayEnd: Number(rtp.turnRelayEnd),
|
||||
turnRealm: rtp.turnRealm,
|
||||
turnInternalIp: rtp.turnInternalIp,
|
||||
turnExternalIp: rtp.turnExternalIp,
|
||||
turnTlsCertPath: rtp.turnTlsCertPath,
|
||||
turnTlsPrivateKeyPath: rtp.turnTlsPrivateKeyPath,
|
||||
turnCredentialTtlSeconds: Number(rtp.turnCredentialTtlSeconds),
|
||||
turnSharedSecret,
|
||||
}, ACCESS, RequestActions.Update);
|
||||
setBusy(false);
|
||||
if (response && !response.Error) {
|
||||
setTurnSharedSecret("");
|
||||
toast.success(t("nginxManagement.rtpSuccess"));
|
||||
await load();
|
||||
}
|
||||
};
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<Col md={{ span: 8, offset: 2 }} className="mt-4 text-center py-5">
|
||||
<Spinner animation="border" />
|
||||
</Col>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Col md={{ span: 8, offset: 2 }} className="mt-4 pb-5">
|
||||
<h3 className="mb-4">{t("nginxManagement.rtpSettingsTitle")}</h3>
|
||||
<Card className="shadow-sm">
|
||||
<Card.Header className="queue-header">{t("nginxManagement.rtpSettingsTitle")}</Card.Header>
|
||||
<Card.Body>
|
||||
<Form onSubmit={save}>
|
||||
<Form.Group className="mb-3">
|
||||
<Form.Label>{t("nginxManagement.rtpRange")}</Form.Label>
|
||||
<Row>
|
||||
<Col>
|
||||
<Form.Control
|
||||
aria-label={t("nginxManagement.rtpStart")}
|
||||
type="number"
|
||||
min={1024}
|
||||
max={65535}
|
||||
required
|
||||
value={rtp.rtpStart}
|
||||
onChange={(e) => setRtp({ ...rtp, rtpStart: Number(e.target.value) })}
|
||||
/>
|
||||
</Col>
|
||||
<Col>
|
||||
<Form.Control
|
||||
aria-label={t("nginxManagement.rtpEnd")}
|
||||
type="number"
|
||||
min={1024}
|
||||
max={65535}
|
||||
required
|
||||
value={rtp.rtpEnd}
|
||||
onChange={(e) => setRtp({ ...rtp, rtpEnd: Number(e.target.value) })}
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
<Form.Text>{t("nginxManagement.rtpHelp")}</Form.Text>
|
||||
</Form.Group>
|
||||
<Row>
|
||||
<Col sm={8}>
|
||||
<Form.Group className="mb-3">
|
||||
<Form.Label>{t("nginxManagement.stunHost")}</Form.Label>
|
||||
<Form.Control
|
||||
value={rtp.stunHost}
|
||||
onChange={(e) => setRtp({ ...rtp, stunHost: e.target.value })}
|
||||
placeholder="stun.example.com"
|
||||
autoComplete="off"
|
||||
/>
|
||||
</Form.Group>
|
||||
</Col>
|
||||
<Col sm={4}>
|
||||
<Form.Group className="mb-3">
|
||||
<Form.Label>{t("nginxManagement.stunPort")}</Form.Label>
|
||||
<Form.Control
|
||||
type="number"
|
||||
min={1}
|
||||
max={65535}
|
||||
required
|
||||
value={rtp.stunPort}
|
||||
onChange={(e) => setRtp({ ...rtp, stunPort: Number(e.target.value) })}
|
||||
/>
|
||||
</Form.Group>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row>
|
||||
<Col sm={8}>
|
||||
<Form.Group className="mb-3">
|
||||
<Form.Label>{t("nginxManagement.clientStunHost")}</Form.Label>
|
||||
<Form.Control
|
||||
value={rtp.clientStunHost}
|
||||
onChange={(e) => setRtp({ ...rtp, clientStunHost: e.target.value })}
|
||||
placeholder="stun.example.com"
|
||||
autoComplete="off"
|
||||
/>
|
||||
</Form.Group>
|
||||
</Col>
|
||||
<Col sm={4}>
|
||||
<Form.Group className="mb-3">
|
||||
<Form.Label>{t("nginxManagement.clientStunPort")}</Form.Label>
|
||||
<Form.Control
|
||||
type="number"
|
||||
min={1}
|
||||
max={65535}
|
||||
required
|
||||
value={rtp.clientStunPort}
|
||||
onChange={(e) => setRtp({ ...rtp, clientStunPort: Number(e.target.value) })}
|
||||
/>
|
||||
</Form.Group>
|
||||
</Col>
|
||||
</Row>
|
||||
<Form.Text className="d-block mb-3">{t("nginxManagement.clientStunHelp")}</Form.Text>
|
||||
<Form.Group className="mb-3">
|
||||
<Form.Label>{t("nginxManagement.iceHostCandidates")}</Form.Label>
|
||||
<Form.Control
|
||||
as="textarea"
|
||||
rows={3}
|
||||
value={rtp.iceHostCandidates}
|
||||
onChange={(e) => setRtp({ ...rtp, iceHostCandidates: e.target.value })}
|
||||
placeholder="192.168.1.10 => 203.0.113.10"
|
||||
autoComplete="off"
|
||||
spellCheck={false}
|
||||
/>
|
||||
<Form.Text>{t("nginxManagement.iceHostCandidatesHelp")}</Form.Text>
|
||||
</Form.Group>
|
||||
<Form.Check
|
||||
type="switch"
|
||||
className="mb-3"
|
||||
label={t("nginxManagement.includeLocalIceCandidates")}
|
||||
checked={rtp.includeLocalIceCandidates}
|
||||
onChange={(e) => setRtp({ ...rtp, includeLocalIceCandidates: e.target.checked })}
|
||||
/>
|
||||
<div className="border rounded p-3 mt-4">
|
||||
<div className="d-flex justify-content-between align-items-center mb-2">
|
||||
<h5 className="mb-0">{t("nginxManagement.turnTitle")}</h5>
|
||||
<Form.Check
|
||||
type="switch"
|
||||
label={t("nginxManagement.turnEnabled")}
|
||||
checked={rtp.turnEnabled}
|
||||
onChange={(e) => setRtp({ ...rtp, turnEnabled: e.target.checked })}
|
||||
/>
|
||||
</div>
|
||||
<p className="text-muted small">{t("nginxManagement.turnHelp")}</p>
|
||||
{rtp.turnEnabled && (
|
||||
<>
|
||||
<Row>
|
||||
<Col md={6}>
|
||||
<Form.Group className="mb-3">
|
||||
<Form.Label>{t("nginxManagement.turnHost")}</Form.Label>
|
||||
<Form.Control
|
||||
required
|
||||
value={rtp.turnHost}
|
||||
onChange={(e) => setRtp({ ...rtp, turnHost: e.target.value })}
|
||||
placeholder="turn.example.com"
|
||||
autoComplete="off"
|
||||
/>
|
||||
</Form.Group>
|
||||
</Col>
|
||||
<Col md={3}>
|
||||
<Form.Group className="mb-3">
|
||||
<Form.Label>{t("nginxManagement.turnRealm")}</Form.Label>
|
||||
<Form.Control
|
||||
value={rtp.turnRealm}
|
||||
onChange={(e) => setRtp({ ...rtp, turnRealm: e.target.value })}
|
||||
autoComplete="off"
|
||||
/>
|
||||
</Form.Group>
|
||||
</Col>
|
||||
<Col md={3}>
|
||||
<Form.Group className="mb-3">
|
||||
<Form.Label>{t("nginxManagement.turnCredentialTtl")}</Form.Label>
|
||||
<Form.Control
|
||||
type="number"
|
||||
min={60}
|
||||
max={86400}
|
||||
required
|
||||
value={rtp.turnCredentialTtlSeconds}
|
||||
onChange={(e) => setRtp({ ...rtp, turnCredentialTtlSeconds: Number(e.target.value) })}
|
||||
/>
|
||||
</Form.Group>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row>
|
||||
<Col md={3}>
|
||||
<Form.Group className="mb-3">
|
||||
<Form.Label>{t("nginxManagement.turnUdpPort")}</Form.Label>
|
||||
<Form.Control type="number" min={1} max={65535} required value={rtp.turnPort}
|
||||
onChange={(e) => setRtp({ ...rtp, turnPort: Number(e.target.value) })} />
|
||||
</Form.Group>
|
||||
</Col>
|
||||
<Col md={3}>
|
||||
<Form.Group className="mb-3">
|
||||
<Form.Label>{t("nginxManagement.turnTlsPort")}</Form.Label>
|
||||
<Form.Control type="number" min={1} max={65535} required value={rtp.turnTlsPort}
|
||||
onChange={(e) => setRtp({ ...rtp, turnTlsPort: Number(e.target.value) })} />
|
||||
</Form.Group>
|
||||
</Col>
|
||||
<Col md={3}>
|
||||
<Form.Group className="mb-3">
|
||||
<Form.Label>{t("nginxManagement.turnRelayStart")}</Form.Label>
|
||||
<Form.Control type="number" min={1024} max={65535} required value={rtp.turnRelayStart}
|
||||
onChange={(e) => setRtp({ ...rtp, turnRelayStart: Number(e.target.value) })} />
|
||||
</Form.Group>
|
||||
</Col>
|
||||
<Col md={3}>
|
||||
<Form.Group className="mb-3">
|
||||
<Form.Label>{t("nginxManagement.turnRelayEnd")}</Form.Label>
|
||||
<Form.Control type="number" min={1024} max={65535} required value={rtp.turnRelayEnd}
|
||||
onChange={(e) => setRtp({ ...rtp, turnRelayEnd: Number(e.target.value) })} />
|
||||
</Form.Group>
|
||||
</Col>
|
||||
</Row>
|
||||
<div className="d-flex flex-wrap gap-4 mb-3">
|
||||
<Form.Check
|
||||
type="checkbox"
|
||||
label={t("nginxManagement.turnUdp")}
|
||||
checked={rtp.turnUdpEnabled}
|
||||
onChange={(e) => setRtp({ ...rtp, turnUdpEnabled: e.target.checked })}
|
||||
/>
|
||||
<Form.Check
|
||||
type="checkbox"
|
||||
label={t("nginxManagement.turnTcp")}
|
||||
checked={rtp.turnTcpEnabled}
|
||||
onChange={(e) => setRtp({ ...rtp, turnTcpEnabled: e.target.checked })}
|
||||
/>
|
||||
<Form.Check
|
||||
type="checkbox"
|
||||
label={t("nginxManagement.turnTls")}
|
||||
checked={rtp.turnTlsEnabled}
|
||||
onChange={(e) => setRtp({ ...rtp, turnTlsEnabled: e.target.checked })}
|
||||
/>
|
||||
</div>
|
||||
<Row>
|
||||
<Col md={6}>
|
||||
<Form.Group className="mb-3">
|
||||
<Form.Label>{t("nginxManagement.turnInternalIp")}</Form.Label>
|
||||
<Form.Control value={rtp.turnInternalIp}
|
||||
onChange={(e) => setRtp({ ...rtp, turnInternalIp: e.target.value })} autoComplete="off" />
|
||||
</Form.Group>
|
||||
</Col>
|
||||
<Col md={6}>
|
||||
<Form.Group className="mb-3">
|
||||
<Form.Label>{t("nginxManagement.turnExternalIp")}</Form.Label>
|
||||
<Form.Control value={rtp.turnExternalIp}
|
||||
onChange={(e) => setRtp({ ...rtp, turnExternalIp: e.target.value })} autoComplete="off" />
|
||||
</Form.Group>
|
||||
</Col>
|
||||
</Row>
|
||||
{rtp.turnTlsEnabled && (
|
||||
<Row>
|
||||
<Col md={6}>
|
||||
<Form.Group className="mb-3">
|
||||
<Form.Label>{t("nginxManagement.turnTlsCertPath")}</Form.Label>
|
||||
<Form.Control required value={rtp.turnTlsCertPath}
|
||||
onChange={(e) => setRtp({ ...rtp, turnTlsCertPath: e.target.value })} autoComplete="off" />
|
||||
</Form.Group>
|
||||
</Col>
|
||||
<Col md={6}>
|
||||
<Form.Group className="mb-3">
|
||||
<Form.Label>{t("nginxManagement.turnTlsKeyPath")}</Form.Label>
|
||||
<Form.Control required value={rtp.turnTlsPrivateKeyPath}
|
||||
onChange={(e) => setRtp({ ...rtp, turnTlsPrivateKeyPath: e.target.value })} autoComplete="off" />
|
||||
</Form.Group>
|
||||
</Col>
|
||||
</Row>
|
||||
)}
|
||||
<Form.Group className="mb-3">
|
||||
<Form.Label>{t("nginxManagement.turnSharedSecret")}</Form.Label>
|
||||
<Form.Control
|
||||
id="turn-shared-secret"
|
||||
type="password"
|
||||
value={turnSharedSecret}
|
||||
onChange={(e) => setTurnSharedSecret(e.target.value)}
|
||||
minLength={rtp.turnSecretConfigured ? undefined : 32}
|
||||
maxLength={256}
|
||||
required={!rtp.turnSecretConfigured}
|
||||
autoComplete="new-password"
|
||||
placeholder={rtp.turnSecretConfigured ? t("nginxManagement.turnSecretKeep") : ""}
|
||||
/>
|
||||
<Form.Text>
|
||||
{rtp.turnSecretConfigured
|
||||
? t("nginxManagement.turnSecretConfigured")
|
||||
: t("nginxManagement.turnSecretRequired")}
|
||||
</Form.Text>
|
||||
</Form.Group>
|
||||
<Alert variant="warning" className="small mb-0">{t("nginxManagement.turnExternalNotice")}</Alert>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<div className="d-flex justify-content-end mt-3 pt-2 pe-2 pb-1">
|
||||
<Button type="submit" variant="primary" disabled={busy}>
|
||||
{busy ? <Spinner size="sm" className="me-2" /> : null}{t("nginxManagement.saveRtp")}
|
||||
</Button>
|
||||
</div>
|
||||
</Form>
|
||||
</Card.Body>
|
||||
</Card>
|
||||
</Col>
|
||||
);
|
||||
};
|
||||
|
||||
export default RTPSettings;
|
||||
@@ -45,7 +45,7 @@ const SipParams = () => {
|
||||
const [loading, setLoading] = useState(true);
|
||||
//url params comes here name and id
|
||||
const profileParam = useParams();
|
||||
const [editingRow, setEditingRow] = useState(null);
|
||||
const [editingRow, setEditingRow] = useState<string | null>(null);
|
||||
//grid data comes here
|
||||
const [rowData, setRowData] = useState<any>([]);
|
||||
//skeleton loading state for reRendering Form
|
||||
@@ -74,6 +74,9 @@ const SipParams = () => {
|
||||
//create and update data from store here
|
||||
const [state, setState] = useState<any>(initialState);
|
||||
|
||||
const getRowKey = (row: Pick<InputItem, "ParamType" | "parameter">) =>
|
||||
JSON.stringify([row.ParamType, row.parameter]);
|
||||
|
||||
const navigate = useNavigate();
|
||||
//grid Cols
|
||||
const columns = [
|
||||
@@ -425,6 +428,7 @@ const SipParams = () => {
|
||||
|
||||
//Delete params from grid
|
||||
function DeleteRow(params: any) {
|
||||
const rowKey = getRowKey(params.data);
|
||||
return (
|
||||
<>
|
||||
<FiEdit
|
||||
@@ -432,9 +436,9 @@ const SipParams = () => {
|
||||
className="mx-2 edit-icon"
|
||||
// Only call handleEditRow if the row is not currently being edited
|
||||
onClick={() => {
|
||||
if (editingRow !== params.data.parameter) {
|
||||
if (editingRow !== rowKey) {
|
||||
handleEditRow(params.data);
|
||||
setEditingRow(params.data.parameter);
|
||||
setEditingRow(rowKey);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
@@ -442,17 +446,23 @@ const SipParams = () => {
|
||||
style={{ paddingLeft: "8px" }}
|
||||
className="delete-icon"
|
||||
onClick={() => {
|
||||
const rowIndexInOriginalData = rowData.findIndex(
|
||||
(row: any) => row.parameter === params.data.parameter
|
||||
setRowData((currentRows: InputItem[]) =>
|
||||
currentRows.filter((row) => getRowKey(row) !== rowKey)
|
||||
);
|
||||
if (rowIndexInOriginalData !== -1) {
|
||||
const updatedRowData = [...rowData];
|
||||
updatedRowData.splice(rowIndexInOriginalData, 1);
|
||||
setRowData(updatedRowData);
|
||||
// Check if the row being deleted is the one being edited, and reset the editing state
|
||||
if (editingRow === rowIndexInOriginalData) {
|
||||
setSelected((currentRows: InputItem[]) =>
|
||||
currentRows.filter((row) => getRowKey(row) !== rowKey)
|
||||
);
|
||||
setState((currentState: any) => {
|
||||
const updatedType = { ...currentState[params.data.ParamType] };
|
||||
delete updatedType[params.data.parameter];
|
||||
return { ...currentState, [params.data.ParamType]: updatedType };
|
||||
});
|
||||
if (editingRow === rowKey) {
|
||||
setEditingRow(null);
|
||||
}
|
||||
setMode(false);
|
||||
setSelectedParamType(null);
|
||||
setSelectedParam([]);
|
||||
setRenderedFormControls([]);
|
||||
}
|
||||
}}
|
||||
size={28}
|
||||
@@ -570,6 +580,7 @@ const SipParams = () => {
|
||||
|
||||
if (mode) {
|
||||
setMode(false);
|
||||
setEditingRow(null);
|
||||
}
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -660,6 +671,7 @@ const SipParams = () => {
|
||||
onChange={(e: any) => {
|
||||
if (mode) {
|
||||
setMode(false);
|
||||
setEditingRow(null);
|
||||
}
|
||||
handleParamChange(e);
|
||||
}}
|
||||
|
||||
@@ -45,9 +45,6 @@ import QRCode from "qrcode";
|
||||
|
||||
type QrSettings = {
|
||||
ip: string;
|
||||
turnServer: string;
|
||||
turnUser: string;
|
||||
turnPassword: string;
|
||||
};
|
||||
|
||||
const SipUsers = () => {
|
||||
@@ -68,15 +65,11 @@ const SipUsers = () => {
|
||||
const [qrSettings, setQrSettings] = useState<QrSettings>(() => {
|
||||
const defaultSettings = {
|
||||
ip: "",
|
||||
turnServer: "",
|
||||
turnUser: "",
|
||||
turnPassword: "",
|
||||
};
|
||||
try {
|
||||
const savedSettings = localStorage.getItem("sipUserQrSettings");
|
||||
return savedSettings
|
||||
? { ...defaultSettings, ...JSON.parse(savedSettings) }
|
||||
: defaultSettings;
|
||||
const parsed = savedSettings ? JSON.parse(savedSettings) : {};
|
||||
return { ip: typeof parsed.ip === "string" ? parsed.ip : defaultSettings.ip };
|
||||
} catch {
|
||||
return defaultSettings;
|
||||
}
|
||||
@@ -99,6 +92,13 @@ const SipUsers = () => {
|
||||
[],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
// Remove legacy TURN secrets that older versions stored in this browser.
|
||||
try {
|
||||
localStorage.setItem("sipUserQrSettings", JSON.stringify({ ip: qrSettings.ip }));
|
||||
} catch { /* QR settings remain usable for this session. */ }
|
||||
}, []);
|
||||
|
||||
const toggleSipSelection = (uid: string | number, checked: boolean) => {
|
||||
const uidStr = String(uid);
|
||||
|
||||
@@ -165,11 +165,6 @@ const SipUsers = () => {
|
||||
};
|
||||
|
||||
const showUserQrCode = async (row: any) => {
|
||||
if (!qrSettings.ip.trim()) {
|
||||
toast.error(t("sipUsers.qr_ip_required"));
|
||||
return;
|
||||
}
|
||||
|
||||
const profileId = row.sipProfile?.id;
|
||||
if (!profileId) {
|
||||
toast.error(t("sipUsers.qr_profile_missing"));
|
||||
@@ -195,22 +190,53 @@ const SipUsers = () => {
|
||||
const details = result.data;
|
||||
const bind = String(details?.transport?.bind || "");
|
||||
const portMatch = bind.match(/:(\d{1,5})\s*$/);
|
||||
const port = portMatch ? Number(portMatch[1]) : NaN;
|
||||
const webrtcValue = String(details?.endpoint?.webrtc || "").toLowerCase();
|
||||
const isWebRtc = ["yes", "true", "1"].includes(webrtcValue);
|
||||
let websocketUrl = "";
|
||||
let turn: any = { urls: [], username: "", credential: "", expiresAt: 0 };
|
||||
let iceServers: any[] = [];
|
||||
let port = portMatch ? Number(portMatch[1]) : NaN;
|
||||
let serverIp = qrSettings.ip.trim();
|
||||
if (isWebRtc) {
|
||||
const settings: any = await RequestService.GetRequest(
|
||||
`/nginx-management/client-settings?username=${encodeURIComponent(String(row.uid || ""))}`,
|
||||
AccessCodeSip.SipUsers,
|
||||
RequestActions.Read,
|
||||
);
|
||||
if (!settings?.hasPermission || settings.Error || !settings.data?.result?.signalingUrl) {
|
||||
toast.error(settings?.hasPermission === false ? t("globals.error_permission") : t("sipUsers.qr_generate_error"));
|
||||
return;
|
||||
}
|
||||
websocketUrl = String(settings.data.result.signalingUrl);
|
||||
turn = settings.data.result.turn ?? turn;
|
||||
iceServers = settings.data.result.iceServers ?? [];
|
||||
const signalingAddress = new URL(websocketUrl);
|
||||
if (!serverIp) serverIp = signalingAddress.hostname;
|
||||
port = signalingAddress.port ? Number(signalingAddress.port) : 443;
|
||||
}
|
||||
if (!serverIp) {
|
||||
toast.error(t("sipUsers.qr_ip_required"));
|
||||
return;
|
||||
}
|
||||
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
||||
toast.error(t("sipUsers.qr_profile_port_missing"));
|
||||
return;
|
||||
}
|
||||
|
||||
const webrtcValue = String(details?.endpoint?.webrtc || "").toLowerCase();
|
||||
const qrPayload = {
|
||||
ip: qrSettings.ip.trim(),
|
||||
ip: serverIp,
|
||||
port,
|
||||
isWebRtc: ["yes", "true", "1"].includes(webrtcValue),
|
||||
isWebRtc,
|
||||
user: String(row.uid || ""),
|
||||
pass: String(row.password || ""),
|
||||
turnServer: qrSettings.turnServer.trim(),
|
||||
turnUser: qrSettings.turnUser.trim(),
|
||||
turnPassword: qrSettings.turnPassword,
|
||||
...(isWebRtc ? {
|
||||
websocketUrl,
|
||||
iceServers,
|
||||
turnServers: turn.urls ?? [],
|
||||
turnServer: turn.urls?.[0] ?? "",
|
||||
turnUser: turn.username ?? "",
|
||||
turnPassword: turn.credential ?? "",
|
||||
turnCredentialExpiresAt: turn.expiresAt ?? 0,
|
||||
} : {}),
|
||||
};
|
||||
const image = await QRCode.toDataURL(JSON.stringify(qrPayload), {
|
||||
width: 300,
|
||||
@@ -229,7 +255,7 @@ const SipUsers = () => {
|
||||
|
||||
const saveQrSettings = () => {
|
||||
try {
|
||||
localStorage.setItem("sipUserQrSettings", JSON.stringify(qrSettings));
|
||||
localStorage.setItem("sipUserQrSettings", JSON.stringify({ ip: qrSettings.ip }));
|
||||
toast.success(t("sipUsers.qr_settings_saved"));
|
||||
setQrSettingsModalOpen(false);
|
||||
} catch {
|
||||
@@ -757,8 +783,9 @@ const SipUsers = () => {
|
||||
>
|
||||
<Form onSubmit={(event) => event.preventDefault()}>
|
||||
<p className="text-muted">{t("sipUsers.qr_settings_help")}</p>
|
||||
<div className="alert alert-info py-2 small">{t("sipUsers.qr_turn_central")}</div>
|
||||
<Row className="g-3">
|
||||
<Col md={6}>
|
||||
<Col md={12}>
|
||||
<Form.Label htmlFor="qr-server-ip">
|
||||
{t("sipUsers.qr_server_ip")}
|
||||
</Form.Label>
|
||||
@@ -775,55 +802,6 @@ const SipUsers = () => {
|
||||
required
|
||||
/>
|
||||
</Col>
|
||||
<Col md={6}>
|
||||
<Form.Label htmlFor="qr-turn-server">
|
||||
{t("sipUsers.qr_turn_server")}
|
||||
</Form.Label>
|
||||
<Form.Control
|
||||
id="qr-turn-server"
|
||||
value={qrSettings.turnServer}
|
||||
onChange={(event) =>
|
||||
setQrSettings((current) => ({
|
||||
...current,
|
||||
turnServer: event.target.value,
|
||||
}))
|
||||
}
|
||||
autoComplete="off"
|
||||
/>
|
||||
</Col>
|
||||
<Col md={6}>
|
||||
<Form.Label htmlFor="qr-turn-user">
|
||||
{t("sipUsers.qr_turn_user")}
|
||||
</Form.Label>
|
||||
<Form.Control
|
||||
id="qr-turn-user"
|
||||
value={qrSettings.turnUser}
|
||||
onChange={(event) =>
|
||||
setQrSettings((current) => ({
|
||||
...current,
|
||||
turnUser: event.target.value,
|
||||
}))
|
||||
}
|
||||
autoComplete="off"
|
||||
/>
|
||||
</Col>
|
||||
<Col md={6}>
|
||||
<Form.Label htmlFor="qr-turn-password">
|
||||
{t("sipUsers.qr_turn_password")}
|
||||
</Form.Label>
|
||||
<Form.Control
|
||||
id="qr-turn-password"
|
||||
type="password"
|
||||
value={qrSettings.turnPassword}
|
||||
onChange={(event) =>
|
||||
setQrSettings((current) => ({
|
||||
...current,
|
||||
turnPassword: event.target.value,
|
||||
}))
|
||||
}
|
||||
autoComplete="new-password"
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
<div className="d-flex justify-content-end gap-2 mt-3">
|
||||
<button
|
||||
|
||||
@@ -307,7 +307,7 @@ def apply_webrtc():
|
||||
" proxy_set_header X-Real-IP $remote_addr;\n"
|
||||
" proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n"
|
||||
" proxy_set_header X-Forwarded-Proto $scheme;\n"
|
||||
" proxy_read_timeout 3600s;\n"
|
||||
" proxy_read_timeout 86400s;\n"
|
||||
"}\n"
|
||||
).encode() if same_site else b""
|
||||
if not same_site:
|
||||
@@ -326,7 +326,7 @@ def apply_webrtc():
|
||||
" proxy_set_header X-Real-IP $remote_addr;\n"
|
||||
" proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n"
|
||||
" proxy_set_header X-Forwarded-Proto $scheme;\n"
|
||||
" proxy_read_timeout 3600s;\n }\n}\n"
|
||||
" proxy_read_timeout 86400s;\n }\n}\n"
|
||||
).encode()
|
||||
|
||||
if mode == "direct":
|
||||
|
||||
@@ -135,10 +135,10 @@ Exec: /usr/bin/date +%A
|
||||
Exec: /usr/bin/date +%T
|
||||
Exec: /usr/bin/date +%F
|
||||
Exec: /usr/bin/timedatectl show | grep Timezone
|
||||
Date-Time: Tuesday 12:09:50 - 2026/10/27 (Asia/Tehran)
|
||||
Date-Time: Tuesday 17:09:01 - 2026/10/27 (Asia/Tehran)
|
||||
HDD:
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
/dev/sda2 233 GB 64 GB 76 GB
|
||||
/dev/sda2 233 GB 58 GB 70 GB
|
||||
App WbSite: http://raymandcti.com/
|
||||
App Footer: Copyright Raymand Communications Naqsh Jahan, Inc. All Rights Reserved
|
||||
App Version: 3.0.0
|
||||
@@ -147,6 +147,72 @@ Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
@@ -161,6 +227,10 @@ Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
@@ -185,6 +255,30 @@ Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
@@ -195,3 +289,49 @@ Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
Exec: /usr/bin/du -s '/var/spool/asterisk/monitor/' | awk '{print $1}'
|
||||
Exec: /usr/bin/cat /proc/cpuinfo | grep 'model name'
|
||||
|
||||
@@ -3,7 +3,11 @@
|
||||
> vite
|
||||
|
||||
|
||||
VITE v7.2.7 ready in 253 ms
|
||||
VITE v7.2.7 ready in 334 ms
|
||||
|
||||
➜ Local: http://localhost:3000/
|
||||
➜ Network: use --host to expose
|
||||
5:10:20 PM [vite] (client) hmr update /src/components/pages/settings/nginx/RTPSettings.tsx
|
||||
5:43:19 PM [vite] (client) hmr update /src/components/application-components/layout/Header.tsx
|
||||
5:43:19 PM [vite] (client) hmr update /src/components/pages/home/Home.tsx, /src/components/application-components/layout/Header.tsx
|
||||
5:47:22 PM [vite] (client) hmr update /src/components/pages/settings/nginx/RTPSettings.tsx
|
||||
|
||||
@@ -16,6 +16,7 @@ import ir.peeco.pline.repositories.SipProfileDetailsRepository;
|
||||
import ir.peeco.pline.repositories.SipProfilesRepository;
|
||||
import ir.peeco.pline.repositories.plineUser.UserAccessRepository;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
@@ -23,6 +24,8 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.net.InetAddress;
|
||||
import java.nio.file.InvalidPathException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
@@ -31,6 +34,8 @@ import java.nio.file.attribute.PosixFilePermissions;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
/** Manages protected Nginx, Asterisk WebRTC transport and TLS settings. */
|
||||
@RestController
|
||||
@@ -46,6 +51,7 @@ public class NginxManagementController {
|
||||
private static final Path CANDIDATE_DTLS_CERT = STATE_DIR.resolve("dtls-fullchain.candidate");
|
||||
private static final Path CANDIDATE_DTLS_KEY = STATE_DIR.resolve("dtls-private-key.candidate");
|
||||
private static final Pattern HOST_PATTERN = Pattern.compile("(?:_|\\[[0-9A-Fa-f:]+\\]|[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*|(?:[0-9]{1,3}\\.){3}[0-9]{1,3})");
|
||||
private static final Pattern IP_LITERAL_PATTERN = Pattern.compile("[0-9A-Fa-f:.]+(?:/[0-9]{1,3})?");
|
||||
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
private final UserLogger userLogger;
|
||||
@@ -79,6 +85,7 @@ public class NginxManagementController {
|
||||
result.addResult("sslContents", readSslContents());
|
||||
result.addResult("host", readHostSettings());
|
||||
result.addResult("webrtc", readWebRtcConfiguration());
|
||||
result.addResult("rtp", readRtpConfiguration());
|
||||
result.addResult("baseConfigurations", List.of(
|
||||
Map.of("id", "webrtc", "locked", true),
|
||||
Map.of("id", "host-ssl", "locked", true)));
|
||||
@@ -185,6 +192,31 @@ public class NginxManagementController {
|
||||
throw new IllegalArgumentException("WebRTC port must be between 1 and 65535");
|
||||
next.serverName = request.serverName.trim();
|
||||
next.port = request.port;
|
||||
next.rtpStart = previous.rtpStart;
|
||||
next.rtpEnd = previous.rtpEnd;
|
||||
next.iceEnabled = true;
|
||||
next.stunHost = previous.stunHost;
|
||||
next.stunPort = previous.stunPort;
|
||||
next.clientStunHost = previous.clientStunHost;
|
||||
next.clientStunPort = previous.clientStunPort;
|
||||
next.iceHostCandidates = previous.iceHostCandidates;
|
||||
next.includeLocalIceCandidates = previous.includeLocalIceCandidates;
|
||||
next.turnEnabled = previous.turnEnabled;
|
||||
next.turnHost = previous.turnHost;
|
||||
next.turnPort = previous.turnPort;
|
||||
next.turnTlsPort = previous.turnTlsPort;
|
||||
next.turnUdpEnabled = previous.turnUdpEnabled;
|
||||
next.turnTcpEnabled = previous.turnTcpEnabled;
|
||||
next.turnTlsEnabled = previous.turnTlsEnabled;
|
||||
next.turnRelayStart = previous.turnRelayStart;
|
||||
next.turnRelayEnd = previous.turnRelayEnd;
|
||||
next.turnRealm = previous.turnRealm;
|
||||
next.turnInternalIp = previous.turnInternalIp;
|
||||
next.turnExternalIp = previous.turnExternalIp;
|
||||
next.turnTlsCertPath = previous.turnTlsCertPath;
|
||||
next.turnTlsPrivateKeyPath = previous.turnTlsPrivateKeyPath;
|
||||
next.turnCredentialTtlSeconds = previous.turnCredentialTtlSeconds;
|
||||
next.turnSharedSecret = previous.turnSharedSecret;
|
||||
next.httpPort = http.getBindPort();
|
||||
next.tlsPort = http.getTlsBindPort();
|
||||
next.upstreamHost = normalizeLoopbackTarget(http.getBindAddr());
|
||||
@@ -201,7 +233,7 @@ public class NginxManagementController {
|
||||
Map<String, Object> currentSsl = readCertificateInfo();
|
||||
if (!Boolean.TRUE.equals(currentSsl.get("valid")))
|
||||
throw new IllegalStateException("Apply a valid host SSL certificate before using direct HTTPS to Asterisk");
|
||||
String keys = plineTools.getConfigPath() + "keys/";
|
||||
String keys = plineTools.getAsteriskConfigPath() + "keys/";
|
||||
http.setTlsEnable(true);
|
||||
http.setTlsBindPort(request.port);
|
||||
next.tlsPort = request.port;
|
||||
@@ -229,7 +261,9 @@ public class NginxManagementController {
|
||||
runManager("apply-webrtc");
|
||||
httpRepository.save(http);
|
||||
updateWebRtcProfiles(request.mode, request.dtlsMode);
|
||||
fileGenerator.GenerateFiles();
|
||||
if (!fileGenerator.GenerateFiles())
|
||||
throw new IllegalStateException(
|
||||
"Could not apply WebRTC settings. Check Asterisk configuration permissions and logs.");
|
||||
plineTools.execAsteriskCli("http reload", true);
|
||||
result.addResult("webrtc", readWebRtcConfiguration());
|
||||
result.setHasError(false);
|
||||
@@ -261,6 +295,127 @@ public class NginxManagementController {
|
||||
return ResponseEntity.ok(result);
|
||||
}
|
||||
|
||||
@PostMapping("/rtp")
|
||||
public synchronized ResponseEntity<ApiResult> saveRtpSettings(HttpSession session,
|
||||
@RequestBody RtpSettingsRequest request) {
|
||||
ApiResult result = new ApiResult();
|
||||
WebRtcState previous = null;
|
||||
byte[] previousState = null;
|
||||
boolean stateExisted = false;
|
||||
boolean stateSnapshotTaken = false;
|
||||
try {
|
||||
requireAccess(session, UserAccessAction.Update);
|
||||
if (request == null) throw new IllegalArgumentException("RTP settings are required");
|
||||
validateRtpSettings(request.rtpStart, request.rtpEnd, request.stunHost, request.stunPort,
|
||||
request.clientStunHost, request.clientStunPort, request.iceHostCandidates);
|
||||
|
||||
previous = readWebRtcState();
|
||||
stateExisted = Files.isRegularFile(WEBRTC_FILE);
|
||||
if (stateExisted) previousState = Files.readAllBytes(WEBRTC_FILE);
|
||||
stateSnapshotTaken = true;
|
||||
request.turnSharedSecret = request.turnEnabled
|
||||
? (!trimToEmpty(request.turnSharedSecret).isBlank()
|
||||
? request.turnSharedSecret.trim() : trimToEmpty(previous.turnSharedSecret))
|
||||
: "";
|
||||
validateTurnSettings(request);
|
||||
WebRtcState next = previous;
|
||||
next.rtpStart = request.rtpStart;
|
||||
next.rtpEnd = request.rtpEnd;
|
||||
next.iceEnabled = true;
|
||||
next.stunHost = trimToEmpty(request.stunHost);
|
||||
next.stunPort = request.stunPort;
|
||||
next.clientStunHost = trimToEmpty(request.clientStunHost);
|
||||
next.clientStunPort = request.clientStunPort;
|
||||
next.iceHostCandidates = parseIceHostCandidates(request.iceHostCandidates);
|
||||
next.includeLocalIceCandidates = request.includeLocalIceCandidates;
|
||||
next.turnEnabled = request.turnEnabled;
|
||||
next.turnHost = trimToEmpty(request.turnHost);
|
||||
next.turnPort = request.turnPort;
|
||||
next.turnTlsPort = request.turnTlsPort;
|
||||
next.turnUdpEnabled = request.turnUdpEnabled;
|
||||
next.turnTcpEnabled = request.turnTcpEnabled;
|
||||
next.turnTlsEnabled = request.turnTlsEnabled;
|
||||
next.turnRelayStart = request.turnRelayStart;
|
||||
next.turnRelayEnd = request.turnRelayEnd;
|
||||
next.turnRealm = trimToEmpty(request.turnRealm).isBlank()
|
||||
? next.turnHost : request.turnRealm.trim();
|
||||
next.turnInternalIp = trimToEmpty(request.turnInternalIp);
|
||||
next.turnExternalIp = trimToEmpty(request.turnExternalIp);
|
||||
next.turnTlsCertPath = trimToEmpty(request.turnTlsCertPath);
|
||||
next.turnTlsPrivateKeyPath = trimToEmpty(request.turnTlsPrivateKeyPath);
|
||||
next.turnCredentialTtlSeconds = request.turnCredentialTtlSeconds;
|
||||
next.turnSharedSecret = request.turnSharedSecret;
|
||||
|
||||
Files.createDirectories(STATE_DIR);
|
||||
writePrivate(WEBRTC_FILE, objectMapper.writeValueAsString(next) + "\n");
|
||||
if (!fileGenerator.GenerateFiles())
|
||||
throw new IllegalStateException(
|
||||
"Could not apply RTP settings. Check Asterisk configuration permissions and logs.");
|
||||
result.addResult("rtp", readRtpConfiguration());
|
||||
result.setHasError(false);
|
||||
userLogger.addLog("Updated Asterisk RTP, ICE, and TURN client settings");
|
||||
} catch (Exception e) {
|
||||
if (e instanceof ResponseStatusException responseStatusException) throw responseStatusException;
|
||||
if (stateSnapshotTaken) {
|
||||
try {
|
||||
if (stateExisted && previousState != null) Files.write(WEBRTC_FILE, previousState);
|
||||
else if (!stateExisted) Files.deleteIfExists(WEBRTC_FILE);
|
||||
fileGenerator.GenerateFiles();
|
||||
} catch (Exception ignored) { }
|
||||
}
|
||||
result.setHasError(true);
|
||||
result.addMessage(safeMessage(e));
|
||||
userLogger.addLog("Failed to update Asterisk RTP, ICE, and TURN client settings: " + safeMessage(e));
|
||||
}
|
||||
return ResponseEntity.ok(result);
|
||||
}
|
||||
|
||||
@GetMapping("/client-settings")
|
||||
public ResponseEntity<ApiResult> getClientSettings(HttpSession session,
|
||||
HttpServletRequest servletRequest, @RequestParam String username) {
|
||||
ApiResult result = new ApiResult();
|
||||
try {
|
||||
requireSipUserRead(session);
|
||||
if (username == null || !username.matches("[A-Za-z0-9_.-]{1,64}"))
|
||||
throw new IllegalArgumentException("SIP username is invalid");
|
||||
if (!Files.isRegularFile(WEBRTC_FILE))
|
||||
throw new IllegalStateException("Save the WebRTC transport settings before generating a client QR code");
|
||||
WebRtcState state = readWebRtcState();
|
||||
String host = "_".equals(state.serverName) || state.serverName.isBlank()
|
||||
? servletRequest.getServerName() : state.serverName;
|
||||
String path = "proxy".equals(state.mode) ? "/asterisk-ws" : "/ws";
|
||||
String signalingUrl = "wss://" + host
|
||||
+ (state.port == 443 ? "" : ":" + state.port) + path;
|
||||
Map<String, Object> turn = Map.of("urls", List.of(), "username", "", "credential", "",
|
||||
"expiresAt", 0L);
|
||||
if (state.turnEnabled) {
|
||||
long expiresAt = System.currentTimeMillis() / 1000L + state.turnCredentialTtlSeconds;
|
||||
String turnUsername = expiresAt + ":" + username;
|
||||
String credential = createTurnCredential(turnUsername, state.turnSharedSecret);
|
||||
turn = Map.of("urls", buildTurnUrls(state), "username", turnUsername,
|
||||
"credential", credential, "expiresAt", expiresAt);
|
||||
}
|
||||
List<Map<String, Object>> iceServers = new ArrayList<>();
|
||||
if (!state.clientStunHost.isBlank()) {
|
||||
iceServers.add(Map.of("urls", "stun:" + formatIceServerHost(state.clientStunHost)
|
||||
+ ":" + state.clientStunPort));
|
||||
}
|
||||
if (state.turnEnabled) {
|
||||
iceServers.add(Map.of("urls", buildTurnUrls(state), "username", turn.get("username"),
|
||||
"credential", turn.get("credential")));
|
||||
}
|
||||
result.addResult("signalingUrl", signalingUrl);
|
||||
result.addResult("turn", turn);
|
||||
result.addResult("iceServers", iceServers);
|
||||
result.setHasError(false);
|
||||
} catch (Exception e) {
|
||||
if (e instanceof ResponseStatusException responseStatusException) throw responseStatusException;
|
||||
result.setHasError(true);
|
||||
result.addMessage(safeMessage(e));
|
||||
}
|
||||
return ResponseEntity.ok(result);
|
||||
}
|
||||
|
||||
private Map<String, Object> readWebRtcConfiguration() throws Exception {
|
||||
WebRtcState state = readWebRtcState();
|
||||
Map<String, Object> configuration = new HashMap<>();
|
||||
@@ -274,6 +429,31 @@ public class NginxManagementController {
|
||||
configuration.put("proxyUrl", "wss://" + state.serverName + ":" + state.port + "/asterisk-ws");
|
||||
configuration.put("directUrl", "wss://" + state.serverName + ":" + state.port + "/ws");
|
||||
configuration.put("upstreamHost", state.upstreamHost);
|
||||
configuration.put("rtpStart", state.rtpStart);
|
||||
configuration.put("rtpEnd", state.rtpEnd);
|
||||
configuration.put("iceEnabled", state.iceEnabled);
|
||||
configuration.put("stunHost", state.stunHost);
|
||||
configuration.put("stunPort", state.stunPort);
|
||||
configuration.put("clientStunHost", state.clientStunHost);
|
||||
configuration.put("clientStunPort", state.clientStunPort);
|
||||
configuration.put("iceHostCandidates", state.iceHostCandidates);
|
||||
configuration.put("includeLocalIceCandidates", state.includeLocalIceCandidates);
|
||||
configuration.put("turnEnabled", state.turnEnabled);
|
||||
configuration.put("turnHost", state.turnHost);
|
||||
configuration.put("turnPort", state.turnPort);
|
||||
configuration.put("turnTlsPort", state.turnTlsPort);
|
||||
configuration.put("turnUdpEnabled", state.turnUdpEnabled);
|
||||
configuration.put("turnTcpEnabled", state.turnTcpEnabled);
|
||||
configuration.put("turnTlsEnabled", state.turnTlsEnabled);
|
||||
configuration.put("turnRelayStart", state.turnRelayStart);
|
||||
configuration.put("turnRelayEnd", state.turnRelayEnd);
|
||||
configuration.put("turnRealm", state.turnRealm);
|
||||
configuration.put("turnInternalIp", state.turnInternalIp);
|
||||
configuration.put("turnExternalIp", state.turnExternalIp);
|
||||
configuration.put("turnTlsCertPath", state.turnTlsCertPath);
|
||||
configuration.put("turnTlsPrivateKeyPath", state.turnTlsPrivateKeyPath);
|
||||
configuration.put("turnCredentialTtlSeconds", state.turnCredentialTtlSeconds);
|
||||
configuration.put("turnSecretConfigured", !trimToEmpty(state.turnSharedSecret).isBlank());
|
||||
configuration.put("http", httpRepository.getFirstByEnable().map(value -> Map.of(
|
||||
"enabled", value.isEnabled(),
|
||||
"bindAddress", value.getBindAddr(),
|
||||
@@ -284,6 +464,37 @@ public class NginxManagementController {
|
||||
return configuration;
|
||||
}
|
||||
|
||||
private Map<String, Object> readRtpConfiguration() throws Exception {
|
||||
WebRtcState state = readWebRtcState();
|
||||
Map<String, Object> configuration = new HashMap<>();
|
||||
configuration.put("rtpStart", state.rtpStart);
|
||||
configuration.put("rtpEnd", state.rtpEnd);
|
||||
configuration.put("iceEnabled", state.iceEnabled);
|
||||
configuration.put("stunHost", state.stunHost);
|
||||
configuration.put("stunPort", state.stunPort);
|
||||
configuration.put("clientStunHost", state.clientStunHost);
|
||||
configuration.put("clientStunPort", state.clientStunPort);
|
||||
configuration.put("iceHostCandidates", state.iceHostCandidates);
|
||||
configuration.put("includeLocalIceCandidates", state.includeLocalIceCandidates);
|
||||
configuration.put("turnEnabled", state.turnEnabled);
|
||||
configuration.put("turnHost", state.turnHost);
|
||||
configuration.put("turnPort", state.turnPort);
|
||||
configuration.put("turnTlsPort", state.turnTlsPort);
|
||||
configuration.put("turnUdpEnabled", state.turnUdpEnabled);
|
||||
configuration.put("turnTcpEnabled", state.turnTcpEnabled);
|
||||
configuration.put("turnTlsEnabled", state.turnTlsEnabled);
|
||||
configuration.put("turnRelayStart", state.turnRelayStart);
|
||||
configuration.put("turnRelayEnd", state.turnRelayEnd);
|
||||
configuration.put("turnRealm", state.turnRealm);
|
||||
configuration.put("turnInternalIp", state.turnInternalIp);
|
||||
configuration.put("turnExternalIp", state.turnExternalIp);
|
||||
configuration.put("turnTlsCertPath", state.turnTlsCertPath);
|
||||
configuration.put("turnTlsPrivateKeyPath", state.turnTlsPrivateKeyPath);
|
||||
configuration.put("turnCredentialTtlSeconds", state.turnCredentialTtlSeconds);
|
||||
configuration.put("turnSecretConfigured", !trimToEmpty(state.turnSharedSecret).isBlank());
|
||||
return configuration;
|
||||
}
|
||||
|
||||
private WebRtcState readWebRtcState() throws Exception {
|
||||
if (Files.isRegularFile(WEBRTC_FILE))
|
||||
return objectMapper.readValue(WEBRTC_FILE.toFile(), WebRtcState.class);
|
||||
@@ -313,8 +524,8 @@ public class NginxManagementController {
|
||||
|
||||
private void updateWebRtcProfiles(String mode, String dtlsMode) {
|
||||
String transportProtocol = "direct".equals(mode) ? "wss" : "ws";
|
||||
String dtlsCert = plineTools.getConfigPath() + "keys/raymand-webrtc-dtls.pem";
|
||||
String dtlsKey = plineTools.getConfigPath() + "keys/raymand-webrtc-dtls-key.pem";
|
||||
String dtlsCert = plineTools.getAsteriskConfigPath() + "keys/raymand-webrtc-dtls.pem";
|
||||
String dtlsKey = plineTools.getAsteriskConfigPath() + "keys/raymand-webrtc-dtls-key.pem";
|
||||
List<TblSipProfileDetails> updates = new ArrayList<>();
|
||||
List<TblSipProfileDetails> removals = new ArrayList<>();
|
||||
for (TblSipProfile profile : sipProfilesRepository.findAll()) {
|
||||
@@ -328,6 +539,15 @@ public class NginxManagementController {
|
||||
List<TblSipProfileDetails> transport = sipProfileDetailsRepository
|
||||
.getBySipProfileIdAndType(profile.getId(), "transport");
|
||||
setProfileValue(profile, transport, "protocol", transportProtocol, updates, removals);
|
||||
setProfileValue(profile, transport, "allow_reload", "yes", updates, removals);
|
||||
setProfileValue(profile, endpoint, "ice_support", "yes", updates, removals);
|
||||
setProfileValue(profile, endpoint, "use_avpf", "yes", updates, removals);
|
||||
setProfileValue(profile, endpoint, "media_encryption", "dtls", updates, removals);
|
||||
setProfileValue(profile, endpoint, "dtls_verify", "fingerprint", updates, removals);
|
||||
setProfileValue(profile, endpoint, "dtls_setup", "actpass", updates, removals);
|
||||
setProfileValue(profile, endpoint, "media_use_received_transport", "yes", updates, removals);
|
||||
setProfileValue(profile, endpoint, "rtcp_mux", "yes", updates, removals);
|
||||
setProfileValue(profile, endpoint, "direct_media", "no", updates, removals);
|
||||
setProfileValue(profile, endpoint, "dtls_auto_generate_cert",
|
||||
"auto".equals(dtlsMode) ? "yes" : "no", updates, removals);
|
||||
if ("custom".equals(dtlsMode)) {
|
||||
@@ -342,6 +562,133 @@ public class NginxManagementController {
|
||||
if (!updates.isEmpty()) sipProfileDetailsRepository.saveAll(updates);
|
||||
}
|
||||
|
||||
private void validateRtpSettings(int rtpStart, int rtpEnd, String stunHost, int stunPort,
|
||||
String clientStunHost, int clientStunPort, String iceHostCandidates) {
|
||||
if (rtpStart < 1024 || rtpEnd > 65535 || rtpStart >= rtpEnd)
|
||||
throw new IllegalArgumentException("RTP ports must be between 1024 and 65535, with the end port greater than the start port");
|
||||
if (stunPort < 1 || stunPort > 65535)
|
||||
throw new IllegalArgumentException("STUN port must be between 1 and 65535");
|
||||
if (!trimToEmpty(stunHost).isBlank()) validateWebRtcHost(stunHost, "STUN host");
|
||||
if (clientStunPort < 1 || clientStunPort > 65535)
|
||||
throw new IllegalArgumentException("Browser STUN port must be between 1 and 65535");
|
||||
if (!trimToEmpty(clientStunHost).isBlank())
|
||||
validateWebRtcHost(clientStunHost, "Browser STUN host");
|
||||
List<String> candidates = parseIceHostCandidates(iceHostCandidates);
|
||||
if (!candidates.isEmpty() && !trimToEmpty(stunHost).isBlank())
|
||||
throw new IllegalArgumentException("Use either a STUN server or static ICE host mappings for Asterisk, not both");
|
||||
}
|
||||
|
||||
private void validateTurnSettings(RtpSettingsRequest request) {
|
||||
if (!request.turnEnabled) return;
|
||||
validateWebRtcHost(request.turnHost, "TURN host");
|
||||
if (!trimToEmpty(request.turnRealm).isBlank())
|
||||
validateWebRtcHost(request.turnRealm, "TURN realm");
|
||||
if (!request.turnUdpEnabled && !request.turnTcpEnabled && !request.turnTlsEnabled)
|
||||
throw new IllegalArgumentException("Enable at least one TURN transport");
|
||||
if (request.turnPort < 1 || request.turnPort > 65535
|
||||
|| request.turnTlsPort < 1 || request.turnTlsPort > 65535)
|
||||
throw new IllegalArgumentException("TURN ports must be between 1 and 65535");
|
||||
if (request.turnRelayStart < 1024 || request.turnRelayEnd > 65535
|
||||
|| request.turnRelayStart >= request.turnRelayEnd)
|
||||
throw new IllegalArgumentException("TURN relay ports must be between 1024 and 65535, with the end port greater than the start port");
|
||||
if (request.turnCredentialTtlSeconds < 60 || request.turnCredentialTtlSeconds > 86400)
|
||||
throw new IllegalArgumentException("TURN credential lifetime must be between 60 and 86400 seconds");
|
||||
if (!trimToEmpty(request.turnInternalIp).isBlank() || !trimToEmpty(request.turnExternalIp).isBlank()) {
|
||||
if (trimToEmpty(request.turnInternalIp).isBlank() || trimToEmpty(request.turnExternalIp).isBlank()
|
||||
|| !isIpLiteral(request.turnInternalIp) || !isIpLiteral(request.turnExternalIp))
|
||||
throw new IllegalArgumentException("Enter both valid internal and public TURN IP addresses, or leave both empty");
|
||||
}
|
||||
if (request.turnTlsEnabled) {
|
||||
validateAbsolutePath(request.turnTlsCertPath, "TURN TLS certificate path");
|
||||
validateAbsolutePath(request.turnTlsPrivateKeyPath, "TURN TLS private key path");
|
||||
}
|
||||
if (trimToEmpty(request.turnSharedSecret).length() < 32)
|
||||
throw new IllegalArgumentException("TURN shared secret must contain at least 32 characters");
|
||||
if (trimToEmpty(request.turnSharedSecret).length() > 256)
|
||||
throw new IllegalArgumentException("TURN shared secret cannot exceed 256 characters");
|
||||
}
|
||||
|
||||
private List<String> parseIceHostCandidates(String value) {
|
||||
List<String> candidates = new ArrayList<>();
|
||||
if (value == null || value.isBlank()) return candidates;
|
||||
for (String line : value.split("\\R")) {
|
||||
String candidate = line.trim();
|
||||
if (candidate.isEmpty()) continue;
|
||||
String[] addresses = candidate.split("=>", -1);
|
||||
if (addresses.length != 2 || !isIpLiteral(addresses[0]) || !isIpLiteral(addresses[1]))
|
||||
throw new IllegalArgumentException("Each ICE mapping must be an IP address pair in the form local IP => public IP");
|
||||
candidates.add(normalizeIpLiteral(addresses[0]) + " => " + normalizeIpLiteral(addresses[1]));
|
||||
}
|
||||
return candidates;
|
||||
}
|
||||
|
||||
private String normalizeIpLiteral(String value) {
|
||||
String address = value.trim();
|
||||
return address.startsWith("[") && address.endsWith("]")
|
||||
? address.substring(1, address.length() - 1) : address;
|
||||
}
|
||||
|
||||
private void validateWebRtcHost(String value, String label) {
|
||||
if (value == null || value.isBlank() || "_".equals(value.trim())
|
||||
|| !HOST_PATTERN.matcher(value.trim()).matches())
|
||||
throw new IllegalArgumentException(label + " must be a DNS name or IP address");
|
||||
}
|
||||
|
||||
private boolean isIpLiteral(String value) {
|
||||
if (value == null) return false;
|
||||
String address = value.trim();
|
||||
if (address.startsWith("[") && address.endsWith("]"))
|
||||
address = address.substring(1, address.length() - 1);
|
||||
if (!IP_LITERAL_PATTERN.matcher(address).matches() || address.contains("/")) return false;
|
||||
try {
|
||||
return InetAddress.getByName(address).getHostAddress() != null;
|
||||
} catch (Exception ignored) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void validateAbsolutePath(String value, String label) {
|
||||
if (value == null || !value.startsWith("/") || value.contains("\n") || value.contains("\r"))
|
||||
throw new IllegalArgumentException(label + " must be an absolute filesystem path");
|
||||
try {
|
||||
Path.of(value);
|
||||
} catch (InvalidPathException e) {
|
||||
throw new IllegalArgumentException(label + " is invalid");
|
||||
}
|
||||
}
|
||||
|
||||
private String trimToEmpty(String value) {
|
||||
return value == null ? "" : value.trim();
|
||||
}
|
||||
|
||||
private List<String> buildTurnUrls(WebRtcState state) {
|
||||
String host = formatIceServerHost(state.turnHost);
|
||||
List<String> urls = new ArrayList<>();
|
||||
if (state.turnUdpEnabled) urls.add("turn:" + host + ":" + state.turnPort + "?transport=udp");
|
||||
if (state.turnTcpEnabled) urls.add("turn:" + host + ":" + state.turnPort + "?transport=tcp");
|
||||
if (state.turnTlsEnabled) urls.add("turns:" + host + ":" + state.turnTlsPort + "?transport=tcp");
|
||||
return urls;
|
||||
}
|
||||
|
||||
private String formatIceServerHost(String host) {
|
||||
return host.contains(":") && !host.startsWith("[") ? "[" + host + "]" : host;
|
||||
}
|
||||
|
||||
private String createTurnCredential(String username, String secret) throws Exception {
|
||||
Mac mac = Mac.getInstance("HmacSHA1");
|
||||
mac.init(new SecretKeySpec(secret.getBytes(StandardCharsets.UTF_8), "HmacSHA1"));
|
||||
return Base64.getEncoder().encodeToString(mac.doFinal(username.getBytes(StandardCharsets.UTF_8)));
|
||||
}
|
||||
|
||||
private void requireSipUserRead(HttpSession session) {
|
||||
Object current = session.getAttribute("user");
|
||||
if (!(current instanceof TblPlineUser user))
|
||||
throw new ResponseStatusException(HttpStatus.UNAUTHORIZED, "Login required");
|
||||
if (user.getId() != null && user.getId() == 1L) return;
|
||||
if (userAccessRepository.findAllByPlineUserAndMenuIdAndAction(user, "2_1", UserAccessAction.Read).isEmpty())
|
||||
throw new ResponseStatusException(HttpStatus.FORBIDDEN, "Permission denied");
|
||||
}
|
||||
|
||||
private void setProfileValue(TblSipProfile profile, List<TblSipProfileDetails> details,
|
||||
String key, String value, List<TblSipProfileDetails> updates,
|
||||
List<TblSipProfileDetails> removals) {
|
||||
@@ -470,6 +817,33 @@ public class NginxManagementController {
|
||||
public String dtlsPrivateKey;
|
||||
}
|
||||
|
||||
public static class RtpSettingsRequest {
|
||||
public int rtpStart = 10000;
|
||||
public int rtpEnd = 20000;
|
||||
public String stunHost = "";
|
||||
public int stunPort = 3478;
|
||||
public String clientStunHost = "";
|
||||
public int clientStunPort = 3478;
|
||||
public String iceHostCandidates = "";
|
||||
public boolean includeLocalIceCandidates;
|
||||
public boolean turnEnabled;
|
||||
public String turnHost = "";
|
||||
public int turnPort = 3478;
|
||||
public int turnTlsPort = 5349;
|
||||
public boolean turnUdpEnabled = true;
|
||||
public boolean turnTcpEnabled;
|
||||
public boolean turnTlsEnabled;
|
||||
public int turnRelayStart = 49152;
|
||||
public int turnRelayEnd = 65535;
|
||||
public String turnRealm = "";
|
||||
public String turnInternalIp = "";
|
||||
public String turnExternalIp = "";
|
||||
public String turnTlsCertPath = "";
|
||||
public String turnTlsPrivateKeyPath = "";
|
||||
public int turnCredentialTtlSeconds = 3600;
|
||||
public String turnSharedSecret = "";
|
||||
}
|
||||
|
||||
public static class WebRtcState {
|
||||
public String mode = "proxy";
|
||||
public String dtlsMode = "auto";
|
||||
@@ -482,6 +856,31 @@ public class NginxManagementController {
|
||||
public boolean originalTlsEnabled;
|
||||
public String originalTlsCert = "";
|
||||
public String originalTlsKey = "";
|
||||
public int rtpStart = 10000;
|
||||
public int rtpEnd = 20000;
|
||||
public boolean iceEnabled = true;
|
||||
public String stunHost = "";
|
||||
public int stunPort = 3478;
|
||||
public String clientStunHost = "";
|
||||
public int clientStunPort = 3478;
|
||||
public List<String> iceHostCandidates = new ArrayList<>();
|
||||
public boolean includeLocalIceCandidates;
|
||||
public boolean turnEnabled;
|
||||
public String turnHost = "";
|
||||
public int turnPort = 3478;
|
||||
public int turnTlsPort = 5349;
|
||||
public boolean turnUdpEnabled = true;
|
||||
public boolean turnTcpEnabled;
|
||||
public boolean turnTlsEnabled;
|
||||
public int turnRelayStart = 49152;
|
||||
public int turnRelayEnd = 65535;
|
||||
public String turnRealm = "";
|
||||
public String turnInternalIp = "";
|
||||
public String turnExternalIp = "";
|
||||
public String turnTlsCertPath = "";
|
||||
public String turnTlsPrivateKeyPath = "";
|
||||
public int turnCredentialTtlSeconds = 3600;
|
||||
public String turnSharedSecret = "";
|
||||
}
|
||||
|
||||
public static class SslRequest {
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import ir.peeco.pline.models.TblSipProfileDetails;
|
||||
import ir.peeco.pline.repositories.SipProfileDetailsRepository;
|
||||
@@ -50,6 +51,7 @@ public class SipProfileDetailsController {
|
||||
|
||||
@PostMapping("/save")
|
||||
@SuppressWarnings("unchecked")
|
||||
@Transactional
|
||||
public ResponseEntity<Object> save(@RequestBody Map<String, Object> body) {
|
||||
|
||||
Long id = Long.valueOf(body.get("id").toString());
|
||||
|
||||
@@ -23,6 +23,8 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -177,8 +179,8 @@ public class Initializer {
|
||||
http.setEnable(true);
|
||||
http.setEnabled(true);
|
||||
http.setTlsEnable(false);
|
||||
http.setTlsCertFile(plineTools.getConfigPath() + "keys/p-line.crt");
|
||||
http.setTlsPrivateKey(plineTools.getConfigPath() + "keys/p-line.key");
|
||||
http.setTlsCertFile(plineTools.getAsteriskConfigPath() + "keys/p-line.crt");
|
||||
http.setTlsPrivateKey(plineTools.getAsteriskConfigPath() + "keys/p-line.key");
|
||||
httpRepository.save(http);
|
||||
}
|
||||
|
||||
@@ -501,6 +503,7 @@ public class Initializer {
|
||||
\t\t\t***********************************************
|
||||
""");
|
||||
|
||||
ensureDefaultWebRtcProfile();
|
||||
fileGenerator.GenerateFiles();
|
||||
dialableNumberConflictService.findExistingConflicts()
|
||||
.forEach(plineTools::plineLogger);
|
||||
@@ -519,6 +522,56 @@ public class Initializer {
|
||||
};
|
||||
}
|
||||
|
||||
/** Keeps the factory WebRTC profile usable for both existing and newly-created SIP users. */
|
||||
private void ensureDefaultWebRtcProfile() {
|
||||
var profile = sipProfilesRepository.findByName("Default Webrtc Profile");
|
||||
if (profile.isEmpty()) return;
|
||||
|
||||
Map<String, String> requiredEndpointSettings = new LinkedHashMap<>();
|
||||
requiredEndpointSettings.put("webrtc", "yes");
|
||||
requiredEndpointSettings.put("ice_support", "yes");
|
||||
requiredEndpointSettings.put("use_avpf", "yes");
|
||||
requiredEndpointSettings.put("media_encryption", "dtls");
|
||||
requiredEndpointSettings.put("dtls_verify", "fingerprint");
|
||||
requiredEndpointSettings.put("dtls_setup", "actpass");
|
||||
requiredEndpointSettings.put("media_use_received_transport", "yes");
|
||||
requiredEndpointSettings.put("rtcp_mux", "yes");
|
||||
requiredEndpointSettings.put("direct_media", "no");
|
||||
|
||||
List<TblSipProfileDetails> endpoint = profileDetailsRepository
|
||||
.getBySipProfileIdAndType(profile.get().getId(), "endpoint");
|
||||
List<TblSipProfileDetails> changed = new ArrayList<>();
|
||||
requiredEndpointSettings.forEach((key, value) -> upsertDefaultProfileDetail(
|
||||
profile.get(), endpoint, "endpoint", key, value, changed, true));
|
||||
upsertDefaultProfileDetail(profile.get(), endpoint, "endpoint", "dtls_auto_generate_cert", "yes", changed, false);
|
||||
upsertDefaultProfileDetail(profile.get(), endpoint, "endpoint", "allow",
|
||||
"[\"ulaw\",\"alaw\"]", changed, false);
|
||||
|
||||
List<TblSipProfileDetails> transport = profileDetailsRepository
|
||||
.getBySipProfileIdAndType(profile.get().getId(), "transport");
|
||||
upsertDefaultProfileDetail(profile.get(), transport, "transport", "allow_reload", "yes", changed, false);
|
||||
if (!changed.isEmpty()) profileDetailsRepository.saveAll(changed);
|
||||
}
|
||||
|
||||
private void upsertDefaultProfileDetail(TblSipProfile profile, List<TblSipProfileDetails> details,
|
||||
String type, String key, String value, List<TblSipProfileDetails> changed, boolean enforce) {
|
||||
var current = details.stream().filter(detail -> key.equalsIgnoreCase(detail.getKey())).findFirst();
|
||||
if (current.isPresent()) {
|
||||
if (enforce && !value.equalsIgnoreCase(current.get().getValue())) {
|
||||
current.get().setValue(value);
|
||||
changed.add(current.get());
|
||||
}
|
||||
return;
|
||||
}
|
||||
TblSipProfileDetails detail = new TblSipProfileDetails();
|
||||
detail.setSipProfile(profile);
|
||||
detail.setType(type);
|
||||
detail.setKey(key);
|
||||
detail.setValue(value);
|
||||
details.add(detail);
|
||||
changed.add(detail);
|
||||
}
|
||||
|
||||
private TblSipProfile getOrCreateSipProfile(String name, String description) {
|
||||
return sipProfilesRepository.findByName(name).orElseGet(() -> {
|
||||
TblSipProfile profile = new TblSipProfile();
|
||||
|
||||
@@ -372,6 +372,22 @@ public class PlineTools {
|
||||
return path;
|
||||
}
|
||||
|
||||
/** Returns the path Asterisk sees inside its container when Docker mode is enabled. */
|
||||
public String getAsteriskConfigPath() {
|
||||
return asteriskDockerMode ? "/etc/asterisk/" : getConfigPath();
|
||||
}
|
||||
|
||||
/** Translate a host-mounted Asterisk path to the path used inside its container. */
|
||||
public String getAsteriskConfigPath(String configuredPath) {
|
||||
if (!asteriskDockerMode || configuredPath == null || configuredPath.isBlank())
|
||||
return configuredPath;
|
||||
String hostPrefix = normalizeBasePath() + "/base/etc/" + this.core + "/";
|
||||
String normalized = configuredPath.replace('\\', '/');
|
||||
if (normalized.startsWith(hostPrefix))
|
||||
return "/etc/" + this.core + "/" + normalized.substring(hostPrefix.length());
|
||||
return normalized;
|
||||
}
|
||||
|
||||
public void plineLogger(String message) {
|
||||
logger.info(message);
|
||||
}
|
||||
@@ -904,15 +920,28 @@ public class PlineTools {
|
||||
this.plineLogger("Create info file: " + filename);
|
||||
}
|
||||
|
||||
List<String> existingLines = Files.readAllLines(Paths.get(infoFile.getPath()), StandardCharsets.UTF_8);
|
||||
List<String> addedIncludes = new ArrayList<>();
|
||||
includes.forEach(x -> {
|
||||
try {
|
||||
Files.write(Paths.get(infoFile.getPath()), ("#include \"" + x.trim() + "\"\n").getBytes(),
|
||||
String includeLine = "#include \"" + x.trim() + "\"";
|
||||
boolean alreadyIncluded = existingLines.stream()
|
||||
.map(String::trim)
|
||||
.anyMatch(includeLine::equals);
|
||||
if (!alreadyIncluded) {
|
||||
Files.write(Paths.get(infoFile.getPath()), (includeLine + "\n").getBytes(StandardCharsets.UTF_8),
|
||||
StandardOpenOption.APPEND);
|
||||
existingLines.add(includeLine);
|
||||
addedIncludes.add(includeLine);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
Files.write(Paths.get(infoFile.getPath()), "\n".getBytes(), StandardOpenOption.APPEND);
|
||||
if (!addedIncludes.isEmpty()) {
|
||||
Files.write(Paths.get(infoFile.getPath()), "\n".getBytes(StandardCharsets.UTF_8),
|
||||
StandardOpenOption.APPEND);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
|
||||
@@ -63,8 +63,8 @@ public class HttpGenerator {
|
||||
ic.addElement("redirect", data.getRedirect());
|
||||
ic.addElement("tlsenable", data.isTlsEnable());
|
||||
ic.addElement("tlsbindaddr", data.getTlsBindAddr() + ":" + data.getTlsBindPort());
|
||||
ic.addElement("tlscertfile", data.getTlsCertFile());
|
||||
ic.addElement("tlsprivatekey", data.getTlsPrivateKey());
|
||||
ic.addElement("tlscertfile", plineTools.getAsteriskConfigPath(data.getTlsCertFile()));
|
||||
ic.addElement("tlsprivatekey", plineTools.getAsteriskConfigPath(data.getTlsPrivateKey()));
|
||||
plineTools.writeInfoFile("", "http.conf", ic);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package ir.peeco.pline.plineServer.fileGeneratorTools;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
|
||||
import ir.peeco.pline.enums.AssignMark;
|
||||
@@ -23,6 +26,9 @@ import ir.peeco.pline.repositories.cdr.CdrSettingsRepository;
|
||||
@Scope("singleton")
|
||||
public class PlineSettingsGenerator {
|
||||
|
||||
private static final Path WEBRTC_STATE = Path.of(GlobalTools.getBaseDir(), "nginx-management", "webrtc.json");
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
private CdrSettingsRepository cdrSettingsRepository;
|
||||
private PlineTools plineTools;
|
||||
|
||||
@@ -42,6 +48,71 @@ public class PlineSettingsGenerator {
|
||||
models();
|
||||
cdrSetting();
|
||||
setHA();
|
||||
rtp();
|
||||
}
|
||||
|
||||
private void rtp() {
|
||||
List<InfoConfiguration> configurations = new ArrayList<>();
|
||||
boolean hasSavedSettings = WEBRTC_STATE.toFile().isFile();
|
||||
File generatedConfig = new File(plineTools.getConfigPath() + "rtp-webrtc.conf");
|
||||
if (!hasSavedSettings && !generatedConfig.isFile())
|
||||
return;
|
||||
if (hasSavedSettings) {
|
||||
try {
|
||||
JsonNode settings = objectMapper.readTree(WEBRTC_STATE.toFile());
|
||||
InfoConfiguration general = new InfoConfiguration("general");
|
||||
general.setBanner(true);
|
||||
general.setDescription("Managed by Raymand CTI WebRTC settings.");
|
||||
general.addElement("rtpstart", settings.path("rtpStart").canConvertToInt()
|
||||
? settings.path("rtpStart").asInt()
|
||||
: 10000, AssignMark.Equal);
|
||||
general.addElement("rtpend", settings.path("rtpEnd").canConvertToInt()
|
||||
? settings.path("rtpEnd").asInt()
|
||||
: 20000, AssignMark.Equal);
|
||||
general.addElement("icesupport", settings.path("iceEnabled").asBoolean(true), AssignMark.Equal);
|
||||
|
||||
JsonNode candidates = settings.path("iceHostCandidates");
|
||||
boolean hasCandidates = candidates.isArray() && !candidates.isEmpty();
|
||||
String stunHost = settings.path("stunHost").asText("").trim();
|
||||
if (!stunHost.isEmpty() && !hasCandidates) {
|
||||
int stunPort = settings.path("stunPort").canConvertToInt()
|
||||
? settings.path("stunPort").asInt()
|
||||
: 3478;
|
||||
general.addElement("stunaddr", stunHost + ":" + stunPort, AssignMark.Equal);
|
||||
}
|
||||
configurations.add(general);
|
||||
|
||||
if (hasCandidates) {
|
||||
InfoConfiguration iceHostCandidates = new InfoConfiguration("ice_host_candidates");
|
||||
boolean includeLocalAddress = settings.path("includeLocalIceCandidates").asBoolean(false);
|
||||
candidates.forEach(candidate -> {
|
||||
if (!candidate.isTextual())
|
||||
return;
|
||||
String[] addresses = candidate.asText().split("=>", -1);
|
||||
if (addresses.length != 2 || addresses[0].isBlank() || addresses[1].isBlank()) {
|
||||
plineTools.plineLogger("Ignoring invalid saved WebRTC ICE host candidate: "
|
||||
+ candidate.asText());
|
||||
return;
|
||||
}
|
||||
String advertisedAddress = addresses[1].trim()
|
||||
+ (includeLocalAddress ? ",include_local_address" : "");
|
||||
iceHostCandidates.addElement(addresses[0].trim(), advertisedAddress,
|
||||
AssignMark.PriorityOperator);
|
||||
});
|
||||
if (!iceHostCandidates.getElements().isEmpty())
|
||||
configurations.add(iceHostCandidates);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
plineTools.plineLogger("Could not read saved WebRTC RTP settings: " + ex.getMessage());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!plineTools.writeInfoFile("", "rtp-webrtc.conf", configurations)) {
|
||||
plineTools.plineLogger("Could not write WebRTC RTP settings");
|
||||
return;
|
||||
}
|
||||
plineTools.IncludeConfigFile("", "rtp.conf", "rtp-webrtc.conf");
|
||||
}
|
||||
|
||||
private void models() {
|
||||
@@ -73,7 +144,6 @@ public class PlineSettingsGenerator {
|
||||
modules.addElement("noload", "res_phoneprov.so", AssignMark.PriorityOperator);
|
||||
modules.addElement("noload", "chan_iax2.so", AssignMark.PriorityOperator);
|
||||
|
||||
|
||||
modules.addElement("\n;**** Load Modules ****", "", AssignMark.Empty);
|
||||
modules.addElement("load", "cdr_pgsql.so", AssignMark.PriorityOperator);
|
||||
modules.addElement("load", "res_ari.so", AssignMark.PriorityOperator);
|
||||
@@ -233,7 +303,7 @@ public class PlineSettingsGenerator {
|
||||
}
|
||||
|
||||
try {
|
||||
String haScript = """
|
||||
String haScript = """
|
||||
#!/bin/bash
|
||||
# ======================================================
|
||||
# PostgreSQL HA Logical Replication Script v17.3 (Stable)
|
||||
@@ -750,5 +820,4 @@ String haScript = """
|
||||
plineTools.plineLogger("result");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user