mirror of
https://github.com/space-wizards/RobustToolboxTemplate.git
synced 2026-02-10 16:24:49 -05:00
Add a debug/example congroup so server commands and scripting works.
This commit is contained in:
parent
1fd897e2a4
commit
920f440530
2 changed files with 51 additions and 0 deletions
50
Content.Server/LocalHostConGroup.cs
Normal file
50
Content.Server/LocalHostConGroup.cs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
using System.Net;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.Console;
|
||||
using Robust.Server.Player;
|
||||
|
||||
namespace Content.Server;
|
||||
|
||||
/// <summary>
|
||||
/// Debug/example ConGroup controller implementation that gives any client connected through localhost every permission.
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
public sealed class LocalHostConGroup : IConGroupControllerImplementation, IPostInjectInit {
|
||||
public bool CanCommand(IPlayerSession session, string cmdName) {
|
||||
return IsLocal(session);
|
||||
}
|
||||
|
||||
public bool CanViewVar(IPlayerSession session) {
|
||||
return IsLocal(session);
|
||||
}
|
||||
|
||||
public bool CanAdminPlace(IPlayerSession session) {
|
||||
return IsLocal(session);
|
||||
}
|
||||
|
||||
public bool CanScript(IPlayerSession session) {
|
||||
return IsLocal(session);
|
||||
}
|
||||
|
||||
public bool CanAdminMenu(IPlayerSession session) {
|
||||
return IsLocal(session);
|
||||
}
|
||||
|
||||
public bool CanAdminReloadPrototypes(IPlayerSession session) {
|
||||
return IsLocal(session);
|
||||
}
|
||||
|
||||
private static bool IsLocal(IPlayerSession player) {
|
||||
var ep = player.ConnectedClient.RemoteEndPoint;
|
||||
var addr = ep.Address;
|
||||
if (addr.IsIPv4MappedToIPv6) {
|
||||
addr = addr.MapToIPv4();
|
||||
}
|
||||
|
||||
return Equals(addr, IPAddress.Loopback) || Equals(addr, IPAddress.IPv6Loopback);
|
||||
}
|
||||
|
||||
void IPostInjectInit.PostInject() {
|
||||
IoCManager.Resolve<IConGroupController>().Implementation = this;
|
||||
}
|
||||
}
|
||||
|
|
@ -5,5 +5,6 @@ internal static class ServerContentIoC
|
|||
public static void Register()
|
||||
{
|
||||
// DEVNOTE: IoCManager registrations for the server go here and only here.
|
||||
IoCManager.Register<LocalHostConGroup>();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue