1
0
mirror of https://e.coding.net/circlecloud/CTZLauncher.git synced 2024-11-22 02:08:49 +00:00

添加MC协议数据解析项目...

This commit is contained in:
j502647092 2015-08-12 19:49:29 +08:00
parent f739a359bf
commit 2fd9846873
9 changed files with 187 additions and 25 deletions

View File

@ -1,10 +1,12 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013 # Visual Studio 14
VisualStudioVersion = 12.0.21005.1 VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CTZLauncher", "CTZLauncher\CTZLauncher.csproj", "{EC25362D-5BA7-4CB3-BDA2-C575B9318086}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CTZLauncher", "CTZLauncher\CTZLauncher.csproj", "{EC25362D-5BA7-4CB3-BDA2-C575B9318086}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MinecraftServerInfo", "MinecraftServerInfo\MinecraftServerInfo.csproj", "{E178FD27-5F66-4B46-9DAD-4F8CC2D5A7A5}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
CD_ROM|Any CPU = CD_ROM|Any CPU CD_ROM|Any CPU = CD_ROM|Any CPU
@ -24,6 +26,16 @@ Global
{EC25362D-5BA7-4CB3-BDA2-C575B9318086}.Release|Any CPU.Build.0 = Release|Any CPU {EC25362D-5BA7-4CB3-BDA2-C575B9318086}.Release|Any CPU.Build.0 = Release|Any CPU
{EC25362D-5BA7-4CB3-BDA2-C575B9318086}.SingleImage|Any CPU.ActiveCfg = Release|Any CPU {EC25362D-5BA7-4CB3-BDA2-C575B9318086}.SingleImage|Any CPU.ActiveCfg = Release|Any CPU
{EC25362D-5BA7-4CB3-BDA2-C575B9318086}.SingleImage|Any CPU.Build.0 = Release|Any CPU {EC25362D-5BA7-4CB3-BDA2-C575B9318086}.SingleImage|Any CPU.Build.0 = Release|Any CPU
{E178FD27-5F66-4B46-9DAD-4F8CC2D5A7A5}.CD_ROM|Any CPU.ActiveCfg = Release|Any CPU
{E178FD27-5F66-4B46-9DAD-4F8CC2D5A7A5}.CD_ROM|Any CPU.Build.0 = Release|Any CPU
{E178FD27-5F66-4B46-9DAD-4F8CC2D5A7A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E178FD27-5F66-4B46-9DAD-4F8CC2D5A7A5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E178FD27-5F66-4B46-9DAD-4F8CC2D5A7A5}.DVD-5|Any CPU.ActiveCfg = Debug|Any CPU
{E178FD27-5F66-4B46-9DAD-4F8CC2D5A7A5}.DVD-5|Any CPU.Build.0 = Debug|Any CPU
{E178FD27-5F66-4B46-9DAD-4F8CC2D5A7A5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E178FD27-5F66-4B46-9DAD-4F8CC2D5A7A5}.Release|Any CPU.Build.0 = Release|Any CPU
{E178FD27-5F66-4B46-9DAD-4F8CC2D5A7A5}.SingleImage|Any CPU.ActiveCfg = Release|Any CPU
{E178FD27-5F66-4B46-9DAD-4F8CC2D5A7A5}.SingleImage|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -79,7 +79,9 @@
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.VisualBasic" /> <Reference Include="Microsoft.VisualBasic" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Web" />
<Reference Include="System.Xaml" /> <Reference Include="System.Xaml" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
@ -112,7 +114,7 @@
<Compile Include="Authentication\WarpedAuhenticator.cs" /> <Compile Include="Authentication\WarpedAuhenticator.cs" />
<Compile Include="Authentication\Yggdrasil.cs" /> <Compile Include="Authentication\Yggdrasil.cs" />
<Compile Include="Authentication\CTZAuthenticator.cs" /> <Compile Include="Authentication\CTZAuthenticator.cs" />
<Compile Include="HttpHelper.cs" /> <Compile Include="Tools\HttpHelper.cs" />
<Compile Include="Launcher\LaunchArguments.cs" /> <Compile Include="Launcher\LaunchArguments.cs" />
<Compile Include="Launcher\LauncherCore.cs" /> <Compile Include="Launcher\LauncherCore.cs" />
<Compile Include="Launcher\LauncherCoreInternal.cs" /> <Compile Include="Launcher\LauncherCoreInternal.cs" />

View File

@ -1,27 +1,18 @@
using System; using CTZLauncher.Modules.CTZServer;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using KMCCC.Authentication; using KMCCC.Authentication;
using KMCCC.Launcher; using KMCCC.Launcher;
using KMCCC.Tools; using KMCCC.Tools;
using KMCCC.Modules;
using KMCCC.Modules.JVersion;
using CityCraft;
using System.IO;
using System.Windows.Threading;
using System.Windows.Media.Animation;
using LitJson; using LitJson;
using CTZLauncher.Modules.CTZServer; using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
namespace CTZLauncher namespace CTZLauncher
{ {
@ -32,7 +23,7 @@ namespace CTZLauncher
{ {
LauncherCore launcher = null; LauncherCore launcher = null;
LaunchOptions option = new LaunchOptions(); LaunchOptions option = new LaunchOptions();
string serveraddress = "127.0.0.1"; string serveraddress = ConfigurationManager.AppSettings["Server"];
int serverport = 25580; int serverport = 25580;
#region #region

View File

@ -1,3 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<appSettings>
<add key="Server" value="127.0.0.1" />
</appSettings>
</configuration>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>

View File

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E178FD27-5F66-4B46-9DAD-4F8CC2D5A7A5}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MinecraftServerInfo</RootNamespace>
<AssemblyName>MinecraftServerInfo</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
namespace MinecraftServerInfo
{
class Program
{
static void Main(string[] args)
{
using (Socket client = new Socket(SocketType.Stream, ProtocolType.Tcp))
try
{
//01 00
//0F 00-2F 09 31 32 37 2E 30 2E 30 2E 31 63 DD 01
//client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, 1000);
//client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 5000);
//client.Connect("CityCraft.cn", 25565);
client.Connect("four.mengcraft.com", 11133);
Console.WriteLine("开始连接");
if (client.Connected)
{
Console.WriteLine("发送数据");
client.Send(new byte[] { 0x0F, 0x00, 0x2F, 0x09, 0x31, 0x32, 0x37, 0x2E, 0x30, 0x2E, 0x30, 0x2E, 0x31, 0x63, 0xDD, 0x01 });
client.Send(new byte[] { 0x01, 0x00 });
Console.WriteLine("读取头数据");
byte[] header = new byte[5];
client.Receive(header, header.Length, SocketFlags.None);
Console.WriteLine(BitConverter.ToString(header));
byte[] buffer = new byte[1024];
int recover = client.Receive(buffer, buffer.Length, SocketFlags.None);
byte[] data = new byte[recover];
Console.WriteLine("数据流长度: " + recover);
Array.Copy(buffer, data, recover);
Console.WriteLine(BitConverter.ToString(data));
Console.WriteLine(Encoding.UTF8.GetString(data));
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
Console.ReadLine();
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("MinecraftServerInfo")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("MinecraftServerInfo")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//将 ComVisible 设置为 false 将使此程序集中的类型
//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("e178fd27-5f66-4b46-9dad-4f8cc2d5a7a5")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]