Skip to content

Commit

Permalink
DomainName as command line parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
ami-GS committed Nov 18, 2024
1 parent 91abe69 commit c76c9e0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dotnet-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ jobs:
dotnet-version: 6.0.x
- name: Run Lang Interop
shell: pwsh
run: scripts/DotNetTest.ps1 -Config Debug -Arch ${{ matrix.vec.arch }} -Tls ${{ matrix.vec.tls }}
run: scripts/DotNetTest.ps1 -Config Debug -Arch ${{ matrix.vec.arch }} -Tls ${{ matrix.vec.tls }} -DomainName "google.com"
5 changes: 4 additions & 1 deletion scripts/DotNetTest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ param (

[Parameter(Mandatory = $false)]
[string]$ExtraArtifactDir = ""

[Parameter(Mandatory = $true)]
[string]$DomainName = ""
)

Set-StrictMode -Version 'Latest'
Expand All @@ -43,4 +46,4 @@ if ($IsWindows) {
$RootDir = Split-Path $PSScriptRoot -Parent

dotnet build (Join-Path $RootDir src cs)
dotnet run --project (Join-Path $RootDir src cs tool) -- (Join-Path $RootArtifactDir $LibName)
dotnet run --project (Join-Path $RootDir src cs tool) -- $DomainName (Join-Path $RootArtifactDir $LibName)
25 changes: 22 additions & 3 deletions src/cs/tool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,32 @@ 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)
if (args.Length == 0)
{
Console.WriteLine("Usage: MsQuicTool <DomainName> [PathToMsQuic]");
return;
}

string DomainName = args[0];

if (string.IsNullOrWhiteSpace(DomainName))
{
Console.WriteLine("DomainName cannot be empty.");
return;
}

if (DomainName.Length > 253)
{
Console.WriteLine("DomainName is too long.");
return;
}

if (args.Length > 1)
{
NativeLibrary.SetDllImportResolver(typeof(MsQuic).Assembly, (libraryName, assembly, searchPath) =>
{
if (libraryName != "msquic") return IntPtr.Zero;
if (NativeLibrary.TryLoad(args[0], out var ptr))
if (NativeLibrary.TryLoad(args[1], out var ptr))
{
return ptr;
}
Expand All @@ -32,7 +52,6 @@ static unsafe void Main(string[] args)
}

var ApiTable = MsQuic.Open();
const string DomainName = "google.com";
QUIC_HANDLE* registration = null;
QUIC_HANDLE* configuration = null;
QUIC_HANDLE* connection = null;
Expand Down

0 comments on commit c76c9e0

Please sign in to comment.