new config value: Security_SubMasters

this is a CSV of avatar names that can issue commands like the master
This commit is contained in:
Madpeter 2020-05-18 17:02:38 +01:00
parent 3c83d8afa7
commit ab6b7d7a69
6 changed files with 54 additions and 8 deletions

View file

@ -15,6 +15,18 @@ namespace BetterSecondBotShared.bottypes
{
LastStatusMessage = "No status";
}
protected List<string> SubMasters = new List<string>();
public bool is_avatar_master(string name)
{
if (name == myconfig.Security_MasterUsername)
{
return true;
}
else
{
return SubMasters.Contains(name);
}
}
protected bool killMe;
protected JsonConfig myconfig;
@ -64,6 +76,21 @@ namespace BetterSecondBotShared.bottypes
{
bits.Add("Resident");
myconfig.Security_MasterUsername = String.Join(" ", bits);
}
if (helpers.notempty(myconfig.Security_SubMasters) == true)
{
string[] master_names = myconfig.Security_SubMasters.Split(",", StringSplitOptions.RemoveEmptyEntries);
foreach (string a in master_names)
{
bits = a.Split(' ', StringSplitOptions.RemoveEmptyEntries).ToList();
if (bits.Count == 1)
{
bits.Add("Resident");
}
SubMasters.Add(String.Join(" ", bits));
ConsoleLog.Info("Sub-Master: " + myconfig.Security_MasterUsername);
}
}
ConsoleLog.Info("Build: " + version);
}
@ -159,9 +186,17 @@ namespace BetterSecondBotShared.bottypes
protected virtual void GroupInvite(InstantMessageEventArgs e)
{
string[] stage1 = myconfig.Security_MasterUsername.ToLowerInvariant().Split(' ');
string bad_master_name = String.Join('.', stage1);
if (e.IM.FromAgentName == bad_master_name)
string[] stage1 = e.IM.FromAgentName.ToLowerInvariant().Split('.');
string name = "" + stage1[0].FirstCharToUpper() + "";
if (stage1.Length == 1)
{
name = " Resident";
}
else
{
name = "" + name + " " + stage1[1].FirstCharToUpper() + "";
}
if(is_avatar_master(name) == true)
{
GroupInvitationEventArgs G = new GroupInvitationEventArgs(e.Simulator, e.IM.FromAgentID, e.IM.FromAgentName, e.IM.Message);
Client.Self.GroupInviteRespond(G.AgentID, e.IM.IMSessionID, true);
@ -170,7 +205,7 @@ namespace BetterSecondBotShared.bottypes
}
protected virtual void FriendshipOffer(UUID IMSessionID, string FromAgentName, UUID FromAgentID)
{
if (FromAgentName == myconfig.Security_MasterUsername)
if (is_avatar_master(FromAgentName) == true)
{
Client.Friends.AcceptFriendship(FromAgentID, IMSessionID);
}
@ -178,7 +213,7 @@ namespace BetterSecondBotShared.bottypes
protected virtual void RequestLure(UUID IMSessionID, string FromAgentName, UUID FromAgentID)
{
if (FromAgentName == myconfig.Security_MasterUsername)
if (is_avatar_master(FromAgentName) == true)
{
Client.Self.SendTeleportLure(FromAgentID);
}
@ -196,7 +231,7 @@ namespace BetterSecondBotShared.bottypes
protected virtual void RequestTeleport(UUID IMSessionID, string FromAgentName, UUID FromAgentID)
{
bool allow = false;
if (FromAgentName == myconfig.Security_MasterUsername)
if (is_avatar_master(FromAgentName) == true)
{
allow = true;
}

View file

@ -13,6 +13,7 @@ namespace BetterSecondBotShared.Json
// Security
public string Security_MasterUsername { get; set; }
public string Security_SubMasters { get; set; }
public string Security_SignedCommandkey { get; set; }
public string Security_WebUIKey { get; set; }

View file

@ -26,6 +26,8 @@ namespace BetterSecondBotShared.Json
else if (cmd == "Basic_HomeRegions") return "a CSV of SLURLs that the bot will attempt to return to after avoiding a sim shutdown (In testing)";
// Security
else if (cmd == "Security_MasterUsername") return "The username of the bots owner *you can leave out Resident if you so wish*";
else if (cmd == "Security_SubMasters") return "A CSV of avatar names who can issue commands to the bot";
else if (cmd == "Security_SignedCommandkey") return "Used when sending the bot a HTTP or IM command that has a hash validation";
else if (cmd == "Security_WebUIKey") return "Used with the webUI to login, note: 2FA support is planned soon for this system that will replace this UIkey";
// Settings
@ -82,6 +84,7 @@ namespace BetterSecondBotShared.Json
else if (cmd == "Basic_HomeRegions") return "http://maps.secondlife.com/secondlife/Viserion/50/140/23";
// Security
else if (cmd == "Security_MasterUsername") return "Madpeter Zond";
else if (cmd == "Security_SubMasters") return "Master Zond,Madpeter Zond,Madpeter Zond";
else if (cmd == "Security_SignedCommandkey") return "asdt234t34d3f34f";
else if (cmd == "Security_WebUIKey") return "2135r3y4vw232";
// Settings

View file

@ -32,12 +32,14 @@ ENV Basic_HomeRegions='http://maps.secondlife.com/secondlife/Viserion/50/140/23'
ENV Security_MasterUsername='Madpeter Zond'
ENV Security_SignedCommandkey=''
ENV Security_WebUIKey=''
ENV Security_SubMasters='X X,Y Y,Z Z'
ENV Setting_AllowRLV='false'
ENV Setting_AllowFunds='false'
ENV Setting_LogCommands='true'
ENV Setting_RelayImToAvatarUUID=''
ENV Setting_DefaultSit_UUID=''
ENV Setting_loginURI='secondlife'
ENV DiscordRelay_URL=''
ENV DiscordRelay_GroupUUID=''

View file

@ -104,9 +104,12 @@ namespace BSB.bottypes
{
CoreCommandLib(sender_uuid, false, bits.ElementAt(0), bits.ElementAt(1), signing_code, arg_signed_with);
}
else if (myconfig.Security_MasterUsername == sender_name)
else
{
CoreCommandLib(sender_uuid, true, bits.ElementAt(0), bits.ElementAt(1), "", arg_signed_with);
if (is_avatar_master(sender_name) == true)
{
CoreCommandLib(sender_uuid, true, bits.ElementAt(0), bits.ElementAt(1), "", arg_signed_with);
}
}
}
}

View file

@ -30,6 +30,7 @@ ENV Basic_BotPassword=''
ENV Basic_HomeRegions='http://maps.secondlife.com/secondlife/Viserion/50/140/23'
ENV Security_MasterUsername='Madpeter Zond'
ENV Security_SubMasters='X X,Y Y,Z Z'
ENV Security_SignedCommandkey=''
ENV Security_WebUIKey=''
@ -38,6 +39,7 @@ ENV Setting_AllowFunds='false'
ENV Setting_LogCommands='true'
ENV Setting_RelayImToAvatarUUID=''
ENV Setting_DefaultSit_UUID=''
ENV Setting_loginURI='secondlife'
ENV DiscordRelay_URL=''
ENV DiscordRelay_GroupUUID=''