Implement Cardmng shims

This commit is contained in:
BtbN 2019-06-01 00:49:01 +02:00
parent 942f5e5861
commit e84c4c8182
2 changed files with 57 additions and 3 deletions

View File

@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Xml.Linq;
using Microsoft.AspNetCore.Mvc;
using ClanServer.Formatters;
using ClanServer.Routing;
namespace ClanServer.Controllers.Core
{
[ApiController, Route("core")]
public class CardmngController : ControllerBase
{
[HttpPost, XrpcCall("cardmng.inquire")]
public ActionResult<EamuseXrpcData> Inquire([FromBody] EamuseXrpcData data)
{
string cardid = data.Document.Element("call").Element("cardmng").Attribute("cardid").Value;
string cardType = data.Document.Element("call").Element("cardmng").Attribute("cardtype").Value;
string update = data.Document.Element("call").Element("cardmng").Attribute("update").Value;
if (update != "") // TODO: actually register cards
{
data.Document = new XDocument(new XElement("response", new XElement("cardmng",
new XAttribute("binded", "1"),
new XAttribute("dataid", "DD389C3FFB6F47BA"),
new XAttribute("refid", "DD389C3FFB6F47BA"),
new XAttribute("ecflag", "1"),
new XAttribute("newflag", "0"),
new XAttribute("expired", "0")
)));
}
else
{
data.Document = new XDocument(new XElement("response", new XElement("cardmng",
new XAttribute("status", "112")
)));
}
return data;
}
[HttpPost, XrpcCall("cardmng.authpass")]
public ActionResult<EamuseXrpcData> Authpass([FromBody] EamuseXrpcData data)
{
data.Document = new XDocument(new XElement("response", new XElement("cardmng",
new XAttribute("status", "0")
)));
return data;
}
}
}

View File

@ -15,9 +15,9 @@ namespace eAmuseTest
{
static void Main(string[] args)
{
string compress = "lz77";
string eamuse_info = "1-5cf049c8-6ec5";
byte[] data = HexToBytes("6e84f02c117651c66313a5c17fa0ddc40e3f4cd52a94bd34f460e763f610e03d5d01f876");
string compress = "none";
string eamuse_info = "1-5cf04a26-56c5";
byte[] data = HexToBytes("a7a4eef0f58176b89e5f6d0c91df45549f0fdb12a7ea731e9f2f52a85db742ed71eceeee848cfcedf8ca2b59161900ba");
compress = compress.ToLower();