Changeset 382
- Timestamp:
- Aug 1, 2022, 12:54:31 PM (2 years ago)
- Location:
- binary-improvements2
- Files:
-
- 2 added
- 34 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements2/MapRendering/API.cs
r369 r382 5 5 public class API : IModApi { 6 6 private Web webInstance; 7 private Mod modInstance; 7 8 8 9 public void InitMod (Mod _modInstance) { … … 10 11 ModEvents.GameShutdown.RegisterHandler (GameShutdown); 11 12 ModEvents.CalcChunkColorsDone.RegisterHandler (CalcChunkColorsDone); 13 modInstance = _modInstance; 12 14 } 13 15 … … 18 20 } 19 21 20 webInstance = new Web ( );22 webInstance = new Web (modInstance.Path); 21 23 LogBuffer.Init (); 22 24 -
binary-improvements2/MapRendering/Web/API/ExecuteConsoleCommand.cs
r360 r382 1 1 using System; 2 2 using System.Net; 3 using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest; 4 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse; 3 5 4 6 namespace AllocsFixes.NetConnections.Servers.Web.API { -
binary-improvements2/MapRendering/Web/API/GetAllowedCommands.cs
r360 r382 1 1 using System.Net; 2 2 using AllocsFixes.JSON; 3 using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest; 4 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse; 3 5 4 6 namespace AllocsFixes.NetConnections.Servers.Web.API { -
binary-improvements2/MapRendering/Web/API/GetAnimalsLocation.cs
r351 r382 3 3 using AllocsFixes.JSON; 4 4 using AllocsFixes.LiveData; 5 using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest; 6 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse; 5 7 6 8 namespace AllocsFixes.NetConnections.Servers.Web.API { -
binary-improvements2/MapRendering/Web/API/GetHostileLocation.cs
r351 r382 3 3 using AllocsFixes.JSON; 4 4 using AllocsFixes.LiveData; 5 using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest; 6 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse; 5 7 6 8 namespace AllocsFixes.NetConnections.Servers.Web.API { -
binary-improvements2/MapRendering/Web/API/GetLandClaims.cs
r369 r382 3 3 using AllocsFixes.JSON; 4 4 using AllocsFixes.PersistentData; 5 using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest; 6 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse; 5 7 6 8 namespace AllocsFixes.NetConnections.Servers.Web.API { -
binary-improvements2/MapRendering/Web/API/GetLog.cs
r350 r382 2 2 using System.Net; 3 3 using AllocsFixes.JSON; 4 using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest; 5 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse; 4 6 5 7 namespace AllocsFixes.NetConnections.Servers.Web.API { … … 9 11 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user, 10 12 int _permissionLevel) { 11 int count, firstLine, lastLine; 12 13 if (_req.QueryString ["count"] == null || !int.TryParse (_req.QueryString ["count"], out count)) { 13 if (_req.QueryString ["count"] == null || !int.TryParse (_req.QueryString ["count"], out int count)) { 14 14 count = 50; 15 15 } … … 27 27 } 28 28 29 if (_req.QueryString ["firstLine"] == null || !int.TryParse (_req.QueryString ["firstLine"], out firstLine)) { 30 if (count > 0) { 31 firstLine = LogBuffer.Instance.OldestLine; 32 } else { 33 firstLine = LogBuffer.Instance.LatestLine; 34 } 29 if (_req.QueryString ["firstLine"] == null || !int.TryParse (_req.QueryString ["firstLine"], out int firstLine)) { 30 firstLine = count > 0 ? LogBuffer.Instance.OldestLine : LogBuffer.Instance.LatestLine; 35 31 } 36 32 37 33 JSONObject result = new JSONObject (); 38 34 39 List<LogBuffer.LogEntry> logEntries = LogBuffer.Instance.GetRange (ref firstLine, count, out lastLine);35 List<LogBuffer.LogEntry> logEntries = LogBuffer.Instance.GetRange (ref firstLine, count, out int lastLine); 40 36 41 37 JSONArray entries = new JSONArray (); … … 44 40 entry.Add ("date", new JSONString (logEntry.date)); 45 41 entry.Add ("time", new JSONString (logEntry.time)); 46 entry.Add ("uptime", new JSONString (logEntry.uptime)); 42 entry.Add ("isotime", new JSONString (logEntry.isoTime)); 43 entry.Add ("uptime", new JSONString (logEntry.uptime.ToString ())); 47 44 entry.Add ("msg", new JSONString (logEntry.message)); 48 45 entry.Add ("trace", new JSONString (logEntry.trace)); -
binary-improvements2/MapRendering/Web/API/GetPlayerInventories.cs
r369 r382 3 3 using AllocsFixes.JSON; 4 4 using AllocsFixes.PersistentData; 5 using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest; 6 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse; 5 7 6 8 namespace AllocsFixes.NetConnections.Servers.Web.API { -
binary-improvements2/MapRendering/Web/API/GetPlayerInventory.cs
r369 r382 3 3 using AllocsFixes.JSON; 4 4 using AllocsFixes.PersistentData; 5 using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest; 6 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse; 5 7 6 8 namespace AllocsFixes.NetConnections.Servers.Web.API { 7 9 public class GetPlayerInventory : WebAPI { 8 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user,9 int _permissionLevel) {10 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, 11 WebConnection _user, int _permissionLevel) { 10 12 if (_req.QueryString ["userid"] == null) { 11 13 _resp.StatusCode = (int) HttpStatusCode.BadRequest; -
binary-improvements2/MapRendering/Web/API/GetPlayerList.cs
r369 r382 6 6 using AllocsFixes.JSON; 7 7 using AllocsFixes.PersistentData; 8 using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest; 9 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse; 8 10 9 11 namespace AllocsFixes.NetConnections.Servers.Web.API { -
binary-improvements2/MapRendering/Web/API/GetPlayersLocation.cs
r369 r382 3 3 using AllocsFixes.JSON; 4 4 using AllocsFixes.PersistentData; 5 using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest; 6 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse; 5 7 6 8 namespace AllocsFixes.NetConnections.Servers.Web.API { -
binary-improvements2/MapRendering/Web/API/GetPlayersOnline.cs
r371 r382 3 3 using AllocsFixes.JSON; 4 4 using AllocsFixes.PersistentData; 5 using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest; 6 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse; 5 7 6 8 namespace AllocsFixes.NetConnections.Servers.Web.API { -
binary-improvements2/MapRendering/Web/API/GetServerInfo.cs
r360 r382 2 2 using System.Net; 3 3 using AllocsFixes.JSON; 4 using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest; 5 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse; 4 6 5 7 namespace AllocsFixes.NetConnections.Servers.Web.API { -
binary-improvements2/MapRendering/Web/API/GetStats.cs
r351 r382 2 2 using AllocsFixes.JSON; 3 3 using AllocsFixes.LiveData; 4 using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest; 5 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse; 4 6 5 7 namespace AllocsFixes.NetConnections.Servers.Web.API { -
binary-improvements2/MapRendering/Web/API/GetWebUIUpdates.cs
r351 r382 2 2 using AllocsFixes.JSON; 3 3 using AllocsFixes.LiveData; 4 using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest; 5 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse; 4 6 5 7 namespace AllocsFixes.NetConnections.Servers.Web.API { -
binary-improvements2/MapRendering/Web/API/Null.cs
r367 r382 1 1 using System.Net; 2 2 using System.Text; 3 using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest; 4 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse; 3 5 4 6 namespace AllocsFixes.NetConnections.Servers.Web.API { -
binary-improvements2/MapRendering/Web/API/WebAPI.cs
r367 r382 1 using System.Net;2 1 using System.Text; 3 2 using AllocsFixes.JSON; 3 using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest; 4 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse; 4 5 5 6 namespace AllocsFixes.NetConnections.Servers.Web.API { … … 44 45 } 45 46 46 public abstract void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user,47 int _permissionLevel);47 public abstract void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, 48 WebConnection _user, int _permissionLevel); 48 49 49 50 public virtual int DefaultPermissionLevel () { -
binary-improvements2/MapRendering/Web/ConnectionHandler.cs
r369 r382 9 9 10 10 public WebConnection IsLoggedIn (string _sessionId, IPAddress _ip) { 11 if (!connections. ContainsKey (_sessionId)) {11 if (!connections.TryGetValue (_sessionId, out WebConnection con)) { 12 12 return null; 13 13 } 14 15 WebConnection con = connections [_sessionId];16 14 17 15 // if (con.Age.TotalMinutes > parent.sessionTimeoutMinutes) { -
binary-improvements2/MapRendering/Web/Handlers/AbsHandler.cs
r381 r382 1 1 using System.Net; 2 using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest; 3 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse; 2 4 3 5 namespace AllocsFixes.NetConnections.Servers.Web.Handlers { 4 public abstract class PathHandler {6 public abstract class AbsHandler { 5 7 protected readonly string moduleName; 6 8 protected string urlBasePath; 7 9 protected Web parent; 8 10 9 protected PathHandler (string _moduleName, int _defaultPermissionLevel = 0) { 11 public string ModuleName => moduleName; 12 public string UrlBasePath => urlBasePath; 13 14 protected AbsHandler (string _moduleName, int _defaultPermissionLevel = 0) { 10 15 moduleName = _moduleName; 11 16 WebPermissions.Instance.AddKnownModule (_moduleName, _defaultPermissionLevel); 12 17 } 13 18 14 public string ModuleName => moduleName; 15 16 public abstract void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user, 19 public abstract void HandleRequest (string _requestPath, HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _con, 17 20 int _permissionLevel); 18 21 -
binary-improvements2/MapRendering/Web/Handlers/ApiHandler.cs
r367 r382 4 4 using System.Reflection; 5 5 using AllocsFixes.NetConnections.Servers.Web.API; 6 using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest; 7 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse; 6 8 7 9 namespace AllocsFixes.NetConnections.Servers.Web.Handlers { 8 public class ApiHandler : PathHandler {10 public class ApiHandler : AbsHandler { 9 11 private readonly Dictionary<string, WebAPI> apis = new CaseInsensitiveStringDictionary<WebAPI> (); 10 12 … … 35 37 #endif 36 38 37 public override void HandleRequest ( HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user,39 public override void HandleRequest (string _requestPath, HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _con, 38 40 int _permissionLevel) { 39 string apiName = _req .Url.AbsolutePath.Remove (0, urlBasePath.Length);41 string apiName = _requestPath.Remove (0, urlBasePath.Length); 40 42 41 43 if (!apis.TryGetValue (apiName, out WebAPI api)) { … … 47 49 if (!AuthorizeForApi (apiName, _permissionLevel)) { 48 50 _resp.StatusCode = (int) HttpStatusCode.Forbidden; 49 if (_ user!= null) {51 if (_con != null) { 50 52 //Log.Out ($"{nameof(ApiHandler)}: user '{user.SteamID}' not allowed to execute '{apiName}'"); 51 53 } … … 58 60 apiHandlerSampler.Begin (); 59 61 #endif 60 api.HandleRequest (_req, _resp, _ user, _permissionLevel);62 api.HandleRequest (_req, _resp, _con, _permissionLevel); 61 63 #if ENABLE_PROFILER 62 64 apiHandlerSampler.End (); -
binary-improvements2/MapRendering/Web/Handlers/ItemIconHandler.cs
r369 r382 4 4 using System.Net; 5 5 using UnityEngine; 6 using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest; 7 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse; 6 8 using Object = UnityEngine.Object; 7 9 8 10 namespace AllocsFixes.NetConnections.Servers.Web.Handlers { 9 public class ItemIconHandler : PathHandler {11 public class ItemIconHandler : AbsHandler { 10 12 private readonly Dictionary<string, byte[]> icons = new Dictionary<string, byte[]> (); 11 13 private readonly bool logMissingFiles; … … 24 26 public static ItemIconHandler Instance { get; private set; } 25 27 26 public override void HandleRequest ( HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user,28 public override void HandleRequest (string _requestPath, HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _con, 27 29 int _permissionLevel) { 28 30 if (!loaded) { … … 32 34 } 33 35 34 string requestFileName = _req .Url.AbsolutePath.Remove (0, urlBasePath.Length);36 string requestFileName = _requestPath.Remove (0, urlBasePath.Length); 35 37 requestFileName = requestFileName.Remove (requestFileName.LastIndexOf ('.')); 36 38 37 if (icons.ContainsKey (requestFileName) && _req .Url.AbsolutePath.EndsWith (".png", StringComparison.OrdinalIgnoreCase)) {39 if (icons.ContainsKey (requestFileName) && _requestPath.EndsWith (".png", StringComparison.OrdinalIgnoreCase)) { 38 40 _resp.ContentType = MimeType.GetMimeType (".png"); 39 41 … … 45 47 _resp.StatusCode = (int) HttpStatusCode.NotFound; 46 48 if (logMissingFiles) { 47 Log.Out ("Web:IconHandler:FileNotFound: \"" + _req .Url.AbsolutePath + "\" ");49 Log.Out ("Web:IconHandler:FileNotFound: \"" + _requestPath + "\" "); 48 50 } 49 51 } -
binary-improvements2/MapRendering/Web/Handlers/SessionHandler.cs
r367 r382 1 using System; 1 2 using System.IO; 2 3 using System.Net; 3 4 using System.Text; 5 using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest; 6 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse; 4 7 5 8 namespace AllocsFixes.NetConnections.Servers.Web.Handlers { 6 public class SessionHandler : PathHandler { 9 public class SessionHandler : AbsHandler { 10 private const string pageBasePath = "/"; 11 private const string steamOpenIdVerifyUrl = "verifysteamopenid"; 12 private const string steamLoginUrl = "loginsteam"; 13 7 14 private readonly string footer = ""; 8 15 private readonly string header = ""; 9 16 10 public SessionHandler (string _dataFolder, string _moduleName = null) : base (_moduleName) { 17 private readonly ConnectionHandler connectionHandler; 18 19 public SessionHandler (string _dataFolder, ConnectionHandler _connectionHandler) : base (null) { 20 connectionHandler = _connectionHandler; 21 11 22 if (File.Exists (_dataFolder + "/sessionheader.tmpl")) { 12 23 header = File.ReadAllText (_dataFolder + "/sessionheader.tmpl"); … … 18 29 } 19 30 20 public override void HandleRequest ( HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user,31 public override void HandleRequest (string _requestPath, HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _con, 21 32 int _permissionLevel) { 22 string subpath = _req.Url.AbsolutePath.Remove (0, urlBasePath.Length); 33 34 IPEndPoint reqRemoteEndPoint = _req.RemoteEndPoint; 35 if (reqRemoteEndPoint == null) { 36 _resp.Redirect (pageBasePath); 37 return; 38 } 39 40 string subpath = _requestPath.Remove (0, urlBasePath.Length); 23 41 24 42 StringBuilder result = new StringBuilder (); 25 43 result.Append (header); 26 44 27 if (subpath.StartsWith ("verify")) { 28 if (_user != null) { 29 _resp.Redirect ("/static/index.html"); 45 if (subpath.StartsWith (steamOpenIdVerifyUrl)) { 46 string remoteEndpointString = reqRemoteEndPoint.ToString (); 47 48 try { 49 ulong id = OpenID.Validate (_req); 50 if (id > 0) { 51 WebConnection con = connectionHandler.LogIn (id, reqRemoteEndPoint.Address); 52 int level = GameManager.Instance.adminTools.GetUserPermissionLevel (con.UserId); 53 Log.Out ("Steam OpenID login from {0} with ID {1}, permission level {2}", 54 remoteEndpointString, con.UserId, level); 55 56 Cookie cookie = new Cookie ("sid", con.SessionID, "/") { 57 Expired = false, 58 Expires = DateTime.MinValue, 59 HttpOnly = true, 60 Secure = false 61 }; 62 _resp.AppendCookie (cookie); 63 _resp.Redirect (pageBasePath); 64 65 return; 66 } 67 } catch (Exception e) { 68 Log.Error ("Error validating login:"); 69 Log.Exception (e); 70 } 71 72 Log.Out ($"Steam OpenID login failed from {remoteEndpointString}"); 73 result.Append ($"<h1>Login failed, <a href=\"{pageBasePath}\">click to return to main page</a>.</h1>"); 74 } else if (subpath.StartsWith ("logout")) { 75 if (_con != null) { 76 connectionHandler.LogOut (_con.SessionID); 77 Cookie cookie = new Cookie ("sid", "", "/") { 78 Expired = true 79 }; 80 _resp.AppendCookie (cookie); 81 _resp.Redirect (pageBasePath); 30 82 return; 31 83 } 32 84 33 result.Append ( 34 "<h1>Login failed, <a href=\"/static/index.html\">click to return to main page</a>.</h1>"); 35 } else if (subpath.StartsWith ("logout")) { 36 if (_user != null) { 37 parent.connectionHandler.LogOut (_user.SessionID); 38 Cookie cookie = new Cookie ("sid", "", "/"); 39 cookie.Expired = true; 40 _resp.AppendCookie (cookie); 41 _resp.Redirect ("/static/index.html"); 42 return; 43 } 44 45 result.Append ( 46 "<h1>Not logged in, <a href=\"/static/index.html\">click to return to main page</a>.</h1>"); 47 } else if (subpath.StartsWith ("login")) { 85 result.Append ($"<h1>Not logged in, <a href=\"{pageBasePath}\">click to return to main page</a>.</h1>"); 86 } else if (subpath.StartsWith (steamLoginUrl)) { 48 87 string host = (Web.IsSslRedirected (_req) ? "https://" : "http://") + _req.UserHostName; 49 string url = OpenID.GetOpenIdLoginUrl (host, host + "/session/verify");88 string url = OpenID.GetOpenIdLoginUrl (host, host + urlBasePath + steamOpenIdVerifyUrl); 50 89 _resp.Redirect (url); 51 90 return; 52 91 } else { 53 result.Append ( 54 "<h1>Unknown command, <a href=\"/static/index.html\">click to return to main page</a>.</h1>"); 92 result.Append ($"<h1>Unknown command, <a href=\"{pageBasePath}\">click to return to main page</a>.</h1>"); 55 93 } 56 94 -
binary-improvements2/MapRendering/Web/Handlers/SimpleRedirectHandler.cs
r351 r382 1 1 using System.Net; 2 using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest; 3 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse; 2 4 3 5 namespace AllocsFixes.NetConnections.Servers.Web.Handlers { 4 public class SimpleRedirectHandler : PathHandler {6 public class SimpleRedirectHandler : AbsHandler { 5 7 private readonly string target; 6 8 7 public SimpleRedirectHandler (string _target , string _moduleName = null) : base (_moduleName) {9 public SimpleRedirectHandler (string _target) : base (null) { 8 10 target = _target; 9 11 } 10 12 11 public override void HandleRequest ( HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user,13 public override void HandleRequest (string _requestPath, HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _con, 12 14 int _permissionLevel) { 13 15 _resp.Redirect (target); -
binary-improvements2/MapRendering/Web/Handlers/StaticHandler.cs
r367 r382 2 2 using System.Net; 3 3 using AllocsFixes.FileCache; 4 using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest; 5 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse; 4 6 5 7 namespace AllocsFixes.NetConnections.Servers.Web.Handlers { 6 public class StaticHandler : PathHandler {8 public class StaticHandler : AbsHandler { 7 9 private readonly AbstractCache cache; 8 10 private readonly string datapath; … … 16 18 } 17 19 18 public override void HandleRequest ( HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user,20 public override void HandleRequest (string _requestPath, HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _con, 19 21 int _permissionLevel) { 20 string fn = _req .Url.AbsolutePath.Remove (0, urlBasePath.Length);22 string fn = _requestPath.Remove (0, urlBasePath.Length); 21 23 22 24 byte[] content = cache.GetFileContent (datapath + fn); … … 29 31 _resp.StatusCode = (int) HttpStatusCode.NotFound; 30 32 if (logMissingFiles) { 31 Log.Out ("Web:Static:FileNotFound: \"" + _req .Url.AbsolutePath + "\" @ \"" + datapath + fn + "\"");33 Log.Out ("Web:Static:FileNotFound: \"" + _requestPath + "\" @ \"" + datapath + fn + "\""); 32 34 } 33 35 } -
binary-improvements2/MapRendering/Web/Handlers/UserStatusHandler.cs
r369 r382 1 using System.Net;2 1 using AllocsFixes.JSON; 3 2 using AllocsFixes.NetConnections.Servers.Web.API; 3 using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest; 4 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse; 4 5 5 6 namespace AllocsFixes.NetConnections.Servers.Web.Handlers { 6 public class UserStatusHandler : PathHandler {7 public class UserStatusHandler : AbsHandler { 7 8 public UserStatusHandler (string _moduleName = null) : base (_moduleName) { 8 9 } 9 10 10 public override void HandleRequest ( HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user,11 public override void HandleRequest (string _requestPath, HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _con, 11 12 int _permissionLevel) { 12 13 JSONObject result = new JSONObject (); 13 14 14 result.Add ("loggedin", new JSONBoolean (_ user!= null));15 result.Add ("username", new JSONString (_ user != null ? _user.UserId.ToString () : string.Empty));15 result.Add ("loggedin", new JSONBoolean (_con != null)); 16 result.Add ("username", new JSONString (_con != null ? _con.UserId.ToString () : string.Empty)); 16 17 17 18 JSONArray perms = new JSONArray (); -
binary-improvements2/MapRendering/Web/LogBuffer.cs
r369 r382 5 5 namespace AllocsFixes.NetConnections.Servers.Web { 6 6 public class LogBuffer { 7 private const int MAX_ENTRIES = 3000; 7 private const int maxEntries = 3000; 8 8 9 private static LogBuffer instance; 9 10 … … 22 23 } 23 24 24 public static LogBuffer Instance { 25 get { 26 if (instance == null) { 27 instance = new LogBuffer (); 28 } 29 30 return instance; 31 } 32 } 25 public static LogBuffer Instance => instance ?? (instance = new LogBuffer ()); 33 26 34 27 public int OldestLine { … … 69 62 70 63 private void LogCallback (string _formattedMsg, string _plainMsg, string _trace, LogType _type, DateTime _timestamp, long _uptime) { 71 LogEntry le = new LogEntry (); 72 73 le.date = $"{_timestamp.Year:0000}-{_timestamp.Month:00}-{_timestamp.Day:00}"; 74 le.time = $"{_timestamp.Hour:00}:{_timestamp.Minute:00}:{_timestamp.Second:00}"; 75 le.uptime = _uptime.ToString (); 76 le.message = _plainMsg; 77 le.trace = _trace; 78 le.type = _type; 64 LogEntry le = new LogEntry (_timestamp, _plainMsg, _trace, _type, _uptime); 79 65 80 66 lock (logEntries) { 81 67 logEntries.Add (le); 82 if (logEntries.Count > MAX_ENTRIES) {83 listOffset += logEntries.Count - MAX_ENTRIES;84 logEntries.RemoveRange (0, logEntries.Count - MAX_ENTRIES);68 if (logEntries.Count > maxEntries) { 69 listOffset += logEntries.Count - maxEntries; 70 logEntries.RemoveRange (0, logEntries.Count - maxEntries); 85 71 } 86 72 } … … 140 126 141 127 public class LogEntry { 142 public string date; 143 public string message; 144 public string time; 145 public string trace; 146 public LogType type; 147 public string uptime; 128 public readonly DateTime timestamp; 129 public readonly string date; 130 public readonly string time; 131 public readonly string isoTime; 132 public readonly string message; 133 public readonly string trace; 134 public readonly LogType type; 135 public readonly long uptime; 136 137 public LogEntry (DateTime _timestamp, string _message, string _trace, LogType _type, long _uptime) { 138 timestamp = _timestamp; 139 date = $"{_timestamp.Year:0000}-{_timestamp.Month:00}-{_timestamp.Day:00}"; 140 time = $"{_timestamp.Hour:00}:{_timestamp.Minute:00}:{_timestamp.Second:00}"; 141 isoTime = _timestamp.ToString ("o"); 142 143 message = _message; 144 trace = _trace; 145 type = _type; 146 uptime = _uptime; 147 } 148 148 } 149 149 } -
binary-improvements2/MapRendering/Web/OpenID.cs
r351 r382 9 9 using System.Text; 10 10 using System.Text.RegularExpressions; 11 using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest; 11 12 12 13 namespace AllocsFixes.NetConnections.Servers.Web { -
binary-improvements2/MapRendering/Web/SSE/EventBase.cs
r372 r382 2 2 using System.Collections.Generic; 3 3 using System.IO; 4 using System.Net;5 4 using System.Net.Sockets; 6 5 using System.Text; 7 6 using AllocsFixes.JSON; 7 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse; 8 8 9 9 namespace AllocsFixes.NetConnections.Servers.Web.SSE { … … 116 116 Log.Exception (e); 117 117 } 118 119 resp.Close ();120 118 } catch (Exception e) { 121 119 currentlyOpen--; -
binary-improvements2/MapRendering/Web/SSE/EventLog.cs
r369 r382 12 12 string date = $"{_timestamp.Year:0000}-{_timestamp.Month:00}-{_timestamp.Day:00}"; 13 13 string time = $"{_timestamp.Hour:00}:{_timestamp.Minute:00}:{_timestamp.Second:00}"; 14 string isotime = _timestamp.ToString ("o"); 14 15 string uptime = _uptime.ToString (); 15 16 string message = _plainMsg; … … 21 22 data.Add ("date", new JSONString (date)); 22 23 data.Add ("time", new JSONString (time)); 24 data.Add ("isotime", new JSONString (isotime)); 23 25 data.Add ("uptime", new JSONString (uptime)); 24 26 -
binary-improvements2/MapRendering/Web/SSE/SseHandler.cs
r367 r382 5 5 using System.Threading; 6 6 using AllocsFixes.NetConnections.Servers.Web.Handlers; 7 using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest; 8 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse; 7 9 8 10 // Implemented following HTML spec … … 10 12 11 13 namespace AllocsFixes.NetConnections.Servers.Web.SSE { 12 public class SseHandler : PathHandler {14 public class SseHandler : AbsHandler { 13 15 private readonly Dictionary<string, EventBase> events = new CaseInsensitiveStringDictionary<EventBase> (); 14 16 15 17 private ThreadManager.ThreadInfo queueThead; 16 18 private readonly AutoResetEvent evSendRequest = new AutoResetEvent (false); … … 18 20 19 21 public SseHandler (string _moduleName = null) : base (_moduleName) { 20 Type[] ctorTypes = { typeof (SseHandler)};21 object[] ctorParams = { this};22 Type[] ctorTypes = { typeof (SseHandler) }; 23 object[] ctorParams = { this }; 22 24 23 25 foreach (Type t in Assembly.GetExecutingAssembly ().GetTypes ()) { … … 25 27 ConstructorInfo ctor = t.GetConstructor (ctorTypes); 26 28 if (ctor != null) { 27 EventBase apiInstance = (EventBase) 28 addEvent (apiInstance.Name, apiInstance);29 EventBase apiInstance = (EventBase)ctor.Invoke (ctorParams); 30 AddEvent (apiInstance.Name, apiInstance); 29 31 } 30 32 } … … 34 36 public override void SetBasePathAndParent (Web _parent, string _relativePath) { 35 37 base.SetBasePathAndParent (_parent, _relativePath); 36 38 37 39 queueThead = ThreadManager.StartThread ("SSE-Processing_" + urlBasePath, QueueProcessThread, ThreadPriority.BelowNormal, 38 40 _useRealThread: true); … … 45 47 } 46 48 47 p rivate void addEvent (string _eventName, EventBase _eventInstance) {49 public void AddEvent (string _eventName, EventBase _eventInstance) { 48 50 events.Add (_eventName, _eventInstance); 49 51 WebPermissions.Instance.AddKnownModule ("webevent." + _eventName, _eventInstance.DefaultPermissionLevel ()); 50 52 } 51 53 52 public override void HandleRequest ( HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user,54 public override void HandleRequest (string _requestPath, HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _con, 53 55 int _permissionLevel) { 54 string eventName = _req .Url.AbsolutePath.Remove (0, urlBasePath.Length);56 string eventName = _requestPath.Remove (0, urlBasePath.Length); 55 57 56 58 if (!events.TryGetValue (eventName, out EventBase eventInstance)) { 57 59 Log.Out ($"Error in {nameof (SseHandler)}.HandleRequest(): No handler found for event \"{eventName}\""); 58 _resp.StatusCode = (int) 60 _resp.StatusCode = (int)HttpStatusCode.NotFound; 59 61 return; 60 62 } 61 63 62 if (! AuthorizeForEvent (eventName, _permissionLevel)) {63 _resp.StatusCode = (int) 64 if (_ user!= null) {64 if (!IsAuthorizedForEvent (eventName, _permissionLevel)) { 65 _resp.StatusCode = (int)HttpStatusCode.Forbidden; 66 if (_con != null) { 65 67 //Log.Out ($"{nameof(SseHandler)}: user '{user.SteamID}' not allowed to access '{eventName}'"); 66 68 } … … 80 82 Log.Error ($"Error in {nameof (SseHandler)}.HandleRequest(): Handler {eventInstance.Name} threw an exception:"); 81 83 Log.Exception (e); 82 _resp.StatusCode = (int) 84 _resp.StatusCode = (int)HttpStatusCode.InternalServerError; 83 85 } 84 86 } 85 87 86 private bool AuthorizeForEvent (string _eventName, int _permissionLevel) {88 private bool IsAuthorizedForEvent (string _eventName, int _permissionLevel) { 87 89 return WebPermissions.Instance.ModuleAllowedWithLevel ("webevent." + _eventName, _permissionLevel); 88 90 } 89 91 90 92 private void QueueProcessThread (ThreadManager.ThreadInfo _threadInfo) { 91 try { 92 while (!shutdown && !_threadInfo.TerminationRequested ()) { 93 evSendRequest.WaitOne (500); 93 while (!shutdown && !_threadInfo.TerminationRequested ()) { 94 evSendRequest.WaitOne (500); 94 95 95 foreach (KeyValuePair<string, EventBase> kvp in events) { 96 foreach (KeyValuePair<string, EventBase> kvp in events) { 97 try { 96 98 kvp.Value.ProcessSendQueue (); 99 } catch (Exception e) { 100 Log.Error ($"SSE ({kvp.Key}): Error processing send queue"); 101 Log.Exception (e); 97 102 } 98 103 } 99 } catch (Exception e) {100 Log.Error ("SSE: Error processing send queue");101 Log.Exception (e);102 104 } 103 105 } -
binary-improvements2/MapRendering/Web/Web.cs
r369 r382 2 2 using System.Collections.Generic; 3 3 using System.IO; 4 using System.Net;5 4 using System.Net.Sockets; 6 using System.Reflection; 5 using Cookie = System.Net.Cookie; 6 using HttpStatusCode = System.Net.HttpStatusCode; 7 using IPEndPoint = System.Net.IPEndPoint; 7 8 using System.Text; 8 9 using System.Threading; … … 10 11 using AllocsFixes.NetConnections.Servers.Web.Handlers; 11 12 using AllocsFixes.NetConnections.Servers.Web.SSE; 13 using SpaceWizards.HttpListener; 12 14 using UnityEngine; 13 15 14 16 namespace AllocsFixes.NetConnections.Servers.Web { 15 17 public class Web : IConsoleServer { 16 private const int GUEST_PERMISSION_LEVEL = 2000; 18 private const int guestPermissionLevel = 2000; 19 private const string indexPagePath = "/app"; 20 17 21 public static int handlingCount; 18 22 public static int currentHandlers; 19 23 public static long totalHandlingTime = 0; 24 private readonly List<AbsHandler> handlers = new List<AbsHandler> (); 25 private readonly ConnectionHandler connectionHandler; 26 20 27 private readonly HttpListener listener = new HttpListener (); 21 private readonly Dictionary<string, PathHandler> handlers = new CaseInsensitiveStringDictionary<PathHandler> (); 22 23 public readonly ConnectionHandler connectionHandler; 24 25 public Web () { 28 private readonly Version httpProtocolVersion = new Version(1, 1); 29 30 public Web (string _modInstancePath) { 26 31 try { 27 32 int webPort = GamePrefs.GetInt (EnumUtils.Parse<EnumGamePrefs> ("ControlPanelPort")); … … 31 36 } 32 37 33 if (!Directory.Exists (Path.GetDirectoryName (Assembly.GetExecutingAssembly ().Location) + 34 "/webserver")) { 35 Log.Out ("Webserver not started (folder \"webserver\" not found in WebInterface mod folder)"); 38 // TODO: Remove once this becomes the default control panel 39 webPort += 2; 40 41 if (!HttpListener.IsSupported) { 42 Log.Out ("Webserver not started (needs Windows XP SP2, Server 2003 or later or Mono)"); 36 43 return; 37 44 } … … 40 47 bool useStaticCache = false; 41 48 42 string dataFolder = Path.GetDirectoryName (Assembly.GetExecutingAssembly ().Location) + "/webserver"; 43 44 if (!HttpListener.IsSupported) { 45 Log.Out ("Webserver not started (needs Windows XP SP2, Server 2003 or later or Mono)"); 46 return; 47 } 48 49 50 RegisterPathHandler ("/index.htm", new SimpleRedirectHandler ("/static/index.html")); 51 RegisterPathHandler ("/favicon.ico", new SimpleRedirectHandler ("/static/favicon.ico")); 52 RegisterPathHandler ("/session/", new SessionHandler (dataFolder)); 49 string webfilesFolder = _modInstancePath + "/webserver"; 50 string webfilesFolderLegacy = _modInstancePath + "/weblegacy"; 51 52 connectionHandler = new ConnectionHandler (); 53 54 RegisterPathHandler ("/", new RewriteHandler ("/files/")); 55 56 // React virtual routing 57 RegisterPathHandler ("/app", new RewriteHandler ("/files/index.html", true)); 58 59 // Legacy web page 60 RegisterPathHandler ("/weblegacy", new StaticHandler ( 61 webfilesFolderLegacy, 62 useStaticCache ? (AbstractCache)new SimpleCache () : new DirectAccess (), 63 false) 64 ); 65 66 RegisterPathHandler ("/session/", new SessionHandler (webfilesFolder, connectionHandler)); 53 67 RegisterPathHandler ("/userstatus", new UserStatusHandler ()); 54 RegisterPathHandler ("/ static/", new StaticHandler (55 dataFolder,68 RegisterPathHandler ("/files/", new StaticHandler ( 69 webfilesFolder, 56 70 useStaticCache ? (AbstractCache) new SimpleCache () : new DirectAccess (), 57 71 false) … … 67 81 RegisterPathHandler ("/sse/", new SseHandler ()); 68 82 69 connectionHandler = new ConnectionHandler (); 70 71 listener.Prefixes.Add ($"http://*:{webPort + 2}/"); 83 listener.Prefixes.Add ($"http://+:{webPort}/"); 84 // listener.Prefixes.Add ($"http://[::1]:{webPort}/"); 72 85 listener.Start (); 86 listener.BeginGetContext (HandleRequest, listener); 73 87 74 88 SdtdConsole.Instance.RegisterServer (this); 75 89 76 listener.BeginGetContext (HandleRequest, listener); 77 78 Log.Out ("Started Webserver on " + (webPort + 2)); 90 Log.Out ("Started Webserver on " + webPort); 79 91 } catch (Exception e) { 80 Log.Out ("Error in Web.ctor: " + e); 81 } 82 } 83 84 public void RegisterPathHandler (string _urlBasePath, PathHandler _handler) { 85 if (handlers.ContainsKey (_urlBasePath)) { 86 Log.Error ($"Web: Handler for relative path {_urlBasePath} already registerd."); 87 return; 92 Log.Error ("Error in Web.ctor: "); 93 Log.Exception (e); 94 } 95 } 96 97 public void RegisterPathHandler (string _urlBasePath, AbsHandler _handler) { 98 foreach (AbsHandler handler in handlers) { 99 if (handler.UrlBasePath == _urlBasePath) { 100 Log.Error ($"Web: Handler for relative path {_urlBasePath} already registerd."); 101 return; 102 } 88 103 } 89 104 90 handlers.Add (_ urlBasePath, _handler);105 handlers.Add (_handler); 91 106 _handler.SetBasePathAndParent (this, _urlBasePath); 92 107 } … … 102 117 103 118 public void Shutdown () { 104 foreach ( KeyValuePair<string, PathHandler> kvpin handlers) {105 kvp.Value.Shutdown ();119 foreach (AbsHandler handler in handlers) { 120 handler.Shutdown (); 106 121 } 107 122 } … … 120 135 } 121 136 122 private readonly Version HttpProtocolVersion = new Version(1, 1);123 124 137 #if ENABLE_PROFILER 125 138 private readonly UnityEngine.Profiling.CustomSampler authSampler = UnityEngine.Profiling.CustomSampler.Create ("Auth"); … … 128 141 129 142 private void HandleRequest (IAsyncResult _result) { 130 if (!listener.IsListening) { 143 HttpListener listenerInstance = (HttpListener)_result.AsyncState; 144 if (!listenerInstance.IsListening) { 131 145 return; 132 146 } … … 135 149 Interlocked.Increment (ref currentHandlers); 136 150 137 // MicroStopwatch msw = new MicroStopwatch ();138 151 #if ENABLE_PROFILER 139 152 UnityEngine.Profiling.Profiler.BeginThreadProfiling ("AllocsMods", "WebRequest"); 140 HttpListenerContext ctx = _listener.EndGetContext (_result);153 HttpListenerContext ctx = listenerInstance.EndGetContext (_result); 141 154 try { 142 155 #else 143 HttpListenerContext ctx = listener .EndGetContext (_result);144 listener .BeginGetContext (HandleRequest, listener);156 HttpListenerContext ctx = listenerInstance.EndGetContext (_result); 157 listenerInstance.BeginGetContext (HandleRequest, listenerInstance); 145 158 #endif 146 159 try { … … 149 162 response.SendChunked = false; 150 163 151 response.ProtocolVersion = HttpProtocolVersion;164 response.ProtocolVersion = httpProtocolVersion; 152 165 153 166 #if ENABLE_PROFILER … … 179 192 } 180 193 181 if (request.Url.AbsolutePath.Length < 2) { 182 handlers ["/index.htm"].HandleRequest (request, response, conn, permissionLevel); 183 return; 184 } else { 185 foreach (KeyValuePair<string, PathHandler> kvp in handlers) { 186 if (request.Url.AbsolutePath.StartsWith (kvp.Key)) { 187 if (!kvp.Value.IsAuthorizedForHandler (conn, permissionLevel)) { 188 response.StatusCode = (int) HttpStatusCode.Forbidden; 189 if (conn != null) { 190 //Log.Out ("Web.HandleRequest: user '{0}' not allowed to access '{1}'", conn.SteamID, kvp.Value.ModuleName); 191 } 192 } else { 193 #if ENABLE_PROFILER 194 handlerSampler.Begin (); 195 #endif 196 kvp.Value.HandleRequest (request, response, conn, permissionLevel); 197 #if ENABLE_PROFILER 198 handlerSampler.End (); 199 #endif 200 } 201 202 return; 203 } 204 } 205 } 206 207 // Not really relevant for non-debugging purposes: 208 //Log.Out ("Error in Web.HandleRequest(): No handler found for path \"" + request.Url.AbsolutePath + "\""); 209 response.StatusCode = (int) HttpStatusCode.NotFound; 194 string requestPath = request.Url.AbsolutePath; 195 196 if (requestPath.Length < 2) { 197 response.Redirect (indexPagePath); 198 return; 199 } 200 201 ApplyPathHandler (requestPath, request, response, conn, permissionLevel); 202 210 203 } catch (IOException e) { 211 204 if (e.InnerException is SocketException) { 212 Log.Out ("Error in Web.HandleRequest(): Remote host closed connection: " + 213 e.InnerException.Message); 205 Log.Out ("Error in Web.HandleRequest(): Remote host closed connection: " + e.InnerException.Message); 214 206 } else { 215 207 Log.Out ("Error (IO) in Web.HandleRequest(): " + e); … … 219 211 Log.Exception (e); 220 212 } finally { 221 if ( ctx != null &&!ctx.Response.SendChunked) {213 if (!ctx.Response.SendChunked) { 222 214 ctx.Response.Close (); 223 215 } 224 225 // msw.Stop ();226 // totalHandlingTime += msw.ElapsedMicroseconds;227 // Log.Out ("Web.HandleRequest(): Took {0} µs", msw.ElapsedMicroseconds);228 216 Interlocked.Decrement (ref currentHandlers); 229 217 } 230 218 #if ENABLE_PROFILER 231 219 } finally { 232 _listener.BeginGetContext (HandleRequest, _listener);220 listenerInstance.BeginGetContext (HandleRequest, listenerInstance); 233 221 UnityEngine.Profiling.Profiler.EndThreadProfiling (); 234 222 } 235 223 #endif 224 } 225 226 public void ApplyPathHandler (string _requestPath, HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _con, 227 int _permissionLevel) { 228 for (int i = handlers.Count - 1; i >= 0; i--) { 229 AbsHandler handler = handlers [i]; 230 231 if (_requestPath.StartsWith (handler.UrlBasePath)) { 232 if (!handler.IsAuthorizedForHandler (_con, _permissionLevel)) { 233 _resp.StatusCode = (int)HttpStatusCode.Forbidden; 234 if (_con != null) { 235 //Log.Out ("Web.HandleRequest: user '{0}' not allowed to access '{1}'", _con.SteamID, handler.ModuleName); 236 } 237 } else { 238 #if ENABLE_PROFILER 239 handlerSampler.Begin (); 240 #endif 241 handler.HandleRequest (_requestPath, _req, _resp, _con, _permissionLevel); 242 #if ENABLE_PROFILER 243 handlerSampler.End (); 244 #endif 245 } 246 247 return; 248 } 249 } 250 251 // Not really relevant for non-debugging purposes: 252 //Log.Out ("Error in Web.HandleRequest(): No handler found for path \"" + _requestPath + "\""); 253 _resp.StatusCode = (int) HttpStatusCode.NotFound; 236 254 } 237 255 … … 239 257 _con = null; 240 258 241 string sessionId = null; 242 if (_req.Cookies ["sid"] != null) { 243 sessionId = _req.Cookies ["sid"].Value; 244 } 245 259 string sessionId = _req.Cookies ["sid"]?.Value; 260 261 IPEndPoint reqRemoteEndPoint = _req.RemoteEndPoint; 262 if (reqRemoteEndPoint == null) { 263 Log.Warning ("No RemoteEndPoint on web request"); 264 return guestPermissionLevel; 265 } 266 246 267 if (!string.IsNullOrEmpty (sessionId)) { 247 WebConnection con = connectionHandler.IsLoggedIn (sessionId, _req.RemoteEndPoint.Address); 248 if (con != null) { 249 _con = con; 268 _con = connectionHandler.IsLoggedIn (sessionId, reqRemoteEndPoint.Address); 269 if (_con != null) { 250 270 return GameManager.Instance.adminTools.GetUserPermissionLevel (_con.UserId); 251 271 } 252 272 } 253 273 254 string remoteEndpointString = _req.RemoteEndPoint.ToString ();274 string remoteEndpointString = reqRemoteEndPoint.ToString (); 255 275 256 276 if (_req.QueryString ["adminuser"] != null && _req.QueryString ["admintoken"] != null) { … … 264 284 } 265 285 266 if (_req.Url.AbsolutePath.StartsWith ("/session/verify", StringComparison.OrdinalIgnoreCase)) { 267 try { 268 ulong id = OpenID.Validate (_req); 269 if (id > 0) { 270 WebConnection con = connectionHandler.LogIn (id, _req.RemoteEndPoint.Address); 271 _con = con; 272 int level = GameManager.Instance.adminTools.GetUserPermissionLevel (con.UserId); 273 Log.Out ("Steam OpenID login from {0} with ID {1}, permission level {2}", 274 remoteEndpointString, con.UserId, level); 275 return level; 276 } 277 278 Log.Out ("Steam OpenID login failed from {0}", remoteEndpointString); 279 } catch (Exception e) { 280 Log.Error ("Error validating login:"); 281 Log.Exception (e); 282 } 283 } 284 285 return GUEST_PERMISSION_LEVEL; 286 return guestPermissionLevel; 286 287 } 287 288 -
binary-improvements2/MapRendering/Web/WebCommandResult.cs
r369 r382 2 2 using System.Collections.Generic; 3 3 using System.IO; 4 using System.Net;5 4 using System.Net.Sockets; 6 5 using System.Text; … … 9 8 using AllocsFixes.NetConnections.Servers.Web.API; 10 9 using UnityEngine; 10 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse; 11 11 12 12 namespace AllocsFixes.NetConnections.Servers.Web { … … 27 27 private readonly ResultType responseType; 28 28 29 public WebCommandResult (string _command, string _parameters, ResultType _responseType, 30 HttpListenerResponse _response) { 29 public WebCommandResult (string _command, string _parameters, ResultType _responseType, HttpListenerResponse _response) { 31 30 Interlocked.Increment (ref handlingCount); 32 31 Interlocked.Increment (ref currentHandlers); -
binary-improvements2/MapRendering/Web/WebConnection.cs
r369 r382 11 11 private readonly string conDescription; 12 12 13 public string SessionID { get; } 14 15 public IPAddress Endpoint { get; } 16 17 public PlatformUserIdentifierAbs UserId { get; } 18 19 public TimeSpan Age => DateTime.Now - lastAction; 20 13 21 public WebConnection (string _sessionId, IPAddress _endpoint, PlatformUserIdentifierAbs _userId) { 14 22 SessionID = _sessionId; … … 19 27 conDescription = "WebPanel from " + Endpoint; 20 28 } 21 22 public string SessionID { get; }23 24 public IPAddress Endpoint { get; }25 26 public PlatformUserIdentifierAbs UserId { get; }27 28 public TimeSpan Age => DateTime.Now - lastAction;29 29 30 30 public static bool CanViewAllPlayers (int _permissionLevel) { -
binary-improvements2/MapRendering/WebAndMapRendering.csproj
r373 r382 47 47 <Private>False</Private> 48 48 </Reference> 49 <Reference Include="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 50 <HintPath>..\7dtd-binaries\System.dll</HintPath> 51 <Private>False</Private> 52 </Reference> 53 <Reference Include="System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 54 <HintPath>..\7dtd-binaries\System.Xml.dll</HintPath> 55 <Private>False</Private> 56 </Reference> 49 57 <Reference Include="UnityEngine"> 50 58 <HintPath>..\7dtd-binaries\UnityEngine.dll</HintPath> … … 57 65 <Reference Include="mscorlib"> 58 66 <HintPath>..\7dtd-binaries\mscorlib.dll</HintPath> 59 <Private>False</Private>60 </Reference>61 <Reference Include="System.Xml">62 <HintPath>..\7dtd-binaries\System.Xml.dll</HintPath>63 <Private>False</Private>64 </Reference>65 <Reference Include="System">66 <HintPath>..\7dtd-binaries\System.dll</HintPath>67 67 <Private>False</Private> 68 68 </Reference> … … 78 78 <ItemGroup> 79 79 <Compile Include="AssemblyInfo.cs" /> 80 <Compile Include="Commands\Exception.cs" /> 80 81 <Compile Include="MapRendering\MapRendering.cs" /> 81 82 <Compile Include="MapRendering\MapRenderBlockBuffer.cs" /> … … 87 88 <Compile Include="Web\API\GetHostileLocation.cs" /> 88 89 <Compile Include="Web\API\Null.cs" /> 90 <Compile Include="Web\Handlers\RewriteHandler.cs" /> 89 91 <Compile Include="Web\SSE\EventLog.cs" /> 90 92 <Compile Include="Web\SSE\SseHandler.cs" /> … … 105 107 <Compile Include="Web\Handlers\ApiHandler.cs" /> 106 108 <Compile Include="Web\Handlers\ItemIconHandler.cs" /> 107 <Compile Include="Web\Handlers\ PathHandler.cs" />109 <Compile Include="Web\Handlers\AbsHandler.cs" /> 108 110 <Compile Include="Web\Handlers\SimpleRedirectHandler.cs" /> 109 111 <Compile Include="Web\Handlers\StaticHandler.cs" /> … … 131 133 <Private>False</Private> 132 134 </ProjectReference> 135 <ProjectReference Include="..\SpaceWizards.HttpListener\SpaceWizards.HttpListener.csproj"> 136 <Project>{e273d042-57f9-4e2e-8268-5053527e5287}</Project> 137 <Name>SpaceWizards.HttpListener</Name> 138 </ProjectReference> 133 139 </ItemGroup> 134 140 <ItemGroup> -
binary-improvements2/server-fixes.sln
r373 r382 7 7 EndProject 8 8 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebAndMapRendering", "MapRendering\WebAndMapRendering.csproj", "{A1847B5F-7BFC-4BCD-94AA-A6C9FB7E7C54}" 9 EndProject 10 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpaceWizards.HttpListener", "SpaceWizards.HttpListener\SpaceWizards.HttpListener.csproj", "{E273D042-57F9-4E2E-8268-5053527E5287}" 9 11 EndProject 10 12 Global
Note:
See TracChangeset
for help on using the changeset viewer.