1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-11 15:52:25 -05:00

Kayak works how I want it :) 'secure' authentication

This commit is contained in:
RaidMax
2015-08-23 22:35:04 -05:00
parent feb37123e2
commit 7ae6c7e07f
21 changed files with 83 additions and 176 deletions

View File

@ -43,6 +43,8 @@ namespace Webfront_Plugin
if (querySet["server"] != null)
requestedServer = activeServers.Find(x => x.pID() == Int32.Parse(querySet["server"]));
else
requestedServer = activeServers.First();
if (querySet["page"] != null)
requestPageNum = Int32.Parse(querySet["page"]);
@ -237,43 +239,47 @@ namespace Webfront_Plugin
continue;
buffer.Append("<tr>");
StringBuilder str = new StringBuilder();
StringBuilder Names = new StringBuilder();
List<Aliases> allAlliases = S.getAliases(Player);
List<String> nameAlias = new List<String>();
List<String> IPAlias = new List<String>();
foreach (Aliases A in allAlliases)
{
foreach (String Name in A.Names.Distinct())
nameAlias.Add(Name);
if (Authenticated)
{
foreach (String IP in A.IPS.Distinct())
IPAlias.Add(IP);
}
}
str.Append("<a href='#' class='pseudoLinkAlias'>Show Aliases</a>");
str.Append("<div class='playerAlias'>");
foreach (String Name in nameAlias.Distinct())
str.AppendFormat("<span>{0}</span><br/>", Utilities.stripColors(Name));
str.Append("</div>");
StringBuilder IPs = new StringBuilder();
if (Authenticated)
{
IPs.Append("<a href='#'><span class='pseudoLinkIP'><i>Show IPs</i></span></a>");
List<Aliases> allAlliases = S.getAliases(Player);
foreach (Aliases A in allAlliases)
{
foreach (String Name in A.Names.Distinct())
nameAlias.Add(Name);
foreach (String IP in A.IPS.Distinct())
IPAlias.Add(IP);
}
Names.Append("<a href='#' class='pseudoLinkAlias'>Show Aliases</a>");
Names.Append("<div class='playerAlias'>");
foreach (String Name in nameAlias.Distinct())
Names.AppendFormat("<span>{0}</span><br/>", Utilities.stripColors(Name));
Names.Append("</div>");
IPs.Append("<a href='#' class='pseudoLinkIP'>Show IPs</a>");
IPs.Append("<div class='playerIPs'>");
foreach (String IP in IPAlias)
IPs.AppendFormat("<span>{0}</span><br/>", IP);
IPs.Append("</div>");
}
else
if (!Authenticated)
{
Names.Append("Hidden");
IPs.Append("Hidden");
}
Int64 forumID = 0;
if (Player.npID.Length == 16)
{
@ -284,9 +290,9 @@ namespace Webfront_Plugin
String Screenshot = String.Empty;
//if (logged)
Screenshot = String.Format("<a href='http://server.nbsclan.org/screen.php?id={0}&name={1}' target='_blank'><div style='background-image:url(http://server.nbsclan.org/shutter.png); width: 20px; height: 20px;float: right; position:relative; right: 21%; background-size: contain;'></div></a>", forumID, Player.Name);
Screenshot = String.Format("<a href='http://server.nbsclan.org/screen.php?id={0}&name={1}' target='_blank'><div style='background-image:url(http://server.nbsclan.org/shutter.png); width: 20px; height: 20px;float: right; position:relative; right: 21%; background-size: contain;'></div></a>", forumID, Player.Name);
buffer.AppendFormat("<td><a style='float: left;' href='{9}'>{0}</a>{10}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td><td>{6} ago</td><td><a href='https://repziw4.de/memberlist.php?mode=viewprofile&u={7}'>{8}</a></td>", Player.Name, str, IPs, 0, SharedLibrary.Utilities.levelHTMLFormatted(Player.Level), Player.Connections, Player.getLastConnection(), forumID, Player.Name, "/player?id=" + Player.databaseID, Screenshot);
buffer.AppendFormat("<td><a style='float: left;' href='{9}'>{0}</a>{10}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td><td>{6} ago</td><td><a href='https://repziw4.de/memberlist.php?mode=viewprofile&u={7}'>{8}</a></td>", Player.Name, Names, IPs, 0, SharedLibrary.Utilities.levelHTMLFormatted(Player.Level), Player.Connections, Player.getLastConnection(), forumID, Player.Name, "/player?id=" + Player.databaseID, Screenshot);
buffer.Append("</tr>");
}

