Added a basic mechanism for statistic tracking.
This commit is contained in:
parent
2f407b14f6
commit
e90d4e8972
1 changed files with 42 additions and 2 deletions
|
|
@ -36,6 +36,7 @@ using System.Threading;
|
||||||
using Community.CsharpSqlite.SQLiteClient;
|
using Community.CsharpSqlite.SQLiteClient;
|
||||||
using Hooks;
|
using Hooks;
|
||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using Rests;
|
using Rests;
|
||||||
using Terraria;
|
using Terraria;
|
||||||
using TShockAPI.DB;
|
using TShockAPI.DB;
|
||||||
|
|
@ -115,7 +116,6 @@ namespace TShockAPI
|
||||||
#endif
|
#endif
|
||||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -218,7 +218,44 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RestObject RestApi_Verify(string username, string password)
|
private void callHome()
|
||||||
|
{
|
||||||
|
string fp;
|
||||||
|
if (!File.Exists(Path.Combine(SavePath, "fingerprint")))
|
||||||
|
{
|
||||||
|
fp = "";
|
||||||
|
int random = Utils.Random.Next(500000, 1000000);
|
||||||
|
fp += random;
|
||||||
|
|
||||||
|
fp = Utils.HashPassword(Netplay.serverIP + fp + Netplay.serverPort + Netplay.serverListenIP);
|
||||||
|
TextWriter tw = new StreamWriter(Path.Combine(SavePath, "fingerprint"));
|
||||||
|
tw.Write(fp);
|
||||||
|
tw.Close();
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
fp = "";
|
||||||
|
TextReader tr = new StreamReader(Path.Combine(SavePath, "fingerprint"));
|
||||||
|
fp = tr.ReadToEnd();
|
||||||
|
tr.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var client = new WebClient())
|
||||||
|
{
|
||||||
|
client.Headers.Add("user-agent",
|
||||||
|
"TShock (" + VersionNum + ")");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string response = client.DownloadString("http://tshock.co/tickto.php?fp=" + fp + "&ver=" + VersionNum + "&port=" + Netplay.serverPort);
|
||||||
|
Console.WriteLine("Registered with stat tracker: " + response);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.Error(e.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RestObject RestApi_Verify(string username, string password)
|
||||||
{
|
{
|
||||||
var userAccount = TShock.Users.GetUserByName(username);
|
var userAccount = TShock.Users.GetUserByName(username);
|
||||||
if (userAccount == null)
|
if (userAccount == null)
|
||||||
|
|
@ -390,6 +427,9 @@ namespace TShockAPI
|
||||||
Regions.ReloadAllRegions();
|
Regions.ReloadAllRegions();
|
||||||
if (Config.RestApiEnabled)
|
if (Config.RestApiEnabled)
|
||||||
RestApi.Start();
|
RestApi.Start();
|
||||||
|
Console.ForegroundColor = ConsoleColor.Cyan;
|
||||||
|
callHome();
|
||||||
|
Console.ForegroundColor = ConsoleColor.Gray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue