Add P2P STUN/TURN voice call feature with single-port WebSocket relay workaround
This commit is contained in:
parent
7cc9ba7f4d
commit
0d3817d7ea
22 changed files with 4757 additions and 9 deletions
|
|
@ -1,3 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GsDChat.Core.Models;
|
||||
|
||||
namespace GsDChat.Server.Configuration;
|
||||
|
||||
public class ServerOptions
|
||||
|
|
@ -17,6 +21,59 @@ public class ServerOptions
|
|||
public bool AllowDmE2ee { get; set; } = true;
|
||||
public int MaxGroupChatUsers { get; set; } = 10;
|
||||
|
||||
// Voice Call & P2P STUN/TURN + Single-Port Relay Settings
|
||||
public bool EnableVoiceCalls { get; set; } = true;
|
||||
public bool AllowVoiceRelayFallback { get; set; } = true;
|
||||
public int MaxVoiceCallUsers { get; set; } = 10;
|
||||
public List<string> StunServers { get; set; } = new()
|
||||
{
|
||||
"stun:stun.cloudflare.com:3478",
|
||||
"stun:stun.l.google.com:19302"
|
||||
};
|
||||
public List<IceServerConfig> TurnServers { get; set; } = new()
|
||||
{
|
||||
new IceServerConfig
|
||||
{
|
||||
Urls = new List<string>
|
||||
{
|
||||
"turn:openrelay.metered.ca:80",
|
||||
"turn:openrelay.metered.ca:443",
|
||||
"turn:openrelay.metered.ca:443?transport=tcp",
|
||||
"turns:openrelay.metered.ca:443?transport=tcp"
|
||||
},
|
||||
Username = "openrelayproject",
|
||||
Credential = "openrelayproject"
|
||||
}
|
||||
};
|
||||
|
||||
public List<IceServerConfig> GetIceServers()
|
||||
{
|
||||
var list = new List<IceServerConfig>();
|
||||
var validStun = (StunServers ?? new List<string>())
|
||||
.Where(s => !string.IsNullOrWhiteSpace(s))
|
||||
.Select(s => s.Trim())
|
||||
.Distinct()
|
||||
.ToList();
|
||||
|
||||
if (validStun.Count > 0)
|
||||
{
|
||||
list.Add(new IceServerConfig { Urls = validStun });
|
||||
}
|
||||
|
||||
if (TurnServers != null)
|
||||
{
|
||||
foreach (var t in TurnServers)
|
||||
{
|
||||
if (t != null && t.Urls != null && t.Urls.Any(u => !string.IsNullOrWhiteSpace(u)))
|
||||
{
|
||||
list.Add(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
// Web Push (VAPID RFC 8292)
|
||||
public string? VapidPublicKey { get; set; }
|
||||
public string? VapidPrivateKey { get; set; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue