优化部分细节
This commit is contained in:
parent
8f2f5f79b6
commit
d888391758
@ -24,11 +24,11 @@ namespace Zerolauncher.Manager
|
||||
MessageBox.Show("正在更新游戏数据,请等待1-3秒。\n 请检查网络", "错误", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
return true;
|
||||
}
|
||||
if (UpDateManager.state)
|
||||
{
|
||||
UpDateManager.DoUpdate();
|
||||
return true;
|
||||
}
|
||||
//if (UpDateManager.state)
|
||||
//{
|
||||
// UpDateManager.DoUpdate();
|
||||
// return true;
|
||||
//}
|
||||
var key = AccToKey(account);
|
||||
if (mGame.ContainsKey(key)) { return false; }
|
||||
if (CacheSha.errorCode != 0) {
|
||||
@ -241,45 +241,47 @@ namespace Zerolauncher.Manager
|
||||
public static Process CheckEngineSafe(string mod)
|
||||
{
|
||||
bool is_first_luancher = EngineManager.CheckEmpy();
|
||||
if (mod == StaticHandleA.UpdateMode)
|
||||
{
|
||||
if (DataStream.dataStream.ecs.Length > 10)
|
||||
{
|
||||
string? now_bit;
|
||||
using (SHA256 sha256 = SHA256.Create())
|
||||
{
|
||||
using (FileStream fileStream = File.OpenRead(engine_file))
|
||||
{
|
||||
byte[] hashBytes = sha256.ComputeHash(fileStream);
|
||||
now_bit = BitConverter.ToString(hashBytes).Replace("-", string.Empty);
|
||||
}
|
||||
}
|
||||
if (DataStream.dataStream.ecs != now_bit)
|
||||
{
|
||||
Trace.WriteLine("lalalala" + DataStream.dataStream.ecs);
|
||||
throw new FileReadException("error esu1!");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!is_check && is_first_luancher)
|
||||
{
|
||||
string? now_bit;
|
||||
using (SHA256 sha256 = SHA256.Create())
|
||||
{
|
||||
using (FileStream fileStream = File.OpenRead(engine_file))
|
||||
{
|
||||
byte[] hashBytes = sha256.ComputeHash(fileStream);
|
||||
now_bit = BitConverter.ToString(hashBytes).Replace("-", string.Empty);
|
||||
}
|
||||
}
|
||||
if (CacheSha.GetE() != now_bit)
|
||||
{
|
||||
Trace.WriteLine("lalalala1");
|
||||
throw new FileReadException("error esu0!");
|
||||
}
|
||||
if (DataStream.dataStream.ecs != now_bit) { DataStream.dataStream.ecs = now_bit; DataStream.write(); }
|
||||
is_check = true;
|
||||
}
|
||||
#region 检测代码
|
||||
//if (mod == StaticHandleA.UpdateMode)
|
||||
//{
|
||||
// if (DataStream.dataStream.ecs.Length > 10)
|
||||
// {
|
||||
// string? now_bit;
|
||||
// using (SHA256 sha256 = SHA256.Create())
|
||||
// {
|
||||
// using (FileStream fileStream = File.OpenRead(engine_file))
|
||||
// {
|
||||
// byte[] hashBytes = sha256.ComputeHash(fileStream);
|
||||
// now_bit = BitConverter.ToString(hashBytes).Replace("-", string.Empty);
|
||||
// }
|
||||
// }
|
||||
// if (DataStream.dataStream.ecs != now_bit)
|
||||
// {
|
||||
// Trace.WriteLine("lalalala" + DataStream.dataStream.ecs);
|
||||
// throw new FileReadException("error esu1!");
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//else if (!is_check && is_first_luancher)
|
||||
//{
|
||||
// string? now_bit;
|
||||
// using (SHA256 sha256 = SHA256.Create())
|
||||
// {
|
||||
// using (FileStream fileStream = File.OpenRead(engine_file))
|
||||
// {
|
||||
// byte[] hashBytes = sha256.ComputeHash(fileStream);
|
||||
// now_bit = BitConverter.ToString(hashBytes).Replace("-", string.Empty);
|
||||
// }
|
||||
// }
|
||||
// if (CacheSha.GetE() != now_bit)
|
||||
// {
|
||||
// Trace.WriteLine("lalalala1");
|
||||
// throw new FileReadException("error esu0!");
|
||||
// }
|
||||
// if (DataStream.dataStream.ecs != now_bit) { DataStream.dataStream.ecs = now_bit; DataStream.write(); }
|
||||
// is_check = true;
|
||||
//}
|
||||
#endregion
|
||||
|
||||
var process = new Process
|
||||
{
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Runtime.ConstrainedExecution;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Zerolauncher.Manager
|
||||
{
|
||||
internal class LoginManager
|
||||
{
|
||||
|
||||
//private static readonly HttpClient client = new HttpClient();
|
||||
|
||||
public static async Task SendPostRequest()
|
||||
@ -45,15 +43,19 @@ namespace Zerolauncher.Manager
|
||||
Console.WriteLine(responseString);
|
||||
}
|
||||
|
||||
public static void GameTest()
|
||||
public static async Task<string?> AssetNet(HttpClient client, SingleGame game, string url, FormUrlEncodedContent? content =null)
|
||||
{
|
||||
//Account account = new Account
|
||||
//{
|
||||
// userName = "b1783488228",
|
||||
// userPWD = "565656",
|
||||
// serverId = "179"
|
||||
//};
|
||||
//SingleGame game = new SingleGame(account);
|
||||
try
|
||||
{
|
||||
var response = content != null? await client.PostAsync(url, content): await client.GetAsync(url);
|
||||
return await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
game.Send($"{StaticHandleS.HintText} 网络发生错误,类型:{ex.GetType().Name},消息:{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static async Task DoLogin(SingleGame game)
|
||||
@ -65,117 +67,60 @@ namespace Zerolauncher.Manager
|
||||
{
|
||||
case 0:
|
||||
game.Send($"{StaticHandleS.HintText} 尝试登玩家{game.account.nickName}到{ServicesStaticInfo.ServicesName[game.account.providerId]}的1服");
|
||||
{
|
||||
HttpResponseMessage response;
|
||||
try
|
||||
{
|
||||
response = await client.GetAsync("http://180.97.189.249:2023");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
game.Send($"{StaticHandleS.HintText} 网络发生错误,类型:{ex.GetType().Name},消息:{ex.Message}");
|
||||
need_web = $"http://180.97.189.249:2023";
|
||||
break;
|
||||
}
|
||||
var responseString = await response.Content.ReadAsStringAsync();
|
||||
int count = 0;
|
||||
while (responseString.Contains("adfwkey"))
|
||||
{
|
||||
if (count++ <= 10)
|
||||
{
|
||||
game.Send($"{StaticHandleS.HintText} 网络被服务器拦截多次,请重试或联系管理员");
|
||||
need_web = $"http://180.97.189.249:2023";
|
||||
break;
|
||||
}
|
||||
var key = responseString.Split("adfwkey=")[1].Split("\"", 2)[0];
|
||||
game.Send($"{StaticHandleS.HintText} 被服务验证拦截-验证码key:{key}");
|
||||
try
|
||||
{
|
||||
response = await client.GetAsync("http://180.97.189.249:2023");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
game.Send($"{StaticHandleS.HintText} 网络发生错误,类型:{ex.GetType().Name},消息:{ex.Message}");
|
||||
need_web = $"http://180.97.189.249:2023";
|
||||
break;
|
||||
}
|
||||
responseString = await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
}
|
||||
need_web = $"http://web.4399.com/stat/togame.php?target=ddt&server_id=S{game.account.serverId}";
|
||||
{
|
||||
var values = new Dictionary<string, string>
|
||||
{
|
||||
{ "loginFrom", "uframe" },
|
||||
{ "postLoginHandler", "default" },
|
||||
{ "layoutSelfAdapting", "true" },
|
||||
{ "externalLogin", "qq" },
|
||||
{ "displayMode", "popup" },
|
||||
{ "layout", "vertical" },
|
||||
{ "appId", "www_home" },
|
||||
{ "mainDivId", "popup_login_div" },
|
||||
{ "includeFcmInfo", "false" },
|
||||
{ "userNameLabel", "4399用户名" },
|
||||
{ "userNameTip", "请输入4399用户名" },
|
||||
{ "welcomeTip", "欢迎回到4399" },
|
||||
{ "username", game.account.userName },
|
||||
{ "password", game.account.userPWD }
|
||||
};
|
||||
var responseString = await AssetNet(client, game, "http://ptlogin.4399.com/ptlogin/login.do?v=1", new FormUrlEncodedContent(values));
|
||||
// eventHandles.__errorCallback('密码错误');
|
||||
if (responseString == null) break;
|
||||
if (responseString.Contains("eventHandles.__errorCallback"))
|
||||
{
|
||||
{ "lUsername", game.account.userName },
|
||||
{ "lPassword", game.account.userPWD }
|
||||
};
|
||||
var content = new FormUrlEncodedContent(values);
|
||||
HttpResponseMessage response;
|
||||
try
|
||||
{
|
||||
response = await client.PostAsync("http://180.97.189.249:2023/form/login.php", content);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
game.Send($"{StaticHandleS.HintText} 网络发生错误,类型:{ex.GetType().Name},消息:{ex.Message}");
|
||||
need_web = $"http://180.97.189.249:2023";
|
||||
game.Send($"{StaticHandleS.HintText} 登录异常:{responseString.Split("eventHandles.__errorCallback('")[1].Split("'")[0]}");
|
||||
break;
|
||||
}
|
||||
var responseString = await response.Content.ReadAsStringAsync();
|
||||
JObject jsonObj = JObject.Parse(responseString);
|
||||
game.Send($"{StaticHandleS.HintText} {jsonObj["title"]}");
|
||||
game.Send($"{StaticHandleS.HintText} {jsonObj["content"]}");
|
||||
if ((int)jsonObj["type"] != 0)
|
||||
{
|
||||
need_web = $"http://180.97.189.249:2023";
|
||||
break;
|
||||
}
|
||||
if(!game.Send($"{StaticHandleS.HintText} 登录成功,开始解析iframe")) return;
|
||||
if (!game.Send($"{StaticHandleS.HintText} 登录成功,开始解析iframe")) return;
|
||||
}
|
||||
{
|
||||
var responseString = await AssetNet(client, game, $"http://web.4399.com/stat/togame.php?target=ddt&server_id=S{game.account.serverId}");
|
||||
if (responseString == null) break;
|
||||
if (!responseString.Contains("name=\"game_box\""))
|
||||
{
|
||||
game.Send($"{StaticHandleS.HintText} 解析异常:服务器返回数据不正确");
|
||||
break;
|
||||
}
|
||||
responseString = responseString.Split("name=\"game_box\"")[1].Split("src=\"")[1].Split("\"")[0];
|
||||
HttpResponseMessage response;
|
||||
try
|
||||
{
|
||||
response = await client.GetAsync("http://180.97.189.249:2023/Play/Play.php?id=1");
|
||||
response = await client.PostAsync(responseString, null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
game.Send($"{StaticHandleS.HintText} 网络发生错误,类型:{ex.GetType().Name},消息:{ex.Message}");
|
||||
need_web = $"http://180.97.189.249:2023";
|
||||
game.Send($"{StaticHandleS.HintText} 网络发生错误,类型:{ex.GetType().Name.Replace(" ", "_")},消息:{ex.Message.Replace(" ", "_")}");
|
||||
break;
|
||||
}
|
||||
var responseString = await response.Content.ReadAsStringAsync();
|
||||
if (!responseString.Contains("var swfPath"))
|
||||
{
|
||||
game.Send($"{StaticHandleS.HintText} 解析异常:服务器返回数据不正确1");
|
||||
need_web = $"http://180.97.189.249:2023";
|
||||
break;
|
||||
}
|
||||
//responseString = "" + responseString.Split("var swfPath")[1].Split("};")[0] + "};";
|
||||
string pattern = @"var swfPath = ""(.*?)"";(.*?){(.*?)};";
|
||||
Match match = Regex.Match(responseString, pattern, RegexOptions.Singleline);
|
||||
|
||||
if (!match.Success)
|
||||
{
|
||||
game.Send($"{StaticHandleS.HintText} 解析异常:服务器返回数据不正确2");
|
||||
//Trace.WriteLine($"---------{responseString}|");
|
||||
need_web = $"http://180.97.189.249:2023";
|
||||
break;
|
||||
}
|
||||
string url = match.Groups[1].Value;
|
||||
string parameters = match.Groups[3].Value;
|
||||
|
||||
string patternParams = @"(\w+): ""(.*?)""";
|
||||
MatchCollection matches = Regex.Matches(parameters, patternParams);
|
||||
|
||||
url += "?";
|
||||
foreach (Match m in matches)
|
||||
{
|
||||
url += $"{m.Groups[1].Value}={WebUtility.UrlEncode(m.Groups[2].Value)}&";
|
||||
}
|
||||
url = url.TrimEnd('&');
|
||||
Trace.WriteLine(url);
|
||||
game.Send($"{StaticHandleS.GameSa} {url}");
|
||||
responseString = await response.Content.ReadAsStringAsync();
|
||||
responseString = "http://" + response.RequestMessage.RequestUri.ToString().Split("/")[2] + "/" + responseString.Split("movie\" value='")[1].Split("'")[0];
|
||||
//Trace.WriteLine(responseString);
|
||||
game.Send($"{StaticHandleS.GameSa} {responseString}");
|
||||
}
|
||||
need_web = null ;
|
||||
break;
|
||||
default:
|
||||
game.Send($"{StaticHandleS.HintText} 错误。未适配的运营商:{game.account.serverId}");
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="169" d:DesignWidth="290">
|
||||
<DockPanel Margin="5">
|
||||
<TextBlock DockPanel.Dock="Top" Margin="5" Text="文本格式:一行一个账号,如:
 服务器---区号---账号---密码---备注
服务器填代号:
 4399是0,7k7k是1,第七大道是2" Foreground="#FFB44242"/>
|
||||
<TextBlock DockPanel.Dock="Top" Margin="5" Text="文本格式:一行一个账号,如:
 服务器---区号---账号---密码---备注
服务器填代号:
 如[0, 4399大区]意味着4399大区的代号是0,
 具体查看添加账号时,以列表显示的为准" Foreground="#FFB44242"/>
|
||||
<DockPanel DockPanel.Dock="Bottom">
|
||||
<Button DockPanel.Dock="Right" Content="选择文件" Click="Button_Click"/>
|
||||
<TextBox Name="input_split" DockPanel.Dock="Right" Text="---" Width="100"/>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user