View File

@ -45,5 +45,13 @@ namespace Webfront_Plugin
{
get { return 0.1f; }
}
public override string Author
{
get
{
return "RaidMax";
}
}
}
}

View File

@ -13,40 +13,19 @@ namespace Webfront_Plugin
public static IScheduler webScheduler { get; private set; }
public static Framework webFront { get; private set; }
public static IPAddress lastIP;
public static IServer webServer;
public static void Init()
{
webScheduler = KayakScheduler.Factory.Create(new SchedulerDelegate());
var server = KayakServer.Factory.Create(new ServerDelegate(), webScheduler);
webServer = KayakServer.Factory.CreateHttp(new RequestDelegate(), webScheduler);
webFront = new Framework();
using (server.Listen(new IPEndPoint(IPAddress.Any, 1624)))
using (webServer.Listen(new IPEndPoint(IPAddress.Any, 1624)))
webScheduler.Start();
}
}
class HttpServerDelegate : IServerDelegate
{
IHttpRequestDelegate requestDelegate;
public HttpServerDelegate(IHttpRequestDelegate requestDelegate)
{
this.requestDelegate = requestDelegate;
}
public ISocketDelegate OnConnection(IServer server, ISocket socket)
{
// Kayak.Http.IHttpServerFactory
}
public void OnClose(IServer server)
{
}
}
class SchedulerDelegate : ISchedulerDelegate
{
public void OnException(IScheduler scheduler, Exception e)
@ -64,52 +43,9 @@ namespace Webfront_Plugin
{
public void OnRequest(HttpRequestHead request, IDataProducer requestBody, IHttpResponseDelegate response)
{
/*if (request.Method.ToUpperInvariant() == "POST" && request.Uri.StartsWith("/bufferedecho"))
{
// when you subecribe to the request body before calling OnResponse,
// the server will automatically send 100-continue if the client is
// expecting it.
requestBody.Connect(new BufferedConsumer(bufferedBody =>
{
var headers = new HttpResponseHead()
{
Status = "200 OK",
Headers = new Dictionary<string, string>()
{
{ "Content-Type", "text/plain" },
{ "Content-Length", request.Headers["Content-Length"] },
{ "Connection", "close" }
}
};
response.OnResponse(headers, new BufferedProducer(bufferedBody));
}, error =>
{
// XXX
// uh oh, what happens?
}));
}
else if (request.Method.ToUpperInvariant() == "POST" && request.Uri.StartsWith("/echo"))
{
var headers = new HttpResponseHead()
{
Status = "200 OK",
Headers = new Dictionary<string, string>()
{
{ "Content-Type", "text/plain" },
{ "Connection", "close" }
}
};
if (request.Headers.ContainsKey("Content-Length"))
headers.Headers["Content-Length"] = request.Headers["Content-Length"];
// if you call OnResponse before subscribing to the request body,
// 100-continue will not be sent before the response is sent.
// per rfc2616 this response must have a 'final' status code,
// but the server does not enforce it.
response.OnResponse(headers, requestBody);
}*/
DefaultKayakServer castCrap = (DefaultKayakServer)Manager.webServer;
Manager.lastIP = castCrap.clientAddress.Address;
string body = Manager.webFront.processRequest(request);
var headers = new HttpResponseHead()
{
@ -122,44 +58,6 @@ namespace Webfront_Plugin
};
response.OnResponse(headers, new BufferedProducer(body));
/*
if (request.Uri.StartsWith("/"))
{
var body = string.Format(
"Hello world.\r\nHello.\r\n\r\nUri: {0}\r\nPath: {1}\r\nQuery:{2}\r\nFragment: {3}\r\n",
request.Uri,
request.Path,
request.QueryString,
request.Fragment);
var headers = new HttpResponseHead()
{
Status = "200 OK",
Headers = new Dictionary<string, string>()
{
{ "Content-Type", "text/plain" },
{ "Content-Length", body.Length.ToString() },
}
};
response.OnResponse(headers, new BufferedProducer(body));
}
else
{
var responseBody = "The resource you requested ('" + request.Uri + "') could not be found.";
var headers = new HttpResponseHead()
{
Status = "404 Not Found",
Headers = new Dictionary<string, string>()
{
{ "Content-Type", "text/plain" },
{ "Content-Length", responseBody.Length.ToString() }
}
};
var body = new BufferedProducer(responseBody);
response.OnResponse(headers, body);
}*/
}
}