Changeset 404 for binary-improvements2/WebServer/src/Web.cs
- Timestamp:
- Feb 16, 2023, 3:50:53 PM (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements2/WebServer/src/Web.cs
r402 r404 6 6 using UnityEngine; 7 7 using Webserver.FileCache; 8 using Webserver.Permissions; 8 9 using Webserver.UrlHandlers; 9 10 using Cookie = System.Net.Cookie; … … 25 26 private readonly Version httpProtocolVersion = new Version(1, 1); 26 27 28 private readonly AsyncCallback handleRequestDelegate; 29 27 30 public Web (string _modInstancePath) { 28 31 try { … … 81 84 // listener.Prefixes.Add ($"http://[::1]:{webPort}/"); 82 85 listener.Start (); 83 listener.BeginGetContext (HandleRequest, listener); 86 handleRequestDelegate = HandleRequest; 87 listener.BeginGetContext (handleRequestDelegate, listener); 84 88 85 89 SdtdConsole.Instance.RegisterServer (this); … … 250 254 #if ENABLE_PROFILER 251 255 } finally { 252 listenerInstance.BeginGetContext ( HandleRequest, listenerInstance);256 listenerInstance.BeginGetContext (handleRequestDelegate, listenerInstance); 253 257 UnityEngine.Profiling.Profiler.EndThreadProfiling (); 254 258 } … … 297 301 _con = connectionHandler.IsLoggedIn (sessionId, reqRemoteEndPoint.Address); 298 302 if (_con != null) { 299 return GameManager.Instance.adminTools.GetUserPermissionLevel (_con.UserId); 300 } 301 } 302 303 if (_req.QueryString ["adminuser"] == null || _req.QueryString ["admintoken"] == null) { 303 int level1 = GameManager.Instance.adminTools.Users.GetUserPermissionLevel (_con.UserId); 304 int level2 = int.MaxValue; 305 if (_con.CrossplatformUserId != null) { 306 level2 = GameManager.Instance.adminTools.Users.GetUserPermissionLevel (_con.CrossplatformUserId); 307 } 308 309 return Math.Min (level1, level2); 310 } 311 } 312 313 if (!_req.Headers.TryGetValue ("X-SDTD-API-TOKENNAME", out string apiTokenName) || 314 !_req.Headers.TryGetValue ("X-SDTD-API-SECRET", out string apiTokenSecret)) { 304 315 return guestPermissionLevel; 305 316 } 306 317 307 WebPermissions.AdminToken admin = WebPermissions.Instance.GetWebAdmin (_req.QueryString ["adminuser"], 308 _req.QueryString ["admintoken"]); 309 if (admin != null) { 310 return admin.permissionLevel; 318 int adminLevel = AdminApiTokens.Instance.GetPermissionLevel (apiTokenName, apiTokenSecret); 319 if (adminLevel < int.MaxValue) { 320 return adminLevel; 311 321 } 312 322
Note:
See TracChangeset
for help on using the changeset viewer.