removed password checking and registration

This commit is contained in:
timerix 2022-10-15 01:29:19 +06:00
parent d41e4207e0
commit fde80452de
4 changed files with 13 additions and 121 deletions

View File

@ -122,38 +122,16 @@ internal static partial class Launcher
RenderTab(tabs.Login); RenderTab(tabs.Login);
} }
break; break;
case ConsoleKey.P:
if (tabs.Current == tabs.Login)
{
tabs.Login = tabs.Login
.Remove(991, 20).Insert(991, "┏━━━━━━━━━━━━━━━━━━┓")
.Remove(1071, 20).Insert(1071, "┃ ┃")
.Remove(1151, 20).Insert(1151, "┗━━━━━━━━━━━━━━━━━━┛");
RenderTab(tabs.Login);
var password = ReadString(33, 13, 15);
tabs.Login = tabs.Login
.Remove(991, 20).Insert(991, "┌──────────────────┐")
.Remove(1071, 20).Insert(1071, "│ │")
.Remove(1151, 20).Insert(1151, "└──────────────────┘");
RenderTab(tabs.Login);
if (password.Length < 8)
throw new Exception("password length should be > 7 and < 17");
password_hash = hasher.HashCycled(password.ToBytes(), 64);
tabs.Login = tabs.Login.Remove(1073, password.Length)
.Insert(1073, "*".Multiply(password.Length));
RenderTab(tabs.Login);
}
break;
case ConsoleKey.L: case ConsoleKey.L:
if (tabs.Current == tabs.Login) if (tabs.Current == tabs.Login)
{ {
RenderTab(tabs.Current); RenderTab(tabs.Current);
if (username.Length < 5) throw new Exception("username is too short"); if (username.Length < 2) throw new Exception("username is too short");
if (password_hash.Length == 0) throw new Exception("pasword is null");
// обновление клиента // обновление клиента
if (!offline) if (!offline)
{ {
Connect(hasher.HashCycled(username.ToBytes(), password_hash, 64), "launcher"); Connect("updater".ToBytes(), "updater");
//обновление файлов клиента //обновление файлов клиента
Info.Log("b", "updating client..."); Info.Log("b", "updating client...");
FSP.DownloadByManifest("download_if_not_exist", Directory.GetCurrent()); FSP.DownloadByManifest("download_if_not_exist", Directory.GetCurrent());
@ -166,7 +144,6 @@ internal static partial class Launcher
Info.Log("g", "client updated"); Info.Log("g", "client updated");
} }
config.Save();
// запуск майнкрафта // запуск майнкрафта
Info.Log("g", "launching minecraft"); Info.Log("g", "launching minecraft");
LaunchGame(config.JavaPath, config.Username, config.UUID, LaunchGame(config.JavaPath, config.Username, config.UUID,
@ -175,28 +152,6 @@ internal static partial class Launcher
Info.Log("b", "minecraft closed"); Info.Log("b", "minecraft closed");
} }
break; break;
case ConsoleKey.R:
if (tabs.Current == tabs.Login && !offline)
{
RenderTab(tabs.Current);
if (username.Length < 5) throw new Exception("username is too short");
if (password_hash.Length == 0) throw new Exception("pasword is null");
Connect("updater".ToBytes(), "updater");
mainSocket.SendPackage("register new user".ToBytes());
mainSocket.GetAnswer("ready");
mainSocket.SendPackage(hasher.HashCycled(username.ToBytes(), password_hash, 64));
mainSocket.SendPackage(username.ToBytes());
Thread.Sleep(300);
Console.Write(".");
Thread.Sleep(300);
Console.Write(".");
Thread.Sleep(300);
Console.Write(".");
Thread.Sleep(300);
Console.Write(".");
Info.Log("g", "registration request sent");
}
break;
case ConsoleKey.F2: case ConsoleKey.F2:
tabs.Log = File.ReadAllText(Info.LogfileName); tabs.Log = File.ReadAllText(Info.LogfileName);
RenderTab(tabs.Log, 9999); RenderTab(tabs.Log, 9999);

View File

@ -10,13 +10,13 @@
┃ ┌──────────────────┐ ┃ ┃ ┌──────────────────┐ ┃
┃ [N] nickname:│ │ ┃ ┃ [N] nickname:│ │ ┃
┃ └──────────────────┘ ┃ ┃ └──────────────────┘ ┃
┃ ┌──────────────────┐ ┃
┃ [P] password:│ │ ┃
┃ └──────────────────┘ ┃
┃ ┃ ┃ ┃
┃ ┏━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━┓ ┃ ┃ ┏━━━━━━━━━━━━━━━━┓ ┃
┃ ┃ [L] login ┃ ┃ [R] register ┃ ┃ ┃ ┃ [L] login ┃ ┃
┃ ┗━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━┛ ┃ ┃ ┗━━━━━━━━━━━━━━━━┛ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃ ┃ ┃
┃ ┃ ┃ ┃
┃ ┃ ┃ ┃

View File

@ -3,7 +3,7 @@
┣━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━┫ ┣━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━┫
┃ ┃ ┃ ┃
┃ ┃ ┃ ┃
гыгыг
┃ ┃ ┃ ┃
┃ я ещё не добавил настройки ┃ ┃ я ещё не добавил настройки ┃
┃ ┃ ┃ ┃

View File

@ -83,62 +83,13 @@ static class Server
switch (request) switch (request)
{ {
case "requesting launcher update": case "requesting launcher update":
Info.Log("b", "updater requested launcher update"); Info.Log("c","updater", "b", " requested launcher update");
fsp.UploadFile("share\\minecraft-launcher.exe"); fsp.UploadFile("share\\minecraft-launcher.exe");
break; break;
case "register new user":
Info.Log("b", "new user registration requested");
handlerSocket.SendPackage("ready".ToBytes());
var req = StringConverter.MergeToString(
hasher.HashCycled(handlerSocket.GetPackage(), 64).HashToString(),
":\n{\n\tusername: \"", handlerSocket.GetPackage().BytesToString(),
"\";\n\tuuid: \"null\";\n};");
var filepath = $"registration_requests\\{DateTime.Now.ToString(MyTimeFormat.ForFileNames)}.req";
File.WriteAllText(filepath, req);
Info.Log("b", "text wrote to file <", "c", $"registration_requests\\{filepath}", "b", ">");
break;
default:
throw new Exception("unknown request: " + request);
}
}
else Thread.Sleep(10);
}
}
// запрос от юзера
if (TryFindUser(hash, out var user))
{
Info.Log("b", "user is ", "c", user.name);
handlerSocket.SendPackage("launcher".ToBytes());
// обработка запросов
while (true)
{
if (handlerSocket.Available >= 2)
{
var request = handlerSocket.GetPackage().BytesToString();
switch (request)
{
case "requesting file download": case "requesting file download":
var file = handlerSocket.GetPackage().BytesToString(); var file = handlerSocket.GetPackage().BytesToString();
Info.Log("b", "user ", "c", user.name, "b", " requested file ", "c", file + ""); Info.Log("b", "user ", "c","updater", "b", " requested file ", "c", file + "");
if (file == "manifest.dtsod") fsp.UploadFile($"share\\{file}");
{
lock (manifestLocker) fsp.UploadFile("share\\manifest.dtsod");
}
else fsp.UploadFile("share\\" + file);
break;
case "requesting uuid":
Info.Log("b", "user ", "c", user.name, "b", " requested uuid");
handlerSocket.SendPackage(user.uuid.ToBytes());
break;
case "excess files found":
Info.Log("b", "user ", "c", user.name, "b", " sent excess files list");
fsp.DownloadFile($"excesses\\{user.name}-{DateTime.Now.ToString(MyTimeFormat.ForFileNames)}.txt");
break;
case "sending launcher error":
Info.Log("y", "user ", "c", user.name, "y", "is sending error:");
string error = handlerSocket.GetPackage().BytesToString();
Info.Log("y", error + '\n');
break; break;
default: default:
throw new Exception("unknown request: " + request); throw new Exception("unknown request: " + request);
@ -186,18 +137,4 @@ static class Server
+"\"];"); +"\"];");
} }
} }
static bool TryFindUser(byte[] hash, out (string name, string uuid) user)
{
DtsodV23 usersdb = new(File.ReadAllText("users.dtsod"));
user = new();
if (usersdb.ContainsKey(hash.HashToString()))
{
user.name = usersdb[hash.HashToString()]["username"];
user.uuid = usersdb[hash.HashToString()]["uuid"];
return true;
}
return false;
}
} }