91 lines
3.3 KiB
C#
91 lines
3.3 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using GsDChat.Core.Models;
|
|
|
|
namespace GsDChat.Server.Configuration;
|
|
|
|
public class ServerOptions
|
|
{
|
|
public string Host { get; set; } = "0.0.0.0";
|
|
public int Port { get; set; } = 5000;
|
|
public bool UseTls { get; set; } = false;
|
|
public string? CertificatePath { get; set; }
|
|
public string? CertificatePassword { get; set; }
|
|
public string? ServerWidePassword { get; set; }
|
|
public string RegistrationMode { get; set; } = "Open"; // Open or InviteOnly
|
|
public string DataDirectory { get; set; } = "data";
|
|
public long MaxFileSizeMb { get; set; } = 50;
|
|
public string ServerName { get; set; } = "GsDChat Community Server";
|
|
public string Motd { get; set; } = "Welcome to GsDChat! Enjoy private, modular messaging.";
|
|
public bool AllowMemberChannelCreation { get; set; } = true;
|
|
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; }
|
|
public string VapidSubject { get; set; } = "mailto:admin@gsdchat.local";
|
|
|
|
// Security Settings
|
|
public int RateLimitRequestsPerMinute { get; set; } = 60;
|
|
public int MaxConnectionsPerIp { get; set; } = 10;
|
|
public int MaxGlobalConnections { get; set; } = 100;
|
|
public int MaxConcurrentSessionsPerUser { get; set; } = 5;
|
|
public int InviteTokenExpirationHours { get; set; } = 168; // 7 days
|
|
public bool RequireAuthForServerInfo { get; set; } = false;
|
|
public bool EnableCsrfProtection { get; set; } = true;
|
|
public int MaxWebSocketMessageSizeBytes { get; set; } = 1048576; // 1MB
|
|
}
|