|
|
|
@ -12,6 +12,7 @@ using System.Security.Cryptography;
|
|
|
|
|
using System.Collections.Specialized;
|
|
|
|
|
using System.IO.Compression;
|
|
|
|
|
using Microsoft.VisualBasic;
|
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
|
|
|
|
|
namespace UMC.ITME
|
|
|
|
|
{
|
|
|
|
@ -108,7 +109,7 @@ namespace UMC.ITME
|
|
|
|
|
|
|
|
|
|
this.RawUrl = ReplaceRawUrl(this.RawUrl);
|
|
|
|
|
|
|
|
|
|
this.StartTime = UMC.Data.Reflection.TimeSpanMilli(DateTime.Now);
|
|
|
|
|
// this.StartTime = UMC.Data.Reflection.TimeSpanMilli(DateTime.Now);
|
|
|
|
|
}
|
|
|
|
|
private HttpProxy(HttpProxy proxy, SiteConfig siteConfig)
|
|
|
|
|
{
|
|
|
|
@ -846,7 +847,7 @@ namespace UMC.ITME
|
|
|
|
|
int statusCode = Convert.ToInt32(res.StatusCode);
|
|
|
|
|
if (statusCode >= 500)
|
|
|
|
|
{
|
|
|
|
|
LogWrite(this.Context, this.Site, statusCode, String.Format("{0} {1}", Method, getUrl.PathAndQuery), this.SiteCookie.Account, 0, res.Headers, this._AttachmentFile);
|
|
|
|
|
LogWrite(this.Context, this.Site, statusCode, String.Format("{0} {1}", Method, getUrl.PathAndQuery), this.SiteCookie.Account, res.Headers, this._AttachmentFile);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -971,7 +972,7 @@ namespace UMC.ITME
|
|
|
|
|
int statusCode = Convert.ToInt32(res.StatusCode);
|
|
|
|
|
if (statusCode >= 500)
|
|
|
|
|
{
|
|
|
|
|
LogWrite(this.Context, this.Site, statusCode, String.Format("{0} {1}", Method, getUrl.PathAndQuery), this.SiteCookie.Account, 0, res.Headers, this._AttachmentFile);
|
|
|
|
|
LogWrite(this.Context, this.Site, statusCode, String.Format("{0} {1}", Method, getUrl.PathAndQuery), this.SiteCookie.Account, res.Headers, this._AttachmentFile);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (res.StatusCode != HttpStatusCode.OK)
|
|
|
|
@ -2230,7 +2231,7 @@ namespace UMC.ITME
|
|
|
|
|
int statusCode = Convert.ToInt32(httpResponse.StatusCode);
|
|
|
|
|
if (statusCode >= 500)
|
|
|
|
|
{
|
|
|
|
|
LogWrite(this.Context, this.Site, statusCode, String.Format("{0} {1}", Method, getUrl.PathAndQuery), this.SiteCookie.Account, 0, httpResponse.Headers, _AttachmentFile);
|
|
|
|
|
LogWrite(this.Context, this.Site, statusCode, String.Format("{0} {1}", Method, getUrl.PathAndQuery), this.SiteCookie.Account, httpResponse.Headers, _AttachmentFile);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (this.IsLog == true)
|
|
|
|
@ -2838,41 +2839,60 @@ namespace UMC.ITME
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void LogWrite(NetContext context, SiteConfig config, int statusCode, String pathAndQuery, string account, int duration, NameValueCollection reHeaders, String attachmentFile)
|
|
|
|
|
public static void LogWrite(NetContext context, SiteConfig config, string account, NameValueCollection reHeaders, String attachmentFile)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var logSetting = LogSetting.Instance();
|
|
|
|
|
if (logSetting.IsWriter)
|
|
|
|
|
{
|
|
|
|
|
var webMeta = new WebMeta();
|
|
|
|
|
var logs = System.Buffers.ArrayPool<String>.Shared.Rent(config.LogConf.Cookies.Length + config.LogConf.Headers.Length + config.LogConf.ResHeaders.Length + 24);
|
|
|
|
|
int logSize = 1;
|
|
|
|
|
logs[0] = config.Root;
|
|
|
|
|
|
|
|
|
|
if (String.IsNullOrEmpty(account) == false)
|
|
|
|
|
{
|
|
|
|
|
webMeta.Put("Account", account);
|
|
|
|
|
}
|
|
|
|
|
var time = (int)((UMC.Data.Reflection.TimeSpanMilli(DateTime.Now) - duration) / 1000);
|
|
|
|
|
if (context.UrlReferrer != null)
|
|
|
|
|
{
|
|
|
|
|
webMeta.Put("Referrer", context.UrlReferrer.AbsoluteUri);
|
|
|
|
|
logs[logSize++] = "Account";
|
|
|
|
|
logs[logSize++] = account;
|
|
|
|
|
}
|
|
|
|
|
if (String.IsNullOrEmpty(attachmentFile) == false)
|
|
|
|
|
{
|
|
|
|
|
webMeta.Put("Attachment", attachmentFile);
|
|
|
|
|
logs[logSize++] = "Attachment";
|
|
|
|
|
logs[logSize++] = attachmentFile;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
foreach (var u in config.LogConf.Cookies)
|
|
|
|
|
{
|
|
|
|
|
webMeta[u] = context.Cookies[u];
|
|
|
|
|
logs[logSize++] = u;
|
|
|
|
|
logs[logSize++] = context.Cookies[u];
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var u in config.LogConf.Headers)
|
|
|
|
|
{
|
|
|
|
|
webMeta[u] = context.Headers[u];
|
|
|
|
|
logs[logSize++] = u;
|
|
|
|
|
logs[logSize++] = context.Headers[u];
|
|
|
|
|
}
|
|
|
|
|
if (reHeaders != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var u in config.LogConf.ResHeaders)
|
|
|
|
|
{
|
|
|
|
|
webMeta[u] = reHeaders[u];
|
|
|
|
|
logs[logSize++] = u;
|
|
|
|
|
logs[logSize++] = reHeaders[u];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
HttpMimeContext httpMimeContext = (HttpMimeContext)context;
|
|
|
|
|
httpMimeContext.WriteLog(logs, logSize);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public static void LogWrite(NetContext context, SiteConfig config, int statusCode, String pathAndQuery, string account, NameValueCollection reHeaders, String attachmentFile)
|
|
|
|
|
{
|
|
|
|
|
var logSetting = LogSetting.Instance();
|
|
|
|
|
if (logSetting.IsWriter)
|
|
|
|
|
{
|
|
|
|
|
var logs = System.Buffers.ArrayPool<String>.Shared.Rent(config.LogConf.Cookies.Length + config.LogConf.Headers.Length + config.LogConf.ResHeaders.Length + 24);
|
|
|
|
|
int logSize = 1;
|
|
|
|
|
logs[0] = config.Root;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (context.Token != null)
|
|
|
|
|
{
|
|
|
|
@ -2881,16 +2901,64 @@ namespace UMC.ITME
|
|
|
|
|
{
|
|
|
|
|
username = $"G:{UMC.Data.Utility.IntParse((context.Token.UserId ?? context.Token.Device).Value)}";
|
|
|
|
|
}
|
|
|
|
|
webMeta.Put("Username", username);
|
|
|
|
|
logs[logSize++] = "Username";
|
|
|
|
|
logs[logSize++] = username;
|
|
|
|
|
}
|
|
|
|
|
webMeta.Put("Address", context.UserHostAddress).Put("Server", context.Server).Put("UserAgent", context.UserAgent)
|
|
|
|
|
.Put("Path", pathAndQuery)
|
|
|
|
|
.Put("Duration", duration)
|
|
|
|
|
.Put("Site", config.Root)
|
|
|
|
|
.Put("Time", time)
|
|
|
|
|
.Put("Status", statusCode);
|
|
|
|
|
|
|
|
|
|
logSetting.Write(webMeta);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logs[logSize++] = "Address";
|
|
|
|
|
logs[logSize++] = context.UserHostAddress;
|
|
|
|
|
|
|
|
|
|
logs[logSize++] = "Server";
|
|
|
|
|
logs[logSize++] = context.Server;
|
|
|
|
|
|
|
|
|
|
logs[logSize++] = "UserAgent";
|
|
|
|
|
logs[logSize++] = context.UserAgent;
|
|
|
|
|
|
|
|
|
|
logs[logSize++] = "Path";
|
|
|
|
|
logs[logSize++] = pathAndQuery;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logs[logSize++] = "Status";
|
|
|
|
|
logs[logSize++] = statusCode.ToString();
|
|
|
|
|
|
|
|
|
|
logs[logSize++] = "Referrer";
|
|
|
|
|
logs[logSize++] = context.UrlReferrer?.AbsoluteUri;
|
|
|
|
|
|
|
|
|
|
if (String.IsNullOrEmpty(account) == false)
|
|
|
|
|
{
|
|
|
|
|
logs[logSize++] = "Account";
|
|
|
|
|
logs[logSize++] = account;
|
|
|
|
|
}
|
|
|
|
|
if (String.IsNullOrEmpty(attachmentFile) == false)
|
|
|
|
|
{
|
|
|
|
|
logs[logSize++] = "Attachment";
|
|
|
|
|
logs[logSize++] = attachmentFile;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
foreach (var u in config.LogConf.Cookies)
|
|
|
|
|
{
|
|
|
|
|
logs[logSize++] = u;
|
|
|
|
|
logs[logSize++] = context.Cookies[u];
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var u in config.LogConf.Headers)
|
|
|
|
|
{
|
|
|
|
|
logs[logSize++] = u;
|
|
|
|
|
logs[logSize++] = context.Headers[u];
|
|
|
|
|
}
|
|
|
|
|
if (reHeaders != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var u in config.LogConf.ResHeaders)
|
|
|
|
|
{
|
|
|
|
|
logs[logSize++] = u;
|
|
|
|
|
logs[logSize++] = reHeaders[u];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
logSetting.Write(logs, 0, logSize);
|
|
|
|
|
System.Buffers.ArrayPool<String>.Shared.Return(logs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -3153,12 +3221,13 @@ namespace UMC.ITME
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
UMC.Security.Identity User;
|
|
|
|
|
long StartTime;
|
|
|
|
|
// long StartTime;
|
|
|
|
|
|
|
|
|
|
public void ProcessEnd()
|
|
|
|
|
{
|
|
|
|
|
LogWrite(this.Context, this.Site, this.SiteCookie.Account, m_HttpHeaders, _AttachmentFile);
|
|
|
|
|
|
|
|
|
|
LogWrite(this.Context, this.Site, this.Context.StatusCode, String.Format("{0} {1}", Context.HttpMethod, this.RawUrl), this.SiteCookie.Account, (int)(UMC.Data.Reflection.TimeSpanMilli(DateTime.Now) - StartTime), m_HttpHeaders, _AttachmentFile);
|
|
|
|
|
// LogWrite(this.Context, this.Site, this.Context.StatusCode, String.Format("{0} {1}", Context.HttpMethod, this.RawUrl), this.SiteCookie.Account, (int)(UMC.Data.Reflection.TimeSpanMilli(DateTime.Now) - StartTime), m_HttpHeaders, _AttachmentFile);
|
|
|
|
|
|
|
|
|
|
this.SaveCookie();
|
|
|
|
|
if (this.IsLog && User.IsAuthenticated)
|
|
|
|
@ -3185,7 +3254,7 @@ namespace UMC.ITME
|
|
|
|
|
AuthBridge(this.Context.Headers);
|
|
|
|
|
}
|
|
|
|
|
internal void AuthBridge(NameValueCollection heaers)
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var user = this.User;
|
|
|
|
|
switch (this.Site.Site.UserModel)
|
|
|
|
|