improved console/extension reliability
This commit is contained in:
parent
1e7bffcd8a
commit
79ecfafeb5
|
|
@ -22,10 +22,9 @@ namespace Novetus.Core
|
||||||
public virtual bool IsValidURL(string absolutePath, string host) { return false; }
|
public virtual bool IsValidURL(string absolutePath, string host) { return false; }
|
||||||
|
|
||||||
public virtual Task OnBeforeTunnelConnectRequest(object sender, TunnelConnectSessionEventArgs e) { return Task.CompletedTask; }
|
public virtual Task OnBeforeTunnelConnectRequest(object sender, TunnelConnectSessionEventArgs e) { return Task.CompletedTask; }
|
||||||
public virtual Task OnRequest(object sender, SessionEventArgs e)
|
public virtual async Task OnRequest(object sender, SessionEventArgs e)
|
||||||
{
|
{
|
||||||
e.Ok("Test successful. \nRunning Novetus " + GlobalVars.ProgramInformation.Version + " on " + GlobalVars.ProgramInformation.NetVersion);
|
e.Ok("Test successful. \nRunning Novetus " + GlobalVars.ProgramInformation.Version + " on " + GlobalVars.ProgramInformation.NetVersion);
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -227,7 +226,7 @@ namespace Novetus.Core
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
e.DecryptSsl = false;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -255,9 +254,13 @@ namespace Novetus.Core
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
e.GenericResponse("", HttpStatusCode.InternalServerError);
|
e.GenericResponse("", HttpStatusCode.InternalServerError);
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
e.GenericResponse("", HttpStatusCode.NotFound);
|
e.GenericResponse("", HttpStatusCode.NotFound);
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ namespace Novetus.Core
|
||||||
public static readonly string RootPath = Directory.GetParent(RootPathLauncher).ToString();
|
public static readonly string RootPath = Directory.GetParent(RootPathLauncher).ToString();
|
||||||
public static readonly string BasePath = RootPath.Replace(@"\", @"\\");
|
public static readonly string BasePath = RootPath.Replace(@"\", @"\\");
|
||||||
public static readonly string DataPath = BasePath + @"\\shareddata";
|
public static readonly string DataPath = BasePath + @"\\shareddata";
|
||||||
|
public static readonly string AssetsPath = BasePath + @"\\assets";
|
||||||
public static readonly string BinDir = BasePath + @"\\bin";
|
public static readonly string BinDir = BasePath + @"\\bin";
|
||||||
public static readonly string ConfigDir = BasePath + @"\\config";
|
public static readonly string ConfigDir = BasePath + @"\\config";
|
||||||
public static readonly string LogDir = BasePath + @"\\logs";
|
public static readonly string LogDir = BasePath + @"\\logs";
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#region Usings
|
#region Usings
|
||||||
using Mono.Nat;
|
using Mono.Nat;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Web;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Novetus.Core
|
namespace Novetus.Core
|
||||||
|
|
@ -50,6 +51,16 @@ namespace Novetus.Core
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string FindQueryString(Uri uri, string searchQuery)
|
||||||
|
{
|
||||||
|
return FindQueryString(uri.Query, searchQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string FindQueryString(string query, string searchQuery)
|
||||||
|
{
|
||||||
|
return HttpUtility.ParseQueryString(query)[searchQuery];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ namespace Novetus.Core
|
||||||
|
|
||||||
box.SelectionColor = color;
|
box.SelectionColor = color;
|
||||||
box.AppendText(text);
|
box.AppendText(text);
|
||||||
box.SelectionColor = box.ForeColor;
|
//box.SelectionColor = box.ForeColor;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
@ -592,7 +592,7 @@ namespace Novetus.Core
|
||||||
{
|
{
|
||||||
string message = (ex.Message != null ? ex.Message.ToString() : "N/A");
|
string message = (ex.Message != null ? ex.Message.ToString() : "N/A");
|
||||||
|
|
||||||
ConsolePrint(ex.Source + " Exception: " + message, 2, false, true);
|
ConsolePrint(ex.Source + " Exception: " + message, 2, true);
|
||||||
|
|
||||||
LogPrint("EXCEPTION|MESSAGE: " + message, 2);
|
LogPrint("EXCEPTION|MESSAGE: " + message, 2);
|
||||||
LogPrint("EXCEPTION|STACK TRACE: " + (!string.IsNullOrWhiteSpace(ex.StackTrace) ? ex.StackTrace : "N/A"), 2);
|
LogPrint("EXCEPTION|STACK TRACE: " + (!string.IsNullOrWhiteSpace(ex.StackTrace) ? ex.StackTrace : "N/A"), 2);
|
||||||
|
|
@ -680,13 +680,8 @@ namespace Novetus.Core
|
||||||
return (p <= 0);
|
return (p <= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ConsolePrint(string text, int type = 1, bool notime = false, bool noLog = false)
|
public static void ConsolePrint(string text, int type = 1, bool noLog = false)
|
||||||
{
|
{
|
||||||
if (!notime)
|
|
||||||
{
|
|
||||||
ConsoleText("[" + DateTime.Now.ToShortTimeString() + "] - ", ConsoleColor.White);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
|
@ -721,20 +716,20 @@ namespace Novetus.Core
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LAUNCHER
|
#if LAUNCHER
|
||||||
if (GlobalVars.consoleForm != null)
|
if (GlobalVars.consoleForm != null)
|
||||||
{
|
{
|
||||||
FormPrint(text, type, GlobalVars.consoleForm.ConsoleBox, notime);
|
FormPrint(text, type, GlobalVars.consoleForm.ConsoleBox);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ConsolePrintMultiLine(string text, int type = 1, bool notime = false, bool noLog = false)
|
public static void ConsolePrintMultiLine(string text, int type = 1, bool noLog = false)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string[] NewlineChars = { Environment.NewLine, "\n" };
|
string[] NewlineChars = { Environment.NewLine, "\n" };
|
||||||
string[] lines = text.Split(NewlineChars, StringSplitOptions.None);
|
string[] lines = text.Split(NewlineChars, StringSplitOptions.None);
|
||||||
ConsolePrintMultiLine(lines, type, notime, noLog);
|
ConsolePrintMultiLine(lines, type, noLog);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
@ -744,33 +739,35 @@ namespace Novetus.Core
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ConsolePrintMultiLine(ICollection<string> textColection, int type = 1, bool notime = false, bool noLog = false)
|
public static void ConsolePrintMultiLine(ICollection<string> textColection, int type = 1, bool noLog = false)
|
||||||
{
|
{
|
||||||
if (!textColection.Any())
|
if (!textColection.Any())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (textColection.Count == 1)
|
if (textColection.Count == 1)
|
||||||
{
|
{
|
||||||
ConsolePrint(textColection.First(), type, notime, noLog);
|
ConsolePrint(textColection.First(), type, noLog);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (string text in textColection)
|
foreach (string text in textColection)
|
||||||
{
|
{
|
||||||
ConsolePrint(text, type, notime, noLog);
|
ConsolePrint(text, type, noLog);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void FormPrint(string text, int type, RichTextBox box, bool noTime = false)
|
private static void FormPrint(string text, int type, RichTextBox box)
|
||||||
{
|
{
|
||||||
if (box == null)
|
if (box == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!noTime)
|
foreach (string line in box.Lines)
|
||||||
{
|
{
|
||||||
box.AppendText("[" + DateTime.Now.ToShortTimeString() + "] - ", Color.White);
|
Regex.Replace(line, @"^\s+$[\r\n]*", "", RegexOptions.Multiline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
box.AppendText("\r\n", Color.White);
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
|
|
@ -793,8 +790,6 @@ namespace Novetus.Core
|
||||||
box.AppendText(text, Color.Black);
|
box.AppendText(text, Color.Black);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
box.AppendText(Environment.NewLine, Color.White);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ConsoleText(string text, ConsoleColor color, bool newLine = false)
|
private static void ConsoleText(string text, ConsoleColor color, bool newLine = false)
|
||||||
|
|
@ -818,11 +813,11 @@ namespace Novetus.Core
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string[] vals = line.Split('|');
|
string[] vals = line.Split('|');
|
||||||
ConsolePrint(vals[0], Convert.ToInt32(vals[1]), true, true);
|
ConsolePrint(vals[0], Convert.ToInt32(vals[1]), true);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
ConsolePrint(line, 1, true, true);
|
ConsolePrint(line, 1, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -441,16 +441,16 @@ namespace NovetusLauncher
|
||||||
public void ConsoleHelp()
|
public void ConsoleHelp()
|
||||||
{
|
{
|
||||||
ClearConsole();
|
ClearConsole();
|
||||||
Util.ConsolePrint("Help:", 3, true, true);
|
Util.ConsolePrint("Help:", 3, true);
|
||||||
Util.ReadTextFileWithColor(GlobalPaths.BasePath + "\\" + GlobalPaths.ConsoleHelpFileName);
|
Util.ReadTextFileWithColor(GlobalPaths.BasePath + "\\" + GlobalPaths.ConsoleHelpFileName);
|
||||||
Util.ConsolePrint(GlobalVars.Important2, 0, true, true);
|
Util.ConsolePrint(GlobalVars.Important2, 0, true);
|
||||||
ScrollToTop();
|
ScrollToTop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClientScriptDoc()
|
public void ClientScriptDoc()
|
||||||
{
|
{
|
||||||
ClearConsole();
|
ClearConsole();
|
||||||
Util.ConsolePrint("ClientScript Documentation:", 3, true, true);
|
Util.ConsolePrint("ClientScript Documentation:", 3, true);
|
||||||
Util.ReadTextFileWithColor(GlobalPaths.BasePath + "\\" + GlobalPaths.ClientScriptDocumentationFileName);
|
Util.ReadTextFileWithColor(GlobalPaths.BasePath + "\\" + GlobalPaths.ClientScriptDocumentationFileName);
|
||||||
ScrollToTop();
|
ScrollToTop();
|
||||||
}
|
}
|
||||||
|
|
@ -476,7 +476,6 @@ namespace NovetusLauncher
|
||||||
|
|
||||||
if (e.KeyCode == Keys.Enter)
|
if (e.KeyCode == Keys.Enter)
|
||||||
{
|
{
|
||||||
ConsoleBox.AppendText(Environment.NewLine, Color.White);
|
|
||||||
ConsoleProcessCommands(lastLine);
|
ConsoleProcessCommands(lastLine);
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
@ -499,8 +498,8 @@ namespace NovetusLauncher
|
||||||
private void ClearConsole()
|
private void ClearConsole()
|
||||||
{
|
{
|
||||||
ConsoleBox.Text = "";
|
ConsoleBox.Text = "";
|
||||||
ConsoleBox.SelectionStart = 0;
|
ScrollToTop();
|
||||||
ConsoleBox.ScrollToCaret();
|
Console.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ScrollToTop()
|
private void ScrollToTop()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue