@@ -10,5 +10,6 @@
|
|||||||
<cc:CommandButton Name="SetLoocButton" Command="setlooc" Text="{Loc server-looc-toggle}" ToggleMode="True" />
|
<cc:CommandButton Name="SetLoocButton" Command="setlooc" Text="{Loc server-looc-toggle}" ToggleMode="True" />
|
||||||
<cc:CommandButton Name="SetPanicbunkerButton" Command="panicbunker" Text="{Loc server-panicbunker-toggle}" ToggleMode="True" />
|
<cc:CommandButton Name="SetPanicbunkerButton" Command="panicbunker" Text="{Loc server-panicbunker-toggle}" ToggleMode="True" />
|
||||||
<cc:CommandButton Name="SetStalinBunker" Command="stalinbunker" Text="{Loc server-stalin-toggle}" ToggleMode="True" />
|
<cc:CommandButton Name="SetStalinBunker" Command="stalinbunker" Text="{Loc server-stalin-toggle}" ToggleMode="True" />
|
||||||
|
<cc:CommandButton Name="SetSalus" Command="salus" Text="{Loc vpn-salus-button}"></cc:CommandButton>
|
||||||
</GridContainer>
|
</GridContainer>
|
||||||
</Control>
|
</Control>
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ namespace Content.Server.Entry
|
|||||||
IoCManager.Resolve<TTSManager>().Initialize();
|
IoCManager.Resolve<TTSManager>().Initialize();
|
||||||
IoCManager.Resolve<StalinManager>().Initialize();
|
IoCManager.Resolve<StalinManager>().Initialize();
|
||||||
IoCManager.Resolve<ServerJukeboxSongsSyncManager>().Initialize();
|
IoCManager.Resolve<ServerJukeboxSongsSyncManager>().Initialize();
|
||||||
|
IoCManager.Resolve<SalusManager>().Initialize();
|
||||||
//WD-EDIT
|
//WD-EDIT
|
||||||
|
|
||||||
_voteManager.Initialize();
|
_voteManager.Initialize();
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ using Content.Server.ServerUpdates;
|
|||||||
using Content.Server.Voting.Managers;
|
using Content.Server.Voting.Managers;
|
||||||
using Content.Server.Worldgen.Tools;
|
using Content.Server.Worldgen.Tools;
|
||||||
using Content.Server.UtkaIntegration;
|
using Content.Server.UtkaIntegration;
|
||||||
|
using Content.Server.White;
|
||||||
using Content.Server.White.JoinQueue;
|
using Content.Server.White.JoinQueue;
|
||||||
using Content.Server.White.Jukebox;
|
using Content.Server.White.Jukebox;
|
||||||
using Content.Server.White.Sponsors;
|
using Content.Server.White.Sponsors;
|
||||||
@@ -73,6 +74,7 @@ namespace Content.Server.IoC
|
|||||||
IoCManager.Register<TTSManager>();
|
IoCManager.Register<TTSManager>();
|
||||||
IoCManager.Register<StalinManager>();
|
IoCManager.Register<StalinManager>();
|
||||||
IoCManager.Register<ServerJukeboxSongsSyncManager>();
|
IoCManager.Register<ServerJukeboxSongsSyncManager>();
|
||||||
|
IoCManager.Register<SalusManager>();
|
||||||
// WD-EDIT
|
// WD-EDIT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
48
Content.Server/White/Salus/SalusCommand.cs
Normal file
48
Content.Server/White/Salus/SalusCommand.cs
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
using Content.Server.Administration;
|
||||||
|
using Content.Server.Chat.Managers;
|
||||||
|
using Content.Shared.Administration;
|
||||||
|
using Content.Shared.White;
|
||||||
|
using Robust.Shared.Configuration;
|
||||||
|
using Robust.Shared.Console;
|
||||||
|
|
||||||
|
namespace Content.Server.White;
|
||||||
|
|
||||||
|
[AdminCommand(AdminFlags.Admin)]
|
||||||
|
public sealed class SalusCommand : IConsoleCommand
|
||||||
|
{
|
||||||
|
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||||
|
|
||||||
|
public string Command => "salus";
|
||||||
|
public string Description => "Enables SALUS system (Autokick vpn users)";
|
||||||
|
public string Help => "salus <bool> or salus for toggle on/off";
|
||||||
|
|
||||||
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||||
|
{
|
||||||
|
IoCManager.InjectDependencies(this);
|
||||||
|
|
||||||
|
if (args.Length > 1)
|
||||||
|
{
|
||||||
|
shell.WriteError(Loc.GetString("shell-need-between-arguments",("lower", 0), ("upper", 1)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var enabled = _cfg.GetCVar(WhiteCVars.AutoKickVpnUsers);
|
||||||
|
|
||||||
|
if (args.Length == 0)
|
||||||
|
{
|
||||||
|
enabled = !enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.Length == 1 && !bool.TryParse(args[0], out enabled))
|
||||||
|
{
|
||||||
|
shell.WriteError(Loc.GetString("shell-argument-must-be-boolean"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_cfg.SetCVar(WhiteCVars.AutoKickVpnUsers, enabled);
|
||||||
|
|
||||||
|
var announce = Loc.GetString("vpn-salus-status", ("enabled", $"{enabled}"));
|
||||||
|
|
||||||
|
IoCManager.Resolve<IChatManager>().DispatchServerAnnouncement(announce, Color.Red);
|
||||||
|
}
|
||||||
|
}
|
||||||
60
Content.Server/White/Salus/SalusManager.cs
Normal file
60
Content.Server/White/Salus/SalusManager.cs
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
using System.Net;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Content.Server.Administration.Logs;
|
||||||
|
using Content.Shared.Database;
|
||||||
|
using Content.Shared.White;
|
||||||
|
using Robust.Shared.Configuration;
|
||||||
|
using Robust.Shared.Network;
|
||||||
|
|
||||||
|
namespace Content.Server.White;
|
||||||
|
|
||||||
|
public sealed class SalusManager
|
||||||
|
{
|
||||||
|
[Dependency] private readonly IServerNetManager _netMgr = default!;
|
||||||
|
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||||
|
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||||
|
|
||||||
|
private readonly HttpClient _httpClient = new();
|
||||||
|
|
||||||
|
private bool _autoKickVpnUsers;
|
||||||
|
private string _salusApiLink = default!;
|
||||||
|
|
||||||
|
public void Initialize()
|
||||||
|
{
|
||||||
|
_httpClient.Timeout = TimeSpan.FromSeconds(2.5);
|
||||||
|
_cfg.OnValueChanged(WhiteCVars.AutoKickVpnUsers, newValue => _autoKickVpnUsers = newValue, true);
|
||||||
|
_cfg.OnValueChanged(WhiteCVars.SalusApiLink, newValue => _salusApiLink = newValue, true);
|
||||||
|
|
||||||
|
_netMgr.Connecting += OnConnecting;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnConnecting(NetConnectingArgs arg)
|
||||||
|
{
|
||||||
|
var ip = arg.IP.Address.ToString();
|
||||||
|
bool usingVpn;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var response = await _httpClient.GetAsync($"{_salusApiLink}{ip}");
|
||||||
|
if (response.StatusCode != HttpStatusCode.OK) return;
|
||||||
|
usingVpn = bool.Parse(await response.Content.ReadAsStringAsync());
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (usingVpn)
|
||||||
|
{
|
||||||
|
var logMessage = Loc.GetString("vpn-user-detected", ("user", arg.UserName), ("ip", ip));
|
||||||
|
_adminLogger.Add(LogType.Unknown, LogImpact.Extreme, $"{logMessage}");
|
||||||
|
|
||||||
|
if (_autoKickVpnUsers)
|
||||||
|
{
|
||||||
|
arg.Deny(Loc.GetString("vpn-user-disconnect-message"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -325,4 +325,9 @@ public sealed class WhiteCVars
|
|||||||
public static readonly CVarDef<float> DamageGetModifier =
|
public static readonly CVarDef<float> DamageGetModifier =
|
||||||
CVarDef.Create("damage.get_modifier", 1.0f, CVar.REPLICATED);
|
CVarDef.Create("damage.get_modifier", 1.0f, CVar.REPLICATED);
|
||||||
|
|
||||||
|
public static readonly CVarDef<bool> AutoKickVpnUsers =
|
||||||
|
CVarDef.Create("white.auto_kick_vpn_users", false, CVar.SERVERONLY);
|
||||||
|
|
||||||
|
public static readonly CVarDef<string> SalusApiLink = CVarDef.Create("white.salus_api_link", "http://localhost:7100/vpnchecker?address=", CVar.SERVERONLY | CVar.CONFIDENTIAL);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
9
Resources/Locale/en-US/white/salus.ftl
Normal file
9
Resources/Locale/en-US/white/salus.ftl
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
vpn-user-detected = Attention, a prankster came in under the vpn { $user }. IP: { $ip }
|
||||||
|
vpn-user-disconnect-message = It is forbidden to play through VPN on the server.
|
||||||
|
vpn-salus-button = Toggle SALUS
|
||||||
|
vpn-salus-status =
|
||||||
|
{ $enabled ->
|
||||||
|
[True] Guests hiding their faces behind masks are not allowed to enter
|
||||||
|
[False] Guests hiding their face behind masks are allowed to enter.
|
||||||
|
*[other] Яниме
|
||||||
|
}
|
||||||
9
Resources/Locale/ru-RU/white/salus.ftl
Normal file
9
Resources/Locale/ru-RU/white/salus.ftl
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
vpn-user-detected = Внимание, пытается зайти приколист под впном { $user }. Айпи: { $ip }
|
||||||
|
vpn-user-disconnect-message = На сервере запрещена игра через ВПН.
|
||||||
|
vpn-salus-button = Переключить SALUS
|
||||||
|
vpn-salus-status =
|
||||||
|
{ $enabled ->
|
||||||
|
[True] Гостям скрывающим свое лицо за масками вход запрещен.
|
||||||
|
[False] Гостям скрывающим свое лицо за масками вход разрешен.
|
||||||
|
*[other] Яниме
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user