Changeset 487 for TFP-WebServer/WebServer/src
- Timestamp:
- Jun 17, 2024, 5:25:43 PM (5 months ago)
- Location:
- TFP-WebServer/WebServer/src
- Files:
-
- 1 added
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
TFP-WebServer/WebServer/src/Commands/EnableOpenIDDebug.cs
r405 r487 5 5 [UsedImplicitly] 6 6 public class EnableOpenIDDebug : ConsoleCmdAbstract { 7 p rotectedoverride string getDescription () {7 public override string getDescription () { 8 8 return "enable/disable OpenID debugging"; 9 9 } 10 10 11 p rotectedoverride string[] getCommands () {11 public override string[] getCommands () { 12 12 return new[] {"openiddebug"}; 13 13 } -
TFP-WebServer/WebServer/src/Commands/WebPermissionsCmd.cs
r435 r487 6 6 [UsedImplicitly] 7 7 public class WebPermissionsCmd : ConsoleCmdAbstract { 8 p rotectedoverride string[] getCommands () {8 public override string[] getCommands () { 9 9 return new[] {"webpermission"}; 10 10 } 11 11 12 p rotectedoverride string getDescription () {12 public override string getDescription () { 13 13 return "Manage web permission levels"; 14 14 } 15 15 16 p rotectedoverride string getHelp () {16 public override string getHelp () { 17 17 return @" 18 18 |Set/get permission levels required to access a given web functionality. Default … … 84 84 if (permissionLevelString.EqualsCaseInsensitive (AdminWebModules.MethodLevelInheritKeyword)) { 85 85 if (isGlobal) { 86 SdtdConsole.Instance.Output ( $"Permission level can not use the 'inherit' keyword with the 'global' method keyword.");86 SdtdConsole.Instance.Output ("Permission level can not use the 'inherit' keyword with the 'global' method keyword."); 87 87 return; 88 88 } … … 97 97 } 98 98 99 module.IsDefault = false;100 99 if (isGlobal) { 101 module .LevelGlobal = level;100 module = module.SetLevelGlobal (level); 102 101 } else { 103 module .LevelPerMethod [(int)method] = level;102 module = module.SetLevelForMethod (method, level); 104 103 } 105 104 -
TFP-WebServer/WebServer/src/Commands/WebTokens.cs
r405 r487 9 9 private static readonly Regex validNameTokenMatcher = new Regex (@"^\w+$"); 10 10 11 p rotectedoverride string[] getCommands () {11 public override string[] getCommands () { 12 12 return new[] {"webtokens"}; 13 13 } 14 14 15 p rotectedoverride string getDescription () {15 public override string getDescription () { 16 16 return "Manage web tokens"; 17 17 } 18 18 19 p rotectedoverride string getHelp () {19 public override string getHelp () { 20 20 return "Set/get webtoken permission levels. A level of 0 is maximum permission.\n" + 21 21 "Usage:\n" + -
TFP-WebServer/WebServer/src/FileCache/InvalidateCachesCmd.cs
r405 r487 5 5 [UsedImplicitly] 6 6 public class InvalidateCachesCmd : ConsoleCmdAbstract { 7 p rotectedoverride string[] getCommands () {7 public override string[] getCommands () { 8 8 return new[] {"invalidatecaches"}; 9 9 } 10 10 11 p rotectedoverride string getDescription () {11 public override string getDescription () { 12 12 return "Invalidate contents of web file caches"; 13 13 } 14 14 15 p rotectedoverride string getHelp () {15 public override string getHelp () { 16 16 return "TODO"; 17 17 } -
TFP-WebServer/WebServer/src/FileCache/SimpleCache.cs
r402 r487 11 11 try { 12 12 lock (fileCache) { 13 if (fileCache. ContainsKey (_filename)) {14 return fileCache [_filename];13 if (fileCache.TryGetValue(_filename, out byte[] content)) { 14 return content; 15 15 } 16 16 … … 19 19 } 20 20 21 fileCache.Add (_filename, File.ReadAllBytes (_filename)); 21 byte[] newContent = File.ReadAllBytes (_filename); 22 fileCache.Add (_filename, newContent); 22 23 23 return fileCache [_filename];24 return newContent; 24 25 } 25 26 } catch (Exception e) { -
TFP-WebServer/WebServer/src/Permissions/AdminApiTokens.cs
r474 r487 19 19 } 20 20 21 p rotectedoverride void ParseElement (XmlElement _childElement) {21 public override void ParseElement (XmlElement _childElement) { 22 22 if (ApiToken.TryParse (_childElement, out ApiToken apiToken)) { 23 23 tokens [apiToken.Name] = apiToken; -
TFP-WebServer/WebServer/src/Permissions/AdminWebModules.cs
r474 r487 1 using System; 1 2 using System.Collections.Generic; 2 3 using System.Xml; 4 using JetBrains.Annotations; 5 using UnityEngine; 3 6 4 7 namespace Webserver.Permissions { … … 16 19 17 20 public override void Clear () { 21 allModulesList.Clear (); 18 22 modules.Clear (); 19 23 } 20 24 21 protected override void ParseElement (XmlElement _childElement) { 22 if (WebModule.TryParse (_childElement, out WebModule webModule)) { 23 modules [webModule.Name] = webModule; 24 } 25 public override void ParseElement (XmlElement _childElement) { 26 allModulesList.Clear (); 27 28 if (!WebModule.TryParse (_childElement, out WebModule webModule)) { 29 return; 30 } 31 32 if (knownModules.TryGetValue (webModule.Name, out WebModule knownModule)) { 33 webModule = webModule.FixPermissionLevelsFromKnownModule (knownModule); 34 } 35 36 modules [webModule.Name] = webModule; 25 37 } 26 38 … … 43 55 lock (Parent) { 44 56 allModulesList.Clear (); 45 57 46 58 modules [_module.Name] = _module; 47 59 Parent.Save (); … … 80 92 #endregion 81 93 82 public struct WebModule {83 public string Name;84 public int LevelGlobal;85 public int[] LevelPerMethod;86 public bool IsDefault;87 88 public WebModule (string _name, int _level, bool _isDefault = false) {94 public readonly struct WebModule { 95 public readonly string Name; 96 public readonly int LevelGlobal; 97 public readonly int[] LevelPerMethod; 98 public readonly bool IsDefault; 99 100 public WebModule (string _name, int _level, bool _isDefault) { 89 101 LevelPerMethod = null; 90 102 … … 94 106 } 95 107 96 public WebModule (string _name, int _levelGlobal, int[] _levelPerMethod, bool _isDefault = false) {97 if (_levelPerMethod == null ||_levelPerMethod.Length != (int)ERequestMethod.Count) {108 public WebModule (string _name, int _levelGlobal, int[] _levelPerMethod, bool _isDefault) { 109 if (_levelPerMethod != null && _levelPerMethod.Length != (int)ERequestMethod.Count) { 98 110 LevelPerMethod = createDefaultPerMethodArray (); 99 111 … … 205 217 } 206 218 207 _result = perMethodLevels != null ? new WebModule (name, permissionLevel, perMethodLevels) : new WebModule (name, permissionLevel);219 _result = new WebModule (name, permissionLevel, perMethodLevels, false); 208 220 209 221 return true; 210 222 } 211 223 224 [MustUseReturnValue] 225 public WebModule SetLevelGlobal (int _level) { 226 int[] perMethodClone = LevelPerMethod == null ? null : new int[LevelPerMethod.Length]; 227 if (perMethodClone != null) { 228 Array.Copy (LevelPerMethod, perMethodClone, perMethodClone.Length); 229 } 230 231 return new WebModule (Name, _level, perMethodClone, false); 232 } 233 234 [MustUseReturnValue] 235 public WebModule SetLevelForMethod (ERequestMethod _method, int _level) { 236 int[] perMethodClone = createDefaultPerMethodArray (); 237 if (LevelPerMethod != null) { 238 Array.Copy (LevelPerMethod, perMethodClone, perMethodClone.Length); 239 } 240 241 perMethodClone[(int)_method] = _level; 242 243 return new WebModule (Name, LevelGlobal, perMethodClone, false); 244 } 245 212 246 private static int[] createDefaultPerMethodArray () { 213 247 int[] result = new int[(int)ERequestMethod.Count]; … … 219 253 return result; 220 254 } 255 256 [MustUseReturnValue] 257 public WebModule FixPermissionLevelsFromKnownModule (WebModule _knownModule) { 258 if (_knownModule.LevelPerMethod == null) { 259 if (LevelPerMethod != null) { 260 return new WebModule (Name, LevelGlobal, false); 261 } 262 return this; 263 } 264 265 WebModule result = this; 266 for (int i = 0; i < _knownModule.LevelPerMethod.Length; i++) { 267 if (result.LevelPerMethod == null || result.LevelPerMethod[i] == MethodLevelNotSupported) { 268 result = result.SetLevelForMethod ((ERequestMethod)i, _knownModule.LevelPerMethod[i]); 269 } 270 } 271 272 return result; 273 } 221 274 } 222 275 … … 253 306 254 307 public void AddKnownModule (WebModule _module) { 308 if (!_module.IsDefault) { 309 Log.Warning ($"Call to AddKnownModule with IsDefault==false! From:\n{StackTraceUtility.ExtractStackTrace()}"); 310 } 311 255 312 if (string.IsNullOrEmpty (_module.Name)) { 256 313 return; 257 314 } 258 315 259 _module.IsDefault = true;260 261 316 lock (Parent) { 262 317 allModulesList.Clear (); 263 318 knownModules [_module.Name] = _module; 319 320 if (modules.TryGetValue (_module.Name, out WebModule overrideModule)) { 321 overrideModule = overrideModule.FixPermissionLevelsFromKnownModule (_module); 322 modules[_module.Name] = overrideModule; 323 } 264 324 } 265 325 } -
TFP-WebServer/WebServer/src/Permissions/AdminWebUsers.cs
r485 r487 21 21 } 22 22 23 p rotectedoverride void ParseElement (XmlElement _childElement) {23 public override void ParseElement (XmlElement _childElement) { 24 24 if (WebUser.TryParse (_childElement, out WebUser webUser)) { 25 25 users [webUser.Name] = webUser; -
TFP-WebServer/WebServer/src/SSE/AbsEvent.cs
r409 r487 1 1 using System; 2 2 using System.Collections.Generic; 3 using System.IO;4 using System.Net.Sockets;5 3 using System.Text; 6 4 using Webserver.UrlHandlers; 7 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse;8 5 9 6 namespace Webserver.SSE { 10 7 public abstract class AbsEvent { 11 8 private const int encodingBufferSize = 1024 * 1024; 12 private const int keepAliveIntervalSeconds = 10;13 private static readonly byte[] keepAliveData = Encoding.UTF8.GetBytes (": KeepAlive\n\n");14 9 15 10 private readonly SseHandler parent; … … 18 13 private readonly byte[] encodingBuffer; 19 14 private readonly StringBuilder stringBuilder = new StringBuilder (); 20 private DateTime lastMessageSent;21 15 22 private readonly List< HttpListenerResponse> openStreams = new List<HttpListenerResponse> ();16 private readonly List<SseClient> openClients = new List<SseClient> (); 23 17 24 18 private readonly BlockingQueue<(string _eventName, string _data)> sendQueue = … … 37 31 } 38 32 39 public void AddListener ( HttpListenerResponse _resp) {33 public void AddListener (SseClient _client) { 40 34 totalOpened++; 41 35 currentlyOpen++; 42 36 43 open Streams.Add (_resp);37 openClients.Add (_client); 44 38 } 45 39 … … 50 44 51 45 public void ProcessSendQueue () { 52 bool dataSent = false;53 54 46 while (sendQueue.HasData ()) { 55 47 (string eventName, string data) = sendQueue.Dequeue (); … … 81 73 } 82 74 83 dataSent = true;84 85 75 sendBufToListeners (buf, bytesToSend); 86 }87 88 DateTime now = DateTime.Now;89 if (dataSent) {90 lastMessageSent = now;91 } else if ((now - lastMessageSent).TotalSeconds >= keepAliveIntervalSeconds) {92 sendBufToListeners (keepAliveData, keepAliveData.Length);93 lastMessageSent = now;94 76 } 95 77 } 96 78 97 79 private void sendBufToListeners (byte[] _bytes, int _bytesToSend) { 98 for (int i = openStreams.Count - 1; i >= 0; i--) { 99 HttpListenerResponse resp = openStreams [i]; 100 try { 101 if (resp.OutputStream.CanWrite) { 102 resp.OutputStream.Write (_bytes, 0, _bytesToSend); 103 resp.OutputStream.Flush (); 104 } else { 105 currentlyOpen--; 106 totalClosed++; 80 for (int i = openClients.Count - 1; i >= 0; i--) { 81 ESseClientWriteResult writeResult = openClients [i].Write (_bytes, _bytesToSend); 82 if (writeResult == ESseClientWriteResult.Ok) { 83 continue; 84 } 107 85 108 logError ("Can not write to endpoint, closing", true); 109 openStreams.RemoveAt (i); 110 resp.Close (); 111 } 112 } catch (IOException e) { 113 currentlyOpen--; 114 totalClosed++; 86 currentlyOpen--; 87 totalClosed++; 115 88 116 openStreams.RemoveAt (i); 117 118 if (e.InnerException is SocketException se) { 119 if (se.SocketErrorCode != SocketError.ConnectionAborted && se.SocketErrorCode != SocketError.Shutdown) { 120 logError ($"SocketError ({se.SocketErrorCode.ToStringCached ()}) while trying to write", true); 121 } 122 } else { 123 logError ("IOException while trying to write:", true); 124 Log.Exception (e); 125 } 126 } catch (Exception e) { 127 currentlyOpen--; 128 totalClosed++; 129 130 openStreams.RemoveAt (i); 131 logError ("Exception while trying to write:", true); 132 Log.Exception (e); 133 resp.Close (); 89 if (writeResult == ESseClientWriteResult.Error) { 90 logError ("Can not write to endpoint, closing", true); 134 91 } 135 92 } … … 143 100 144 101 public virtual int DefaultPermissionLevel () => 0; 102 103 public void ClientClosed (SseClient _client) { 104 openClients.Remove (_client); 105 } 145 106 } 146 107 } -
TFP-WebServer/WebServer/src/UrlHandlers/ApiHandler.cs
r460 r487 30 30 31 31 private void apiFoundCallback (Type _type) { 32 ConstructorInfo ctor = _type.GetConstructor (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, (Binder)null,33 apiWithParentCtorTypes, (ParameterModifier[])null);32 ConstructorInfo ctor = _type.GetConstructor (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, 33 apiWithParentCtorTypes, null); 34 34 if (ctor != null) { 35 35 AbsWebAPI apiInstance = (AbsWebAPI)ctor.Invoke (apiWithParentCtorArgs); … … 38 38 } 39 39 40 ctor = _type.GetConstructor (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, (Binder)null,41 apiEmptyCtorTypes, (ParameterModifier[])null);40 ctor = _type.GetConstructor (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, 41 apiEmptyCtorTypes, null); 42 42 if (ctor != null) { 43 43 AbsWebAPI apiInstance = (AbsWebAPI)ctor.Invoke (apiEmptyCtorArgs); -
TFP-WebServer/WebServer/src/UrlHandlers/SessionHandler.cs
r457 r487 20 20 private const string userPassLoginUrl = "login"; 21 21 public const string userPassLoginName = "User/pass"; 22 private const string userPassErrorPage = "UserPassLoginFailed";23 22 24 23 public SessionHandler () : base (null) { -
TFP-WebServer/WebServer/src/UrlHandlers/SseHandler.cs
r426 r487 20 20 private static readonly Type[] ctorTypes = { typeof (SseHandler) }; 21 21 private static readonly object[] ctorParams = new object[1]; 22 23 private readonly List<SseClient> clients = new List<SseClient>(); 22 24 23 25 public SseHandler (string _moduleName = null) : base (_moduleName) { … … 57 59 58 60 public override void HandleRequest (RequestContext _context) { 59 string eventName = _context.RequestPath.Remove (0, urlBasePath.Length); 60 61 if (!events.TryGetValue (eventName, out AbsEvent eventInstance)) { 62 Log.Warning ($"[Web] [SSE] In {nameof (SseHandler)}.HandleRequest(): No handler found for event \"{eventName}\""); 63 _context.Response.StatusCode = (int)HttpStatusCode.NotFound; 61 string eventNames = _context.QueryParameters ["events"]; 62 if (string.IsNullOrEmpty (eventNames)) { 63 Log.Warning ($"[Web] [SSE] In {nameof (SseHandler)}.HandleRequest(): No 'events' query parameter given"); 64 _context.Response.StatusCode = (int)HttpStatusCode.BadRequest; 64 65 return; 65 66 } 66 67 67 if (!IsAuthorizedForEvent (eventName, _context.PermissionLevel)) { 68 SseClient client; 69 try { 70 client = new SseClient(this, _context.Response); 71 } catch (Exception e) { 72 Log.Error ($"[Web] [SSE] In {nameof (SseHandler)}.HandleRequest(): Could not create client:"); 73 Log.Exception (e); 74 _context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; 75 return; 76 } 77 78 int eventsFound = 0; 79 int eventsAuthorized = 0; 80 int eventsRegistered = 0; 81 foreach (string eventName in eventNames.Split (',', StringSplitOptions.RemoveEmptyEntries)) { 82 if (!events.TryGetValue (eventName, out AbsEvent eventInstance)) { 83 Log.Warning ($"[Web] [SSE] In {nameof (SseHandler)}.HandleRequest(): No handler found for event \"{eventName}\""); 84 continue; 85 } 86 87 eventsFound++; 88 89 if (!IsAuthorizedForEvent (eventName, _context.PermissionLevel)) { 90 continue; 91 } 92 93 eventsAuthorized++; 94 95 try 96 { 97 eventInstance.AddListener (client); 98 } catch (Exception e) { 99 Log.Error ($"[Web] [SSE] In {nameof (SseHandler)}.HandleRequest(): Handler {eventInstance.Name} threw an exception:"); 100 Log.Exception (e); 101 _context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; 102 } 103 104 eventsRegistered++; 105 } 106 107 if (eventsFound == 0) { 108 _context.Response.StatusCode = (int)HttpStatusCode.BadRequest; 109 _context.Response.Close (); 110 return; 111 } 112 113 if (eventsAuthorized == 0) { 68 114 _context.Response.StatusCode = (int)HttpStatusCode.Forbidden; 69 115 if (_context.Connection != null) { … … 71 117 } 72 118 119 _context.Response.Close (); 73 120 return; 74 121 } 75 122 76 try { 77 eventInstance.AddListener (_context.Response); 78 79 // Keep the request open 80 _context.Response.SendChunked = true; 81 82 _context.Response.AddHeader ("Content-Type", "text/event-stream"); 83 _context.Response.OutputStream.Flush (); 84 } catch (Exception e) { 85 Log.Error ($"[Web] [SSE] In {nameof (SseHandler)}.HandleRequest(): Handler {eventInstance.Name} threw an exception:"); 86 Log.Exception (e); 87 _context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; 88 } 123 clients.Add (client); 89 124 } 90 125 … … 105 140 } 106 141 } 142 143 for (int index = clients.Count - 1; index >= 0; index--) { 144 clients[index].HandleKeepAlive (); 145 } 107 146 } 108 147 } … … 111 150 evSendRequest.Set (); 112 151 } 152 153 public void ClientClosed (SseClient _client) { 154 foreach ((string eventName, AbsEvent eventHandler) in events) { 155 try { 156 eventHandler.ClientClosed (_client); 157 } catch (Exception e) { 158 Log.Error($"[Web] [SSE] '{eventName}': Error closing client"); 159 Log.Exception(e); 160 } 161 } 162 163 clients.Remove (_client); 164 } 113 165 } 114 166 } -
TFP-WebServer/WebServer/src/Web.cs
r474 r487 172 172 } 173 173 174 #if ENABLE_PROFILER 174 175 private readonly UnityEngine.Profiling.CustomSampler getContextSampler = UnityEngine.Profiling.CustomSampler.Create ("GetCtx"); 176 #endif 175 177 private readonly UnityEngine.Profiling.CustomSampler authSampler = UnityEngine.Profiling.CustomSampler.Create ("Auth"); 176 178 private readonly UnityEngine.Profiling.CustomSampler cookieSampler = UnityEngine.Profiling.CustomSampler.Create ("ConCookie"); … … 191 193 #else 192 194 HttpListenerContext ctx = listenerInstance.EndGetContext (_result); 193 listenerInstance.BeginGetContext ( HandleRequest, listenerInstance);195 listenerInstance.BeginGetContext (handleRequestDelegate, listenerInstance); 194 196 #endif 195 197 try { -
TFP-WebServer/WebServer/src/WebAPI/APIs/Permissions/CommandPermissions.cs
r486 r487 10 10 private const string propertyCommand = "command"; 11 11 private const string propertyPermissionLevel = "permissionLevel"; 12 private const string propertyIsDefault = "default"; 12 13 13 14 private static readonly byte[] jsonKeyCommand = JsonWriter.GetEncodedPropertyNameWithBeginObject (propertyCommand); 14 15 private static readonly byte[] jsonKeyPermissionLevel = JsonWriter.GetEncodedPropertyNameWithPrefixValueSeparator (propertyPermissionLevel); 16 private static readonly byte[] jsonKeyIsDefault = JsonWriter.GetEncodedPropertyNameWithPrefixValueSeparator (propertyIsDefault); 15 17 16 18 private static AdminCommands CommandsInstance => GameManager.Instance.adminTools.Commands; … … 26 28 27 29 bool first = true; 28 foreach ((_, AdminCommands.CommandPermission commandPermission) in CommandsInstance.GetCommands ()) { 30 31 foreach (IConsoleCommand command in SdtdConsole.Instance.GetCommands ()) { 29 32 if (!first) { 30 33 writer.WriteValueSeparator (); … … 33 36 first = false; 34 37 35 writeCommandJson (ref writer, commandPermission); 38 AdminCommands.CommandPermission commandPermission = CommandsInstance.GetAdminToolsCommandPermission (command.GetCommands()); 39 bool isDefault = commandPermission.PermissionLevel == command.DefaultPermissionLevel; 40 if (commandPermission.Command == "") { 41 commandPermission = 42 new AdminCommands.CommandPermission (command.GetCommands ()[0], commandPermission.PermissionLevel); 43 } 44 45 writeCommandJson (ref writer, commandPermission, isDefault); 36 46 } 37 47 38 48 writer.WriteEndArray (); 39 49 … … 46 56 } 47 57 48 private void writeCommandJson (ref JsonWriter _writer, AdminCommands.CommandPermission _commandPermission) {58 private void writeCommandJson(ref JsonWriter _writer, AdminCommands.CommandPermission _commandPermission, bool _isDefault) { 49 59 _writer.WriteRaw (jsonKeyCommand); 50 60 _writer.WriteString (_commandPermission.Command); 51 61 _writer.WriteRaw (jsonKeyPermissionLevel); 52 62 _writer.WriteInt32 (_commandPermission.PermissionLevel); 63 _writer.WriteRaw (jsonKeyIsDefault); 64 _writer.WriteBoolean (_isDefault); 53 65 _writer.WriteEndObject (); 54 66 } -
TFP-WebServer/WebServer/src/WebAPI/APIs/Permissions/CommandPermissions.openapi.yaml
r486 r487 21 21 type: integer 22 22 description: Permission level of the command 23 default: 24 type: boolean 25 description: Whether the permission level is the default value for the command 23 26 required: 24 27 - command 25 28 - permissionLevel 29 - default 26 30 27 31 CommandPermissionList: -
TFP-WebServer/WebServer/src/WebAPI/APIs/Permissions/WebModules.cs
r486 r487 124 124 } 125 125 126 module .LevelGlobal = permissionLevelGlobal;126 module = module.SetLevelGlobal (permissionLevelGlobal); 127 127 } 128 128 … … 165 165 } 166 166 167 module .LevelPerMethod [(int)method] = permissionLevel;167 module = module.SetLevelForMethod (method, permissionLevel); 168 168 } 169 169 } 170 170 171 module.IsDefault = false;172 171 ModulesInstance.AddModule (module); 173 172 -
TFP-WebServer/WebServer/src/WebAPI/APIs/WorldState/Player.cs
r463 r487 92 92 ClientInfo ci = ConnectionManager.Instance.Clients.ForUserId (_nativeUserId); 93 93 if (ci == null) { 94 Log.Warning ( $"[Web] Player.GET: ClientInfo null");94 Log.Warning ("[Web] Player.GET: ClientInfo null"); 95 95 return; 96 96 } … … 100 100 101 101 if (entity == null) { 102 Log.Warning ( $"[Web] Player.GET: EntityPlayer null");102 Log.Warning ("[Web] Player.GET: EntityPlayer null"); 103 103 return; 104 104 } -
TFP-WebServer/WebServer/src/WebAPI/AbsRestApi.cs
r486 r487 103 103 } 104 104 } catch (Exception e) { 105 SendEmptyResponse (_context, HttpStatusCode.InternalServerError, jsonInputData, "ERROR_PROCESSING", e); 105 try { 106 SendEmptyResponse (_context, HttpStatusCode.InternalServerError, jsonInputData, "ERROR_PROCESSING", e); 107 } catch (Exception e2) { 108 Log.Error ($"[Web] In {nameof(AbsRestApi)}.HandleRequest(): Handler {Name} threw an exception while trying to send a previous exception to the client:"); 109 Log.Exception (e2); 110 } 106 111 } 107 112 } -
TFP-WebServer/WebServer/src/WebAPI/OpenApiHelpers.cs
r466 r487 105 105 } 106 106 107 private static readonly Regex pathMatcher = new Regex ( "^\\s{1,2}(/\\S+):.*$", RegexOptions.Compiled | RegexOptions.CultureInvariant);107 private static readonly Regex pathMatcher = new Regex (@"^\s{1,2}(/\S+):.*$", RegexOptions.Compiled | RegexOptions.CultureInvariant); 108 108 private Dictionary<string, string> findExportedPaths (string _spec, string _replaceBasePath = null) { 109 109 Dictionary<string, string> result = new Dictionary<string, string> (); … … 161 161 break; 162 162 case '\\': 163 _targetSb.Append ( "\\\\");163 _targetSb.Append (@"\\"); 164 164 break; 165 165 case '\b': -
TFP-WebServer/WebServer/src/WebCommandResult.cs
r402 r487 17 17 private readonly string command; 18 18 private readonly string parameters; 19 private readonly string sourceName; 19 20 20 21 private readonly RequestContext context; … … 26 27 parameters = _parameters; 27 28 responseType = _responseType; 29 sourceName = _context.Connection?.Username ?? "Unauth-PermLevel-" + _context.PermissionLevel; 28 30 } 29 31 … … 93 95 94 96 public string GetDescription () { 95 return $"WebCommandResult_for_{command} ";97 return $"WebCommandResult_for_{command}_by_{sourceName}"; 96 98 } 97 99 }
Note:
See TracChangeset
for help on using the changeset viewer.