Files
lampac/mods/WatchTogether/ModInit.cs
T
prodik b6acef01ef TelegramAuth + TelegramAuthBot + WatchTogether; README/AGENT
- mods/TelegramAuth, mods/TelegramAuthBot, mods/WatchTogether: копии из
  образа с enable: true (правило 1), секции в config/init.conf
- TelegramAuth в API-режиме (enable: false -> accsdb/гейт не поднимается),
  TelegramAuthBot: бот @GatusMonBot, long polling
- WatchTogether: customPlugins watchtogether.js, relay /wt/c/
- README: секция про SQLite/volume (первый запуск), таблица модулей,
  состояние Tg-notify и TelegramAuth, раздел WatchTogether
- AGENT: правило 10 дополнено секретами init.conf, §12 переписан,
  добавлен §13 WatchTogether, список mods/ в §1
- в git bot_token и mutations_api_secret оставлены пустыми (правило 10),
  реальные значения только в рабочем файле на сервере
2026-10-04 15:03:00 +00:00

73 lines
2.2 KiB
C#

using Microsoft.Extensions.DependencyInjection;
using Shared;
using Shared.Models.AppConf;
using Shared.Models.Events;
using Shared.Models.Module;
using Shared.Models.Module.Interfaces;
using System.Collections.Generic;
using Shared.Services;
namespace WatchTogether
{
public class WatchTogetherConf
{
public bool enable { get; set; } = true;
public bool allow_anonymous { get; set; } = true;
public int relay_max_channels { get; set; } = 500;
public int relay_max_clients_per_channel { get; set; } = 32;
public int gc_empty_timeout_minutes { get; set; } = 30;
public int gc_max_lifetime_hours { get; set; } = 12;
public List<WafLimitRootMap> limit_map { get; set; } = new()
{
new("^/watchtogether/", new WafLimitMap { limit = 30, second = 1 }),
new("^/wt/c/", new WafLimitMap { limit = 10, second = 1 })
};
}
/// <summary>
/// WatchTogether: a lampac module that acts as both the lparty relay and a
/// shadow host keeping rooms alive when their creator disconnects.
/// </summary>
public class ModInit : IModuleLoaded, IModuleConfigure
{
public static string modpath;
public static WatchTogetherConf conf;
public void Configure(ConfigureModel app)
{
app.services.AddTransient<Microsoft.AspNetCore.Hosting.IStartupFilter, RelayStartupFilter>();
}
public void Loaded(InitspaceModel baseconf)
{
modpath = baseconf.path;
UpdateConf();
EventListener.UpdateInitFile += UpdateConf;
ShadowHost.Start();
}
public void Dispose()
{
EventListener.UpdateInitFile -= UpdateConf;
ShadowHost.Stop();
}
private static bool isWafInjected = false;
private void UpdateConf()
{
conf = ModuleInvoke.Init("WatchTogether", new WatchTogetherConf());
if (!isWafInjected && conf.limit_map != null)
{
foreach (var m in conf.limit_map)
{
CoreInit.conf.WAF.limit_map.Insert(0, m);
}
isWafInjected = true;
}
}
}
}