Client UUID Implementation: Bans and User Auth.

Send ServerSideCharacter flag if set in WorldInfo.
This commit is contained in:
Zidonuke Ghost 2013-10-01 04:35:49 -04:00
parent 2569c10823
commit b2a8198bb1
12 changed files with 158 additions and 26 deletions

View file

@ -34,6 +34,7 @@ namespace TShockAPI.DB
var table = new SqlTable("Bans",
new SqlColumn("IP", MySqlDbType.String, 16) {Primary = true},
new SqlColumn("Name", MySqlDbType.Text),
new SqlColumn("UUID", MySqlDbType.Text),
new SqlColumn("Reason", MySqlDbType.Text),
new SqlColumn("BanningUser", MySqlDbType.Text),
new SqlColumn("Date", MySqlDbType.Text),
@ -61,7 +62,7 @@ namespace TShockAPI.DB
using (var reader = database.QueryReader("SELECT * FROM Bans WHERE IP=@0", ip))
{
if (reader.Read())
return new Ban(reader.Get<string>("IP"), reader.Get<string>("Name"), reader.Get<string>("Reason"), reader.Get<string>("BanningUser"), reader.Get<string>("Date"), reader.Get<string>("Expiration"));
return new Ban(reader.Get<string>("IP"), reader.Get<string>("Name"), reader.Get<string>("UUID"), reader.Get<string>("Reason"), reader.Get<string>("BanningUser"), reader.Get<string>("Date"), reader.Get<string>("Expiration"));
}
}
catch (Exception ex)
@ -80,7 +81,7 @@ namespace TShockAPI.DB
{
while (reader.Read())
{
banlist.Add(new Ban(reader.Get<string>("IP"), reader.Get<string>("Name"), reader.Get<string>("Reason"), reader.Get<string>("BanningUser"), reader.Get<string>("Date"), reader.Get<string>("Expiration")));
banlist.Add(new Ban(reader.Get<string>("IP"), reader.Get<string>("Name"), reader.Get<string>("UUID"), reader.Get<string>("Reason"), reader.Get<string>("BanningUser"), reader.Get<string>("Date"), reader.Get<string>("Expiration")));
}
return banlist;
}
@ -103,7 +104,24 @@ namespace TShockAPI.DB
using (var reader = database.QueryReader("SELECT * FROM Bans WHERE " + namecol + "=@0", name))
{
if (reader.Read())
return new Ban(reader.Get<string>("IP"), reader.Get<string>("Name"), reader.Get<string>("Reason"), reader.Get<string>("BanningUser"), reader.Get<string>("Date"), reader.Get<string>("Expiration"));
return new Ban(reader.Get<string>("IP"), reader.Get<string>("Name"), reader.Get<string>("UUID"), reader.Get<string>("Reason"), reader.Get<string>("BanningUser"), reader.Get<string>("Date"), reader.Get<string>("Expiration"));
}
}
catch (Exception ex)
{
Log.Error(ex.ToString());
}
return null;
}
public Ban GetBanByUUID(string uuid)
{
try
{
using (var reader = database.QueryReader("SELECT * FROM Bans WHERE UUID=@0", uuid))
{
if (reader.Read())
return new Ban(reader.Get<string>("IP"), reader.Get<string>("Name"), reader.Get<string>("UUID"), reader.Get<string>("Reason"), reader.Get<string>("BanningUser"), reader.Get<string>("Date"), reader.Get<string>("Expiration"));
}
}
catch (Exception ex)
@ -120,11 +138,11 @@ namespace TShockAPI.DB
return AddBan(ip, name, reason, false, "", "");
}
#endif
public bool AddBan(string ip, string name = "", string reason = "", bool exceptions = false, string banner = "", string expiration = "")
public bool AddBan(string ip, string name = "", string uuid = "", string reason = "", bool exceptions = false, string banner = "", string expiration = "")
{
try
{
return database.Query("INSERT INTO Bans (IP, Name, Reason, BanningUser, Date, Expiration) VALUES (@0, @1, @2, @3, @4, @5);", ip, name, reason, banner, DateTime.UtcNow.ToString("s"), expiration) != 0;
return database.Query("INSERT INTO Bans (IP, Name, UUID Reason, BanningUser, Date, Expiration) VALUES (@0, @1, @2, @3, @4, @5, @6);", ip, name, uuid, reason, banner, DateTime.UtcNow.ToString("s"), expiration) != 0;
}
catch (Exception ex)
{
@ -181,6 +199,8 @@ namespace TShockAPI.DB
public string Name { get; set; }
public string UUID { get; set; }
public string Reason { get; set; }
public string BanningUser { get; set; }
@ -189,10 +209,11 @@ namespace TShockAPI.DB
public string Expiration { get; set; }
public Ban(string ip, string name, string reason, string banner, string date, string exp)
public Ban(string ip, string name, string uuid, string reason, string banner, string date, string exp)
{
IP = ip;
Name = name;
UUID = UUID;
Reason = reason;
BanningUser = banner;
Date = date;
@ -203,6 +224,7 @@ namespace TShockAPI.DB
{
IP = string.Empty;
Name = string.Empty;
UUID = string.Empty;
Reason = string.Empty;
BanningUser = "";
Date = "";