Skip to content
This repository has been archived by the owner on Sep 19, 2021. It is now read-only.

Commit

Permalink
Patch 4.4 updates and API Key checking.
Browse files Browse the repository at this point in the history
  • Loading branch information
vekien committed Sep 19, 2018
1 parent 54d01fa commit 6a52c55
Show file tree
Hide file tree
Showing 5 changed files with 290 additions and 248 deletions.
38 changes: 30 additions & 8 deletions Mappy/API.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,30 @@ static class API
private static int total = 0;
private static bool requestInAction = false;

//
// Submit data
//
/// <summary>
/// Check an API key can submit data to XIVAPI
/// </summary>
/// <param name="key"></param>
public static async void CheckApiKey(string key)
{
try
{
Logger.Add("Validating XIVAPI key...");

dynamic response = await $"http://xivapi.local/mappy/verify?key={key}".GetJsonAsync();
App.Instance.ToggleSubmitting(response.allowed);
}
catch (Exception ex)
{
Logger.Exception(ex, "Mappy -> CheckApiKey");
}
}

/// <summary>
/// Submit some data (Even if you hard code this, there are server checks XD)
/// </summary>
/// <param name="type"></param>
/// <param name="data"></param>
public static async void SubmitData(string type, List<Entity> data)
{
// if submit turned off
Expand All @@ -39,9 +60,9 @@ public static async void SubmitData(string type, List<Entity> data)

try {
// submit to api
await "http://xivapi.local/data/submit".PostJsonAsync(new
string key = Properties.Settings.Default.ApiKey;
await $"http://xivapi.local/mappy/submit?key={key}".PostJsonAsync(new
{
key = Properties.Settings.Default.ApiKey,
id,
type,
data,
Expand All @@ -53,9 +74,10 @@ public static async void SubmitData(string type, List<Entity> data)
}
}

//
// Get map image list
//
/// <summary>
/// Get map image from XIVAPI
/// </summary>
/// <param name="id"></param>
public static async void GetMapImage(uint id)
{
// if a request is in action or id is zero, do nothing
Expand Down
5 changes: 2 additions & 3 deletions Mappy/App.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions Mappy/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ private void Initialized()
};
aTimer.Interval = Properties.Settings.Default.ScanTimerSpeed;
aTimer.Enabled = true;

// check key
API.CheckApiKey(Properties.Settings.Default.ApiKey);
}

#region Log View Window
Expand Down Expand Up @@ -321,6 +324,18 @@ private void BtnOpenDebug_Click(object sender, EventArgs e)

#region Settings

public void ToggleSubmitting(bool enable)
{
Settings_Submit.Checked = enable;
Properties.Settings.Default.Submit = Settings_Submit.Checked;
Properties.Settings.Default.Save();

Logger.Add(enable
? "XIVAPI key enabled! Data will submit. If you have enabled the API key after memory scan, you will need to restart the app to pickup the existing data."
: "XIVAPI key does not have permission to submit data. Ask @Vekien for permission!"
);
}

private void LoadSettings()
{
TopMost = Properties.Settings.Default.AlwaysOnTop;
Expand All @@ -338,12 +353,17 @@ private void Settings_Submit_CheckedChanged(object sender, EventArgs e)
{
Properties.Settings.Default.Submit = Settings_Submit.Checked;
Properties.Settings.Default.Save();

if (Settings_Submit.Checked) {
API.CheckApiKey(Properties.Settings.Default.ApiKey);
}
}

private void Settings_AlwaysOnTop_CheckedChanged(object sender, EventArgs e)
{
Properties.Settings.Default.AlwaysOnTop = Settings_AlwaysOnTop.Checked;
Properties.Settings.Default.Save();

}

private void Settings_MapBoundaries_CheckedChanged(object sender, EventArgs e)
Expand Down
123 changes: 61 additions & 62 deletions signatures-x64.json
Original file line number Diff line number Diff line change
@@ -1,149 +1,148 @@
[
{
"Key": "MAPINFO",
"Value": "E8********CCCCCCCCCC48895C2408574883EC208B05",
"Key": "TARGET",
"Value": "41bc000000e041bd01000000493bc47555488d0d",
"ASMSignature": true,
"PointerPath": [
0,
16
144
]
},
{
"Key": "ZONEINFO",
"Value": "8B9084000000E8****0000EB**833D******000275**833D******000075**833D******000074**48C705",
"Key": "CHATLOG",
"Value": "e8********85c0740e488b0d********33D2E8********488b0d",
"ASMSignature": true,
"PointerPath": [
0,
-4
0,
48,
908
]
},

{
"Key": "CHARMAP",
"Value": "488b420848c1e8033da701000077248bc0488d0d",
"ASMSignature": true,
"Key": "TARGET",
"PointerPath": [
0,
144
],
"Value": "41bc000000e041bd01000000493bc47555488d0d"
0
]
},
{
"Key": "PARTYMAP",
"Value": "488D7C242066660F1F840000000000488B17488D0D",
"ASMSignature": true,
"Key": "CHATLOG",
"PointerPath": [
0,
0,
48,
908
],
"Value": "e8********85c0740e488b0d********33D2E8********488b0d"
752
]
},
{
"Key": "PARTYCOUNT",
"Value": "488D7C242066660F1F840000000000488B17488D0D",
"ASMSignature": true,
"Key": "CHARMAP",
"PointerPath": [
0,
0
],
"Value": "488b420848c1e8033da701000077248bc0488d0d"
-26920
]
},
{
"Key": "MAPINFO",
"Value": "E8********CCCCCCCCCC48895C2408574883EC208B05",
"ASMSignature": true,
"Key": "PARTYMAP",
"PointerPath": [
0,
384
],
"Value": "488D7C242066660F1F840000000000488B17488D0D"
16
]
},
{
"Key": "ZONEINFO",
"Value": "8B9084000000E8****0000EB**833D******000275**833D******000075**833D******000074**48C705",
"ASMSignature": true,
"Key": "PARTYCOUNT",
"PointerPath": [
0,
14784
],
"Value": "488D7C242066660F1F840000000000488B17488D0D"
-4
]
},
{
"ASMSignature": true,
"Key": "PLAYERINFO",
"Value": "83f9ff7412448b048e8bd3488d0d",
"ASMSignature": true,
"PointerPath": [
0,
0
],
"Value": "83f9ff7412448b048e8bd3488d0d"
]
},
{
"ASMSignature": true,
"Key": "ENMITYMAP",
"Value": "83f9ff7412448b048e8bd3488d0d",
"ASMSignature": true,
"PointerPath": [
0,
-4656
],
"Value": "83f9ff7412448b048e8bd3488d0d"
]
},
{
"ASMSignature": true,
"Key": "ENMITY_COUNT",
"Value": "83f9ff7412448b048e8bd3488d0d",
"ASMSignature": true,
"PointerPath": [
0,
-2352
],
"Value": "83f9ff7412448b048e8bd3488d0d"
]
},
{
"ASMSignature": true,
"Key": "AGROMAP",
"Value": "83f9ff7412448b048e8bd3488d0d",
"ASMSignature": true,
"PointerPath": [
0,
-2344
],
"Value": "83f9ff7412448b048e8bd3488d0d"
]
},
{
"ASMSignature": true,
"Key": "AGRO_COUNT",
"Value": "83f9ff7412448b048e8bd3488d0d",
"ASMSignature": true,
"PointerPath": [
0,
-40
],
"Value": "83f9ff7412448b048e8bd3488d0d"
]
},
{
"ASMSignature": false,
"Key": "HOTBAR",
"Value": "9C640000000000002C2C000000000000",
"ASMSignature": false,
"PointerPath": [
0,
56,
48,
40,
32,
0,
56,
48,
40,
32,
0,
0
],
"Value": "F783843E****0000"
]
},
{
"ASMSignature": false,
"Key": "RECAST",
"Value": "9C640000000000002C2C000000000000",
"ASMSignature": false,
"PointerPath": [
0,
56,
24,
48,
32,
56,
24,
48,
32,
60
],
"Value": "F783843E****0000"
]
},
{
"ASMSignature": true,
"Key": "INVENTORY",
"Value": "48895C2408488974241048897C2418488B3D",
"ASMSignature": true,
"PointerPath": [
0,
0
],
"Value": "48895C2408488974241048897C2418488B3D"
]
}
]

0 comments on commit 6a52c55

Please sign in to comment.