Update WireSockUI for direct SDK compatibility#104
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates WireSockUI to support direct integration with the WireSock SDK (wgbooster.dll), adding support for several new configuration directives (such as VirtualAdapterMode and BypassLanTraffic), dynamic library discovery, and x64 build configurations. The review feedback highlights several robustness and validation issues: a bug in range validation that permits malformed inputs, potential startup crashes in Program.cs due to unhandled exceptions from malformed environment paths, unintended signaling of the global service event in IsApplicationAlreadyRunning(), and redundant cleanup logic in WireSockManager.cs.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Pull request overview
Updates WireSockUI to remain compatible with the direct wgbooster.dll SDK integration model by improving SDK discovery, aligning native bindings/diagnostics with the updated ABI, and expanding WireSock-specific config parsing/validation and related UI settings.
Changes:
- Updated native wgbooster bindings (log levels,
drop_tunnel(..., preserveNetworkLock),SetLastError) and added richer lifecycle diagnostics. - Implemented direct-SDK
wgbooster.dlldiscovery (app dir / PATH / registry install locations) and adjusted single-instance coordination to match the direct client/service name. - Enhanced config handling:
#@wsdirective parsing, additional profile fields/validation, and updated template + documentation.
Reviewed changes
Copilot reviewed 16 out of 18 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| WireSockUI/WireSockUI.csproj | Disables Prefer32Bit to better align with direct SDK bitness expectations. |
| WireSockUI/WireSockManager.cs | Updates tunnel lifecycle handling, logging, diagnostics, and drop_tunnel ABI usage. |
| WireSockUI/Resources/template.conf | Updates template to use #@ws: directives and adds new optional directives. |
| WireSockUI/Properties/Settings.settings | Changes default log level from None to Error. |
| WireSockUI/Properties/Settings.Designer.cs | Keeps generated default log level consistent with settings. |
| WireSockUI/Properties/Resources.resx | Updates user-facing strings for direct SDK/client messaging. |
| WireSockUI/Program.cs | Implements wgbooster.dll discovery and process PATH augmentation. |
| WireSockUI/Native/WireguardConfigParser.cs | Adds case-insensitive parsing and #@ws prefix support. |
| WireSockUI/Native/WireguardBoosterExports.cs | Aligns interop with updated SDK ABI and error reporting. |
| WireSockUI/Global.cs | Switches single-instance primitive type to EventWaitHandle. |
| WireSockUI/Forms/frmSettings.Designer.cs | Updates log level dropdown options (removes None, adds Warning/Debug). |
| WireSockUI/Forms/frmSettings.cs | Adds fallback when legacy/unknown log level is loaded from settings. |
| WireSockUI/Forms/frmMain.cs | Updates single-instance logic and supports profile-level adapter override. |
| WireSockUI/Forms/frmEdit.cs | Enhances #@ws syntax highlighting/validation and improves save semantics. |
| WireSockUI/Config/Profile.cs | Expands profile parsing/validation (adapter override, scripts, SOCKS options, etc.). |
| WireSockUI/app.config | Updates default log level to Error. |
| WireSockUI.sln | Adds x64 solution/platform mappings. |
| README.md | Replaces archival messaging with direct-SDK compatibility documentation. |
Files not reviewed (2)
- WireSockUI/Forms/frmSettings.Designer.cs: Generated file
- WireSockUI/Properties/Settings.Designer.cs: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Addressed review feedback in f4ff47b:\n- preserve empty H-range parts so malformed ranges like 10- / -10 are rejected\n- avoid signaling the shared direct-client event during instance detection\n- ignore malformed PATH/registry path entries while locating wgbooster.dll and normalizing PATH\n- trim quoted PATH entries during duplicate checks\n- use DropCurrentHandle() on start failure\n- complete the log queue on the finalizer path\n\nVerification:\n- dotnet build WireSockUI.sln\n- dotnet build WireSockUI.sln -p:Configuration=Release -p:Platform=x64 |
|
Addressed the latest review feedback in e09f711:\n- Dispose(false) no longer runs managed cleanup; explicit Dispose() still disconnects and completes the log queue.\n- Missing AllowedApps/DisallowedApps insertions now use the #@ws: extension prefix.\n\nVerification repeated:\n- dotnet build WireSockUI.sln\n- dotnet build WireSockUI.sln -p:Configuration=Release -p:Platform=x64 |
|
Addressed the latest disconnect cleanup review in 76d6f6f:\n- Disconnect() now attempts _dropTunnel even if _stopTunnel throws, logging stop/drop failures separately before clearing managed state.\n\nVerification repeated:\n- dotnet build WireSockUI.sln\n- dotnet build WireSockUI.sln -p:Configuration=Release -p:Platform=x64 |
|
Addressed the latest review feedback in 823aaaf:\n- Dispose(false) now quietly releases the native tunnel handle without managed queue/UI cleanup.\n- SOCKS5 proxy editor validation trims whitespace before address validation.\n- Profile ValidateInt/ValidateBool trim values and ValidateInt uses invariant parsing.\n\nVerification repeated:\n- dotnet build WireSockUI.sln\n- dotnet build WireSockUI.sln -p:Configuration=Release -p:Platform=x64 |
|
Addressed the latest Copilot review in 96c7a4e: registry install locations now take precedence over inherited PATH probing, invalid wgbooster.dll candidate paths emit Trace warnings, and PATH mutation failures emit Trace warnings. Verified with dotnet build WireSockUI.sln and dotnet build WireSockUI.sln -p:Configuration=Release -p:Platform=x64. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 18 changed files in this pull request and generated 4 comments.
Files not reviewed (2)
- WireSockUI/Forms/frmSettings.Designer.cs: Generated file
- WireSockUI/Properties/Settings.Designer.cs: Generated file
Comments suppressed due to low confidence (1)
WireSockUI/Forms/frmEdit.cs:541
- In the error path, File.Delete(tmpProfile) is called even if File.WriteAllText(tmpProfile, ...) failed before creating the file. That can throw (e.g., FileNotFoundException) and crash the save flow while already handling an exception. Guard the cleanup with File.Exists and/or wrap deletion in a try/catch to avoid masking the original validation/write error.
catch (Exception ex)
{
MessageBox.Show(ex.Message, Resources.EditProfileError, MessageBoxButtons.OK, MessageBoxIcon.Error);
File.Delete(tmpProfile);
DialogResult = DialogResult.None;
return;
|
Addressed the latest Copilot review in 9e5a421: Disconnect and DropCurrentHandle now log native diagnostics when stop_tunnel/drop_tunnel return false, PATH is no longer scanned for wgbooster.dll discovery, README discovery order was updated, and temporary profile cleanup is guarded so it cannot mask write/validation errors. Verification repeated: dotnet build WireSockUI.sln and dotnet build WireSockUI.sln -p:Configuration=Release -p:Platform=x64. |
|
Addressed the latest Copilot review in 3ac9d5f: log queue completion now works on both dispose paths without the worker capturing the WireSockManager instance, #@ws directive parsing/stripping now requires a real directive prefix, and the unused struct-based wgb_create_tunnel bindings were removed so WireSockUI relies on the SDK file-based Unicode tunnel creation path it actually uses. Verified against the local wgbooster.h header before removing the unused ABI surface. Verification repeated: dotnet build WireSockUI.sln and dotnet build WireSockUI.sln -p:Configuration=Release -p:Platform=x64. |
|
Addressed the latest Copilot review in de50aeb: native stop/drop cleanup now removes unreachable null branches and logs EntryPointNotFoundException explicitly for missing exports, PATH normalization trims both Windows separator styles, and the single-instance EventWaitHandle path now catches IOException instead of the unreachable WaitHandleCannotBeOpenedException. Verification repeated: dotnet build WireSockUI.sln and dotnet build WireSockUI.sln -p:Configuration=Release -p:Platform=x64. |
|
Addressed the latest Copilot review in f19ec94: corrected the Peer-section validation message grammar from 'an Peer' to 'a Peer'. Verification repeated: dotnet build WireSockUI.sln and dotnet build WireSockUI.sln -p:Configuration=Release -p:Platform=x64. |
|
Addressed the latest Copilot review in e987b36: removed redundant DNS/Dns and PresharedKey/PreSharedKey fallback reads now that profile sections and keys are case-insensitive. Kept distinct compatibility aliases such as Socks5ProxyUsername/Socks5Username. Verification repeated: dotnet build WireSockUI.sln and dotnet build WireSockUI.sln -p:Configuration=Release -p:Platform=x64. |
Summary:
Review notes:
Verification: