Skip to content

Commit

Permalink
Build Windows Installer (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
nibanks authored Sep 27, 2022
1 parent cba0edb commit d112dc8
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 19 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ jobs:
cmake -G 'Visual Studio 17 2022' -A x64 -DQUIC_TLS=${{ matrix.tls }} -DQUIC_BUILD_SHARED=${{ matrix.shared }} ..
cmake --build . --config Release
cmake --install . --config Release
- name: Build Windows Installer
if: runner.os == 'Windows'
run: |
cd build
& 'C:/Program Files (x86)/WiX Toolset v3.11/bin/candle.exe' ../src/installer.wxs -o src/Release/quicreach.wixobj
& 'C:/Program Files (x86)/WiX Toolset v3.11/bin/light.exe' -b src/Release -o src/Release/quicreach.msi src/Release/quicreach.wixobj
- name: Upload
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8
with:
Expand All @@ -63,6 +69,7 @@ jobs:
build/**/*.dll
build/**/quicreach
build/**/quicreach.exe
build/**/quicreach.msi
- name: Test (Linux)
if: runner.os == 'Linux'
run: /usr/local/lib/quicreach outlook-evergreen.office.com,www.cloudflare.com,www.google.com --req-all --stats
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,6 @@ MigrationBackup/

# Ionide (cross platform F# VS Code tools) working folder
.ionide/

# VSCode folder
.vscode/
23 changes: 23 additions & 0 deletions src/installer.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*"
Language="1033"
Manufacturer="Microsoft Corporation"
Name="quicreach"
UpgradeCode="8395c163-ac9f-4a89-82fc-689fe25f0777"
Version="1.1.0.0">
<Package InstallScope="perMachine" Compressed="yes" />
<MajorUpgrade DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." />
<MediaTemplate EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="SystemFolder64">
<Component Id="ProductComponent" Guid='4c39c05d-c4bd-44d2-aba6-78abbb0c0d21'>
<File KeyPath="yes" Source="quicreach.exe"></File>
</Component>
</Directory>
</Directory>
<Feature Id="quicreach">
<ComponentRef Id="ProductComponent" />
</Feature>
</Product>
</Wix>
48 changes: 29 additions & 19 deletions src/quicreach.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include <msquic.hpp>
#include "domains.hpp"

#define QUICREACH_VERSION "1.1.0"

#ifdef _WIN32
#define QUIC_CALL __cdecl
#else
Expand Down Expand Up @@ -97,6 +99,24 @@ void IncStat( _Inout_ _Interlocked_operand_ uint32_t volatile &Addend) {
#endif
}

void AddHostName(const char* arg) {
// Parse hostname(s), treating '*' as all top-level domains.
if (!strcmp(arg, "*")) {
for (auto Domain : TopDomains) {
Config.HostNames.push_back(Domain);
}
} else {
char* HostName = (char*)arg;
do {
char* End = strchr(HostName, ',');
if (End) *End = 0;
Config.HostNames.push_back(HostName);
if (!End) break;
HostName = End + 1;
} while (true);
}
}

bool ParseConfig(int argc, char **argv) {
if (argc < 2 || !strcmp(argv[1], "-?") || !strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) {
printf("usage: quicreach <hostname(s)> [options...]\n"
Expand All @@ -110,29 +130,16 @@ bool ParseConfig(int argc, char **argv) {
" -r, --req-all Require all hostnames to succeed\n"
" -s, --stats Print connection statistics\n"
" -u, --unsecure Allows unsecure connections\n"
" -v, --version Prints out the version\n"
);
return false;
}

// Parse hostname(s), treating '*' as all top-level domains.
if (!strcmp(argv[1], "*")) {
for (auto Domain : TopDomains) {
Config.HostNames.push_back(Domain);
}
} else {
char* HostName = (char*)argv[1];
do {
char* End = strchr(HostName, ',');
if (End) *End = 0;
Config.HostNames.push_back(HostName);
if (!End) break;
HostName = End + 1;
} while (true);
}
for (int i = 1; i < argc; ++i) {
if (argv[i][0] != '-') {
AddHostName(argv[i]);

// Parse options.
for (int i = 2; i < argc; ++i) {
if (!strcmp(argv[i], "--alpn") || !strcmp(argv[i], "-a")) {
} else if (!strcmp(argv[i], "--alpn") || !strcmp(argv[i], "-a")) {
if (++i >= argc) { printf("Missing ALPN string\n"); return false; }
Config.Alpn = argv[i];

Expand Down Expand Up @@ -163,6 +170,9 @@ bool ParseConfig(int argc, char **argv) {

} else if (!strcmp(argv[i], "--unsecure") || !strcmp(argv[i], "-u")) {
Config.CredFlags |= QUIC_CREDENTIAL_FLAG_NO_CERTIFICATE_VALIDATION;

} else if (!strcmp(argv[i], "--version") || !strcmp(argv[i], "-v")) {
printf("quicreach " QUICREACH_VERSION "\n");
}
}

Expand Down Expand Up @@ -332,7 +342,7 @@ bool TestReachability() {

int QUIC_CALL main(int argc, char **argv) {

if (!ParseConfig(argc, argv)) return 1;
if (!ParseConfig(argc, argv) || Config.HostNames.empty()) return 1;

MsQuic = new (std::nothrow) MsQuicApi();
if (QUIC_FAILED(MsQuic->GetInitStatus())) {
Expand Down

0 comments on commit d112dc8

Please sign in to comment.