mirror of
https://github.com/jmcorgan/fips.git
synced 2026-07-22 07:48:26 +00:00
Gate platform-specific code behind cfg attributes and add full Windows
support: TUN device via wintun, TCP control socket on localhost:21210,
Windows Service lifecycle (--install-service/--uninstall-service/--service),
CI build and test matrix, and packaging with ZIP builder and PowerShell
service management scripts.
Key changes:
- Cargo.toml: move tun/libc/rtnetlink behind cfg(unix); add wintun and
windows-service dependencies for Windows
- upper/tun.rs: wintun-based TUN implementation with netsh configuration
for IPv6 address, MTU, and fd00::/8 routing
- control/mod.rs: split into unix_impl/windows_impl; Windows uses TCP on
localhost:21210 with shared connection handler
- bin/fips.rs: refactor main() into run_daemon() accepting a shutdown
signal; add Windows Service support via windows-service crate
- transport/udp/socket.rs: platform-gated modules; Windows uses
tokio::net::UdpSocket (kernel drop count unavailable, returns 0)
- transport/ethernet: gate to cfg(unix); add Windows stub types
- config: platform-conditional default paths (socket, hosts) for Windows
- CI: add windows-latest to build matrix and test-windows job with
cargo-nextest
- packaging/windows: build-zip.ps1, install-service.ps1,
uninstall-service.ps1, and package-windows.yml workflow
- README/docs: Windows build instructions, service management, and
control socket platform differences
Linux and macOS behavior is unchanged.
74 lines
2.1 KiB
PowerShell
74 lines
2.1 KiB
PowerShell
# Uninstall the FIPS Windows service.
|
|
#
|
|
# Usage: powershell -File uninstall-service.ps1 [-RemoveAll]
|
|
# Requires: Administrator privileges
|
|
#
|
|
# By default preserves config in %ProgramData%\fips\.
|
|
# Pass -RemoveAll to remove config and identity keys too.
|
|
|
|
param(
|
|
[switch]$RemoveAll
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
# Check for admin
|
|
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
|
if (-not $isAdmin) {
|
|
Write-Error "This script requires Administrator privileges. Right-click PowerShell and select 'Run as Administrator'."
|
|
exit 1
|
|
}
|
|
|
|
$InstallDir = "$env:ProgramFiles\fips"
|
|
$ConfigDir = "$env:ProgramData\fips"
|
|
|
|
Write-Host "Uninstalling FIPS service..."
|
|
|
|
# Stop the service if running
|
|
$svc = Get-Service -Name "fips" -ErrorAction SilentlyContinue
|
|
if ($svc -and $svc.Status -eq "Running") {
|
|
Write-Host " Stopping service..."
|
|
Stop-Service -Name "fips" -Force
|
|
}
|
|
|
|
# Uninstall the service
|
|
if (Test-Path "$InstallDir\fips.exe") {
|
|
Write-Host " Removing service registration..."
|
|
& "$InstallDir\fips.exe" --uninstall-service
|
|
}
|
|
|
|
# Remove binaries
|
|
if (Test-Path $InstallDir) {
|
|
Write-Host " Removing $InstallDir"
|
|
Remove-Item -Recurse -Force $InstallDir
|
|
}
|
|
|
|
# Remove from PATH
|
|
$machinePath = [Environment]::GetEnvironmentVariable("Path", "Machine")
|
|
if ($machinePath -like "*$InstallDir*") {
|
|
$newPath = ($machinePath -split ";" | Where-Object { $_ -ne $InstallDir }) -join ";"
|
|
[Environment]::SetEnvironmentVariable("Path", $newPath, "Machine")
|
|
Write-Host " Removed from system PATH"
|
|
}
|
|
|
|
# Remove FIPS_CONFIG env var
|
|
[Environment]::SetEnvironmentVariable("FIPS_CONFIG", $null, "Machine")
|
|
|
|
# Config removal
|
|
if ($RemoveAll) {
|
|
if (Test-Path $ConfigDir) {
|
|
Write-Host " Removing config and keys at $ConfigDir"
|
|
Remove-Item -Recurse -Force $ConfigDir
|
|
}
|
|
} else {
|
|
if (Test-Path $ConfigDir) {
|
|
Write-Host " Preserving config at $ConfigDir"
|
|
}
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "FIPS service uninstalled."
|
|
if (-not $RemoveAll) {
|
|
Write-Host "Config preserved at $ConfigDir (use -RemoveAll to delete)"
|
|
}
|