зеркало из https://github.com/microsoft/msquic.git
delete MsQuicTool
This commit is contained in:
Родитель
025741e8ff
Коммит
dfa4d7288c
|
@ -5,8 +5,6 @@ VisualStudioVersion = 17.1.32407.343
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "msquic", "lib\msquic.csproj", "{EE202EA3-7F1D-46FF-9DC9-3BD7AA7845AE}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "msquic", "lib\msquic.csproj", "{EE202EA3-7F1D-46FF-9DC9-3BD7AA7845AE}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MsQuicTool", "tool\MsQuicTool.csproj", "{16C9720E-1875-4953-A03B-A290411B9DF4}"
|
|
||||||
EndProject
|
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -29,18 +27,6 @@ Global
|
||||||
{EE202EA3-7F1D-46FF-9DC9-3BD7AA7845AE}.Release|x64.Build.0 = Release|Any CPU
|
{EE202EA3-7F1D-46FF-9DC9-3BD7AA7845AE}.Release|x64.Build.0 = Release|Any CPU
|
||||||
{EE202EA3-7F1D-46FF-9DC9-3BD7AA7845AE}.Release|x86.ActiveCfg = Release|Any CPU
|
{EE202EA3-7F1D-46FF-9DC9-3BD7AA7845AE}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{EE202EA3-7F1D-46FF-9DC9-3BD7AA7845AE}.Release|x86.Build.0 = Release|Any CPU
|
{EE202EA3-7F1D-46FF-9DC9-3BD7AA7845AE}.Release|x86.Build.0 = Release|Any CPU
|
||||||
{16C9720E-1875-4953-A03B-A290411B9DF4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{16C9720E-1875-4953-A03B-A290411B9DF4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{16C9720E-1875-4953-A03B-A290411B9DF4}.Debug|x64.ActiveCfg = Debug|Any CPU
|
|
||||||
{16C9720E-1875-4953-A03B-A290411B9DF4}.Debug|x64.Build.0 = Debug|Any CPU
|
|
||||||
{16C9720E-1875-4953-A03B-A290411B9DF4}.Debug|x86.ActiveCfg = Debug|Any CPU
|
|
||||||
{16C9720E-1875-4953-A03B-A290411B9DF4}.Debug|x86.Build.0 = Debug|Any CPU
|
|
||||||
{16C9720E-1875-4953-A03B-A290411B9DF4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{16C9720E-1875-4953-A03B-A290411B9DF4}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{16C9720E-1875-4953-A03B-A290411B9DF4}.Release|x64.ActiveCfg = Release|Any CPU
|
|
||||||
{16C9720E-1875-4953-A03B-A290411B9DF4}.Release|x64.Build.0 = Release|Any CPU
|
|
||||||
{16C9720E-1875-4953-A03B-A290411B9DF4}.Release|x86.ActiveCfg = Release|Any CPU
|
|
||||||
{16C9720E-1875-4953-A03B-A290411B9DF4}.Release|x86.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
#pragma warning disable IDE0073
|
|
||||||
//
|
|
||||||
// Copyright (c) Microsoft Corporation.
|
|
||||||
// Licensed under the MIT License.
|
|
||||||
//
|
|
||||||
#pragma warning restore IDE0073
|
|
||||||
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
|
|
||||||
[assembly: InternalsVisibleTo("MsQuicTool")]
|
|
|
@ -1,17 +0,0 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\lib\msquic.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>Exe</OutputType>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
|
@ -1,110 +0,0 @@
|
||||||
//
|
|
||||||
// Copyright (c) Microsoft Corporation.
|
|
||||||
// Licensed under the MIT License.
|
|
||||||
//
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading;
|
|
||||||
using Microsoft.Quic;
|
|
||||||
|
|
||||||
namespace MsQuicTool
|
|
||||||
{
|
|
||||||
class Program
|
|
||||||
{
|
|
||||||
static unsafe void Main(string[] args)
|
|
||||||
{
|
|
||||||
// This code lets us pass in an argument of where to search for the library at.
|
|
||||||
// Very helpful for testing
|
|
||||||
if (args.Length > 0)
|
|
||||||
{
|
|
||||||
NativeLibrary.SetDllImportResolver(typeof(MsQuic).Assembly, (libraryName, assembly, searchPath) =>
|
|
||||||
{
|
|
||||||
if (libraryName != "msquic") return IntPtr.Zero;
|
|
||||||
if (NativeLibrary.TryLoad(args[0], out var ptr))
|
|
||||||
{
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
return IntPtr.Zero;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var ApiTable = MsQuic.Open();
|
|
||||||
const string DomainName = "google.com";
|
|
||||||
QUIC_HANDLE* registration = null;
|
|
||||||
QUIC_HANDLE* configuration = null;
|
|
||||||
QUIC_HANDLE* connection = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
|
|
||||||
MsQuic.ThrowIfFailure(ApiTable->RegistrationOpen(null, ®istration));
|
|
||||||
byte* alpn = stackalloc byte[] { (byte)'h', (byte)'3' };
|
|
||||||
QUIC_BUFFER buffer = new();
|
|
||||||
buffer.Buffer = alpn;
|
|
||||||
buffer.Length = 2;
|
|
||||||
QUIC_SETTINGS settings = new();
|
|
||||||
settings.IsSetFlags = 0;
|
|
||||||
settings.IsSet.PeerBidiStreamCount = 1;
|
|
||||||
settings.PeerBidiStreamCount = 1;
|
|
||||||
settings.IsSet.PeerUnidiStreamCount = 1;
|
|
||||||
settings.PeerUnidiStreamCount = 3;
|
|
||||||
MsQuic.ThrowIfFailure(ApiTable->ConfigurationOpen(registration, &buffer, 1, &settings, (uint)sizeof(QUIC_SETTINGS), null, &configuration));
|
|
||||||
QUIC_CREDENTIAL_CONFIG config = new();
|
|
||||||
config.Flags = QUIC_CREDENTIAL_FLAGS.CLIENT;
|
|
||||||
MsQuic.ThrowIfFailure(ApiTable->ConfigurationLoadCredential(configuration, &config));
|
|
||||||
MsQuic.ThrowIfFailure(ApiTable->ConnectionOpen(registration, &NativeCallback, ApiTable, &connection));
|
|
||||||
sbyte* google = stackalloc sbyte[50];
|
|
||||||
int written = Encoding.UTF8.GetBytes(DomainName, new Span<byte>(google, 50));
|
|
||||||
google[written] = 0;
|
|
||||||
MsQuic.ThrowIfFailure(ApiTable->ConnectionStart(connection, configuration, 0, google, 443));
|
|
||||||
Thread.Sleep(1000);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (connection != null)
|
|
||||||
{
|
|
||||||
ApiTable->ConnectionShutdown(connection, QUIC_CONNECTION_SHUTDOWN_FLAGS.NONE, 0);
|
|
||||||
ApiTable->ConnectionClose(connection);
|
|
||||||
}
|
|
||||||
if (configuration != null)
|
|
||||||
{
|
|
||||||
ApiTable->ConfigurationClose(configuration);
|
|
||||||
}
|
|
||||||
if (registration != null)
|
|
||||||
{
|
|
||||||
ApiTable->RegistrationClose(registration);
|
|
||||||
}
|
|
||||||
MsQuic.Close(ApiTable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[UnmanagedCallersOnly(CallConvs = new Type[] { typeof(CallConvCdecl) })]
|
|
||||||
private static unsafe int NativeCallback(QUIC_HANDLE* handle, void* context, QUIC_CONNECTION_EVENT* evnt)
|
|
||||||
{
|
|
||||||
Console.WriteLine(evnt->Type);
|
|
||||||
if (evnt->Type == QUIC_CONNECTION_EVENT_TYPE.CONNECTED)
|
|
||||||
{
|
|
||||||
QUIC_API_TABLE* ApiTable = (QUIC_API_TABLE*)context;
|
|
||||||
void* buf = stackalloc byte[128];
|
|
||||||
uint len = 128;
|
|
||||||
if (MsQuic.StatusSucceeded(ApiTable->GetParam(handle, MsQuic.QUIC_PARAM_CONN_REMOTE_ADDRESS, &len, buf)))
|
|
||||||
{
|
|
||||||
QuicAddr* addr = (QuicAddr*)(buf);
|
|
||||||
Console.WriteLine($"Connected Family: {addr->Family}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (evnt->Type == QUIC_CONNECTION_EVENT_TYPE.PEER_STREAM_STARTED)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Aborting Stream");
|
|
||||||
return MsQuic.QUIC_STATUS_ABORTED;
|
|
||||||
}
|
|
||||||
if (evnt->Type == QUIC_CONNECTION_EVENT_TYPE.SHUTDOWN_INITIATED_BY_TRANSPORT)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"{evnt->SHUTDOWN_INITIATED_BY_TRANSPORT.Status.ToString("X8")}: {MsQuicException.GetErrorCodeForStatus(evnt->SHUTDOWN_INITIATED_BY_TRANSPORT.Status)}");
|
|
||||||
}
|
|
||||||
return MsQuic.QUIC_STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Загрузка…
Ссылка в новой задаче